hedgequantx 1.2.95 → 1.2.97
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 +1 -1
- package/src/pages/algo.js +58 -9
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -203,13 +203,50 @@ const selectSymbolMenu = async (service, account) => {
|
|
|
203
203
|
|
|
204
204
|
console.log();
|
|
205
205
|
|
|
206
|
+
// Symbol name descriptions
|
|
207
|
+
const symbolDescriptions = {
|
|
208
|
+
'NQ': 'E-mini NASDAQ-100',
|
|
209
|
+
'MNQ': 'Micro E-mini NASDAQ-100',
|
|
210
|
+
'ES': 'E-mini S&P 500',
|
|
211
|
+
'MES': 'Micro E-mini S&P 500',
|
|
212
|
+
'YM': 'E-mini Dow Jones',
|
|
213
|
+
'MYM': 'Micro E-mini Dow Jones',
|
|
214
|
+
'RTY': 'E-mini Russell 2000',
|
|
215
|
+
'M2K': 'Micro E-mini Russell 2000',
|
|
216
|
+
'CL': 'Crude Oil WTI',
|
|
217
|
+
'MCL': 'Micro Crude Oil',
|
|
218
|
+
'NG': 'Natural Gas',
|
|
219
|
+
'QG': 'E-mini Natural Gas',
|
|
220
|
+
'QM': 'E-mini Crude Oil',
|
|
221
|
+
'GC': 'Gold',
|
|
222
|
+
'MGC': 'Micro Gold',
|
|
223
|
+
'SI': 'Silver',
|
|
224
|
+
'SIL': 'Micro Silver',
|
|
225
|
+
'HG': 'Copper',
|
|
226
|
+
'PL': 'Platinum',
|
|
227
|
+
'6E': 'Euro FX',
|
|
228
|
+
'M6E': 'Micro Euro FX',
|
|
229
|
+
'6B': 'British Pound',
|
|
230
|
+
'6J': 'Japanese Yen',
|
|
231
|
+
'6A': 'Australian Dollar',
|
|
232
|
+
'6C': 'Canadian Dollar',
|
|
233
|
+
'6M': 'Mexican Peso',
|
|
234
|
+
'6S': 'Swiss Franc',
|
|
235
|
+
'ZB': '30-Year T-Bond',
|
|
236
|
+
'ZN': '10-Year T-Note',
|
|
237
|
+
'ZF': '5-Year T-Note',
|
|
238
|
+
'ZT': '2-Year T-Note',
|
|
239
|
+
'ZC': 'Corn',
|
|
240
|
+
'ZS': 'Soybeans',
|
|
241
|
+
'ZW': 'Wheat'
|
|
242
|
+
};
|
|
243
|
+
|
|
206
244
|
// Format symbols for display
|
|
207
245
|
const symbolChoices = availableSymbols.map(symbol => {
|
|
208
|
-
const name = symbol.name || symbol.symbol || symbol.id;
|
|
209
246
|
const symbolCode = symbol.symbol || symbol.id || '';
|
|
210
247
|
|
|
211
248
|
// Extract base symbol (e.g., NQ from NQH6) and month code
|
|
212
|
-
const baseMatch = symbolCode.match(/^([A-
|
|
249
|
+
const baseMatch = symbolCode.match(/^([A-Z0-9]{1,4})([FGHJKMNQUVXZ])(\d{1,2})$/i);
|
|
213
250
|
let baseSymbol = symbolCode;
|
|
214
251
|
let monthYear = '';
|
|
215
252
|
|
|
@@ -221,9 +258,12 @@ const selectSymbolMenu = async (service, account) => {
|
|
|
221
258
|
monthYear = (monthCodes[monthCode] || monthCode) + year;
|
|
222
259
|
}
|
|
223
260
|
|
|
224
|
-
//
|
|
261
|
+
// Get descriptive name from mapping
|
|
262
|
+
const description = symbolDescriptions[baseSymbol] || symbol.name || baseSymbol;
|
|
263
|
+
|
|
264
|
+
// Format: "NQ Mar26 E-mini NASDAQ-100"
|
|
225
265
|
return {
|
|
226
|
-
name: chalk.yellow(baseSymbol.padEnd(5)) + chalk.cyan(monthYear.padEnd(7)) + chalk.white(
|
|
266
|
+
name: chalk.yellow(baseSymbol.padEnd(5)) + chalk.cyan(monthYear.padEnd(7)) + chalk.white(description),
|
|
227
267
|
value: symbol
|
|
228
268
|
};
|
|
229
269
|
});
|
|
@@ -747,11 +787,14 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
747
787
|
|
|
748
788
|
hqxServer.on('disconnected', () => {
|
|
749
789
|
hqxConnected = false;
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
stopReason
|
|
754
|
-
|
|
790
|
+
// Only log error if not intentionally stopped by user
|
|
791
|
+
if (!stopReason || stopReason === 'user') {
|
|
792
|
+
// Don't show error for user-initiated stop
|
|
793
|
+
if (!stopReason) {
|
|
794
|
+
printLog('error', 'Connection lost - Stopping algo');
|
|
795
|
+
stopReason = 'disconnected';
|
|
796
|
+
algoRunning = false;
|
|
797
|
+
}
|
|
755
798
|
}
|
|
756
799
|
});
|
|
757
800
|
|
|
@@ -814,6 +857,7 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
814
857
|
if (!key) return;
|
|
815
858
|
const keyName = key.name?.toLowerCase();
|
|
816
859
|
if (keyName === 'x' || (key.ctrl && keyName === 'c')) {
|
|
860
|
+
stopReason = 'user'; // Set stop reason before cleanup
|
|
817
861
|
cleanup();
|
|
818
862
|
}
|
|
819
863
|
});
|
|
@@ -880,6 +924,9 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
880
924
|
hqxServer.disconnect();
|
|
881
925
|
algoRunning = false;
|
|
882
926
|
|
|
927
|
+
// Clear screen and show final result
|
|
928
|
+
console.clear();
|
|
929
|
+
|
|
883
930
|
console.log();
|
|
884
931
|
if (stopReason === 'target') {
|
|
885
932
|
console.log(chalk.green.bold(' [OK] Daily target reached! Algo stopped.'));
|
|
@@ -887,6 +934,8 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
887
934
|
console.log(chalk.red.bold(' [X] Max risk reached! Algo stopped.'));
|
|
888
935
|
} else if (stopReason === 'disconnected' || stopReason === 'connection_error') {
|
|
889
936
|
console.log(chalk.red.bold(' [X] Connection lost! Algo stopped.'));
|
|
937
|
+
} else if (stopReason === 'user') {
|
|
938
|
+
console.log(chalk.yellow(' [OK] Algo stopped by user'));
|
|
890
939
|
} else {
|
|
891
940
|
console.log(chalk.yellow(' [OK] Algo stopped by user'));
|
|
892
941
|
}
|