hedgequantx 2.9.249 → 2.9.250
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/algo-executor.js +24 -21
package/package.json
CHANGED
|
@@ -119,30 +119,33 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
119
119
|
ui.addLog('system', 'Connecting to market data...');
|
|
120
120
|
|
|
121
121
|
// Listen for position updates from Rithmic (external closes, manual trades)
|
|
122
|
+
// Only if service supports events (RithmicService or DaemonProxyService)
|
|
122
123
|
const accId = account.rithmicAccountId || account.accountId;
|
|
123
|
-
service.on
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
124
|
+
if (typeof service.on === 'function') {
|
|
125
|
+
service.on('positionUpdate', (pos) => {
|
|
126
|
+
// Match by account and symbol
|
|
127
|
+
const posSymbol = pos.contractId || pos.symbol || '';
|
|
128
|
+
const matchesSymbol = posSymbol.includes(contract.name) || posSymbol.includes(contractId) ||
|
|
129
|
+
posSymbol === symbolCode || contractId.includes(posSymbol);
|
|
130
|
+
const matchesAccount = pos.accountId === accId || pos.accountId === account.accountId;
|
|
131
|
+
|
|
132
|
+
if (matchesSymbol && matchesAccount) {
|
|
133
|
+
const qty = parseInt(pos.quantity) || 0;
|
|
134
|
+
if (!isNaN(qty) && Math.abs(qty) < 1000 && qty !== currentPosition) {
|
|
135
|
+
const oldPos = currentPosition;
|
|
136
|
+
currentPosition = qty;
|
|
137
|
+
if (qty === 0 && oldPos !== 0) {
|
|
138
|
+
ui.addLog('trade', `Position closed externally (was ${oldPos})`);
|
|
139
|
+
sessionLogger.log('POSITION', `External close: ${oldPos} -> 0`);
|
|
140
|
+
pendingOrder = false; // Reset pending order flag
|
|
141
|
+
} else if (qty !== 0 && oldPos === 0) {
|
|
142
|
+
ui.addLog('trade', `Position opened externally: ${qty}`);
|
|
143
|
+
sessionLogger.log('POSITION', `External open: 0 -> ${qty}`);
|
|
144
|
+
}
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
146
149
|
|
|
147
150
|
strategy.on('signal', async (signal) => {
|
|
148
151
|
const dir = signal.direction?.toUpperCase() || 'UNKNOWN';
|