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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
4
4
  "description": "Prop Futures Algo Trading CLI - Connect to Topstep, Alpha Futures, and other prop firms",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -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
- cachedContracts = result.contracts.map(c => ({
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 popular contracts for trading from API
447
+ * Get all available contracts from API
448
448
  */
449
449
  async getContracts() {
450
450
  try {
451
- // Search for popular futures symbols from API
452
- const symbols = ['ES', 'NQ', 'MES', 'MNQ', 'CL', 'GC', 'RTY', 'YM', 'SI', 'ZB', 'ZN', 'NG', 'MCL', 'MGC'];
453
- const allContracts = [];
451
+ const response = await this._request(
452
+ this.propfirm.gatewayApi, '/api/Contract/available', 'POST',
453
+ { live: false }
454
+ );
454
455
 
455
- for (const sym of symbols) {
456
- const response = await this._request(
457
- this.propfirm.gatewayApi, '/api/Contract/search', 'POST',
458
- { searchText: sym, live: false }
459
- );
460
- if (response.statusCode === 200) {
461
- const contracts = response.data.contracts || response.data || [];
462
- // Take first contract for each symbol (front month)
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: true, contracts: allContracts };
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
  }