hedgequantx 1.8.8 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -133,15 +133,10 @@ const copyTradingMenu = async () => {
|
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
// Cached contracts from API
|
|
137
|
-
let cachedContracts = null;
|
|
138
|
-
|
|
139
136
|
/**
|
|
140
137
|
* Get contracts from ProjectX API (shared for all services)
|
|
141
138
|
*/
|
|
142
139
|
const getContractsFromAPI = async () => {
|
|
143
|
-
if (cachedContracts) return cachedContracts;
|
|
144
|
-
|
|
145
140
|
// Find a ProjectX connection to get contracts from API
|
|
146
141
|
const allConns = connections.getAll();
|
|
147
142
|
const projectxConn = allConns.find(c => c.type === 'projectx');
|
|
@@ -150,12 +145,11 @@ const getContractsFromAPI = async () => {
|
|
|
150
145
|
const result = await projectxConn.service.getContracts();
|
|
151
146
|
if (result.success && result.contracts?.length > 0) {
|
|
152
147
|
// Normalize contract structure - API returns { name: "ESH6", description: "E-mini S&P 500..." }
|
|
153
|
-
|
|
148
|
+
return result.contracts.map(c => ({
|
|
154
149
|
...c,
|
|
155
150
|
symbol: c.name || c.symbol,
|
|
156
151
|
name: c.description || c.name || c.symbol
|
|
157
152
|
}));
|
|
158
|
-
return cachedContracts;
|
|
159
153
|
}
|
|
160
154
|
}
|
|
161
155
|
|
|
@@ -444,29 +444,26 @@ class ProjectXService {
|
|
|
444
444
|
// ==================== CONTRACTS ====================
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
|
-
* Get
|
|
447
|
+
* Get all available contracts from API
|
|
448
448
|
*/
|
|
449
449
|
async getContracts() {
|
|
450
450
|
try {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
const response = await this._request(
|
|
452
|
+
this.propfirm.gatewayApi, '/api/Contract/available', 'POST',
|
|
453
|
+
{ live: false }
|
|
454
|
+
);
|
|
454
455
|
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (contracts.length > 0) {
|
|
464
|
-
allContracts.push(contracts[0]);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
456
|
+
if (response.statusCode === 200) {
|
|
457
|
+
const contracts = response.data.contracts || response.data || [];
|
|
458
|
+
// Filter only active contracts and sort by description
|
|
459
|
+
const activeContracts = contracts
|
|
460
|
+
.filter(c => c.activeContract === true)
|
|
461
|
+
.sort((a, b) => (a.description || '').localeCompare(b.description || ''));
|
|
462
|
+
|
|
463
|
+
return { success: true, contracts: activeContracts };
|
|
467
464
|
}
|
|
468
465
|
|
|
469
|
-
return { success:
|
|
466
|
+
return { success: false, contracts: [], error: 'Failed to fetch contracts' };
|
|
470
467
|
} catch (error) {
|
|
471
468
|
return { success: false, contracts: [], error: error.message };
|
|
472
469
|
}
|