hedgequantx 1.8.5 → 1.8.6
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
|
@@ -137,26 +137,46 @@ const copyTradingMenu = async () => {
|
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
// Cached contracts from API
|
|
141
|
+
let cachedContracts = null;
|
|
142
|
+
|
|
140
143
|
/**
|
|
141
|
-
*
|
|
144
|
+
* Get contracts from ProjectX API (shared for all services)
|
|
145
|
+
*/
|
|
146
|
+
const getContractsFromAPI = async () => {
|
|
147
|
+
if (cachedContracts) return cachedContracts;
|
|
148
|
+
|
|
149
|
+
// Find a ProjectX connection to get contracts from API
|
|
150
|
+
const allConns = connections.getAll();
|
|
151
|
+
const projectxConn = allConns.find(c => c.type === 'projectx');
|
|
152
|
+
|
|
153
|
+
if (projectxConn && typeof projectxConn.service.getContracts === 'function') {
|
|
154
|
+
const result = await projectxConn.service.getContracts();
|
|
155
|
+
if (result.success && result.contracts?.length > 0) {
|
|
156
|
+
cachedContracts = result.contracts;
|
|
157
|
+
return cachedContracts;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return null;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Symbol selection helper - uses API contracts for all services
|
|
142
166
|
*/
|
|
143
167
|
const selectSymbol = async (service, label) => {
|
|
144
168
|
try {
|
|
145
|
-
|
|
169
|
+
// Always use contracts from ProjectX API for consistency
|
|
170
|
+
let contracts = await getContractsFromAPI();
|
|
146
171
|
|
|
147
|
-
|
|
172
|
+
// Fallback to service's own contracts if no ProjectX available
|
|
173
|
+
if (!contracts && typeof service.getContracts === 'function') {
|
|
148
174
|
const result = await service.getContracts();
|
|
149
175
|
if (result.success && result.contracts?.length > 0) {
|
|
150
176
|
contracts = result.contracts;
|
|
151
177
|
}
|
|
152
178
|
}
|
|
153
179
|
|
|
154
|
-
if (contracts.length === 0 && typeof service.searchContracts === 'function') {
|
|
155
|
-
const searchResult = await service.searchContracts('ES');
|
|
156
|
-
if (Array.isArray(searchResult)) contracts = searchResult;
|
|
157
|
-
else if (searchResult?.contracts) contracts = searchResult.contracts;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
180
|
if (!contracts || contracts.length === 0) {
|
|
161
181
|
console.log(chalk.red(' No contracts available'));
|
|
162
182
|
return null;
|