hedgequantx 2.9.251 → 2.9.253
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
|
@@ -60,6 +60,11 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
60
60
|
let running = true, stopReason = null, startingPnL = null;
|
|
61
61
|
let currentPosition = 0, pendingOrder = false, tickCount = 0, lastBias = 'FLAT';
|
|
62
62
|
|
|
63
|
+
// Clear any stale position data at startup
|
|
64
|
+
if (service.positions) {
|
|
65
|
+
service.positions.clear();
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
// HFT: Use CircularBuffer for O(1) tick storage (replaces O(n) shift())
|
|
64
69
|
const recentTicksBuffer = new CircularBuffer(100);
|
|
65
70
|
const recentSignalsBuffer = new CircularBuffer(10);
|
|
@@ -445,6 +450,11 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
445
450
|
if (Date.now() % 10000 < 2000) {
|
|
446
451
|
const posResult = await service.getPositions(accId);
|
|
447
452
|
if (posResult.success && posResult.positions) {
|
|
453
|
+
// Debug: log all positions
|
|
454
|
+
if (posResult.positions.length > 0) {
|
|
455
|
+
console.log('[Position] Raw positions:', JSON.stringify(posResult.positions));
|
|
456
|
+
}
|
|
457
|
+
|
|
448
458
|
const pos = posResult.positions.find(p => {
|
|
449
459
|
const sym = p.contractId || p.symbol || '';
|
|
450
460
|
return sym.includes(contract.name) || sym.includes(contractId);
|
|
@@ -452,6 +462,7 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
452
462
|
if (pos && pos.quantity !== 0) {
|
|
453
463
|
// Validate quantity is reasonable (prevent overflow values)
|
|
454
464
|
const qty = parseInt(pos.quantity);
|
|
465
|
+
console.log('[Position] Found:', pos.symbol || pos.contractId, 'qty:', qty);
|
|
455
466
|
if (!isNaN(qty) && Math.abs(qty) < 1000) {
|
|
456
467
|
currentPosition = qty;
|
|
457
468
|
}
|