hedgequantx 2.9.67 → 2.9.69
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
|
@@ -88,13 +88,22 @@ const oneAccountMenu = async (service) => {
|
|
|
88
88
|
|
|
89
89
|
// Load contracts to find the saved symbol (match by baseSymbol first, then exact symbol)
|
|
90
90
|
const contractsResult = await accountService.getContracts();
|
|
91
|
-
if (contractsResult.success) {
|
|
91
|
+
if (contractsResult.success && contractsResult.contracts.length > 0) {
|
|
92
92
|
// Try baseSymbol match first (more stable across contract rolls)
|
|
93
|
-
|
|
93
|
+
if (lastConfig.baseSymbol) {
|
|
94
|
+
contract = contractsResult.contracts.find(c => c.baseSymbol === lastConfig.baseSymbol);
|
|
95
|
+
}
|
|
94
96
|
// Fall back to exact symbol match
|
|
95
|
-
if (!contract) {
|
|
97
|
+
if (!contract && lastConfig.symbol) {
|
|
96
98
|
contract = contractsResult.contracts.find(c => c.symbol === lastConfig.symbol);
|
|
97
99
|
}
|
|
100
|
+
// Last resort: try to extract base symbol from saved symbol (e.g., MESH6 -> MES)
|
|
101
|
+
if (!contract && lastConfig.symbol) {
|
|
102
|
+
const extractedBase = lastConfig.symbol.replace(/[A-Z]\d+$/, '');
|
|
103
|
+
if (extractedBase) {
|
|
104
|
+
contract = contractsResult.contracts.find(c => c.baseSymbol === extractedBase);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
// Find strategy
|
|
@@ -231,9 +240,19 @@ const oneAccountMenu = async (service) => {
|
|
|
231
240
|
const selectSymbol = async (service, account) => {
|
|
232
241
|
const spinner = ora({ text: 'Loading symbols...', color: 'yellow' }).start();
|
|
233
242
|
|
|
243
|
+
// Ensure we have a logged-in service
|
|
244
|
+
if (!service.loginInfo && service.credentials) {
|
|
245
|
+
spinner.text = 'Reconnecting to broker...';
|
|
246
|
+
const loginResult = await service.login(service.credentials.username, service.credentials.password);
|
|
247
|
+
if (!loginResult.success) {
|
|
248
|
+
spinner.fail(`Login failed: ${loginResult.error}`);
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
234
253
|
const contractsResult = await service.getContracts();
|
|
235
254
|
if (!contractsResult.success || !contractsResult.contracts?.length) {
|
|
236
|
-
spinner.fail(
|
|
255
|
+
spinner.fail(`Failed to load contracts: ${contractsResult.error || 'No contracts'}`);
|
|
237
256
|
return null;
|
|
238
257
|
}
|
|
239
258
|
|