hedgequantx 2.3.17 → 2.3.19

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/dist/lib/api.jsc CHANGED
Binary file
package/dist/lib/api2.jsc CHANGED
Binary file
package/dist/lib/core.jsc CHANGED
Binary file
Binary file
package/dist/lib/data.jsc CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/lib/n/r1.jsc CHANGED
Binary file
package/dist/lib/n/r2.jsc CHANGED
Binary file
package/dist/lib/n/r3.jsc CHANGED
Binary file
package/dist/lib/n/r4.jsc CHANGED
Binary file
package/dist/lib/n/r5.jsc CHANGED
Binary file
package/dist/lib/n/r6.jsc CHANGED
Binary file
package/dist/lib/n/r7.jsc CHANGED
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.3.17",
3
+ "version": "2.3.19",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -189,7 +189,9 @@ const launchAlgo = async (service, account, contract, config) => {
189
189
 
190
190
  let running = true;
191
191
  let stopReason = null;
192
- let lastPnL = 0;
192
+ let startingPnL = null; // P&L at algo start (from API)
193
+ let lastPositionPnL = 0;
194
+ let pollCount = 0;
193
195
 
194
196
  // Log startup info from API
195
197
  ui.addLog('info', `Connection: ${connectionType}`);
@@ -212,6 +214,27 @@ const launchAlgo = async (service, account, contract, config) => {
212
214
  // Poll data from API - 100% real data
213
215
  const pollAPI = async () => {
214
216
  try {
217
+ pollCount++;
218
+
219
+ // Get account P&L from API
220
+ const accountResult = await service.getTradingAccounts();
221
+ if (accountResult.success && accountResult.accounts) {
222
+ const acc = accountResult.accounts.find(a => a.accountId === account.accountId);
223
+ if (acc && acc.profitAndLoss !== undefined) {
224
+ const accountPnL = acc.profitAndLoss;
225
+
226
+ // Set starting P&L on first poll
227
+ if (startingPnL === null) {
228
+ startingPnL = accountPnL;
229
+ ui.addLog('info', `Starting P&L: $${startingPnL.toFixed(2)}`);
230
+ }
231
+
232
+ // Session P&L = current - starting (both from API)
233
+ const sessionPnL = accountPnL - startingPnL;
234
+ stats.pnl = sessionPnL;
235
+ }
236
+ }
237
+
215
238
  // Get positions from API
216
239
  const posResult = await service.getPositions(account.accountId);
217
240
 
@@ -223,62 +246,52 @@ const launchAlgo = async (service, account, contract, config) => {
223
246
  });
224
247
 
225
248
  if (position) {
226
- // P&L directly from API - no calculation
227
- const apiPnL = position.profitAndLoss || 0;
249
+ const positionPnL = position.profitAndLoss || 0;
228
250
 
229
- // Detect trade completion (P&L changed)
230
- if (lastPnL !== 0 && Math.abs(apiPnL - lastPnL) > 0.01) {
231
- const tradePnL = apiPnL - lastPnL;
251
+ // Detect trade completion (position P&L changed significantly)
252
+ if (lastPositionPnL !== 0 && Math.abs(positionPnL - lastPositionPnL) > 0.01) {
253
+ const tradePnL = positionPnL - lastPositionPnL;
232
254
  stats.trades++;
233
255
 
234
256
  if (tradePnL > 0) {
235
257
  stats.wins++;
236
- ui.addLog('trade', `+$${tradePnL.toFixed(2)} (from API)`);
258
+ ui.addLog('trade', `+$${tradePnL.toFixed(2)}`);
237
259
  } else {
238
260
  stats.losses++;
239
- ui.addLog('loss', `-$${Math.abs(tradePnL).toFixed(2)} (from API)`);
261
+ ui.addLog('loss', `-$${Math.abs(tradePnL).toFixed(2)}`);
240
262
  }
241
263
  }
242
264
 
243
- lastPnL = apiPnL;
244
- stats.pnl = apiPnL;
265
+ lastPositionPnL = positionPnL;
245
266
 
246
267
  // Log position info from API
247
268
  if (position.quantity && position.quantity !== 0) {
248
269
  const side = position.quantity > 0 ? 'LONG' : 'SHORT';
249
270
  const qty = Math.abs(position.quantity);
250
- ui.addLog('info', `Position: ${side} ${qty}x | P&L: $${apiPnL.toFixed(2)}`);
271
+ ui.addLog('info', `${side} ${qty}x @ P&L: $${positionPnL.toFixed(2)}`);
251
272
  }
252
273
  } else {
253
- // No position - flat
254
- if (stats.pnl !== 0) {
255
- ui.addLog('info', 'Position closed - Flat');
274
+ // No position for this symbol - log status every 15 polls (~30 sec)
275
+ if (pollCount % 15 === 0) {
276
+ ui.addLog('info', `Waiting for ${symbolName} position... (Session P&L: $${stats.pnl.toFixed(2)})`);
256
277
  }
278
+ lastPositionPnL = 0;
257
279
  }
258
280
  }
259
281
 
260
- // Get account balance from API
261
- const accountResult = await service.getTradingAccounts();
262
- if (accountResult.success && accountResult.accounts) {
263
- const acc = accountResult.accounts.find(a => a.accountId === account.accountId);
264
- if (acc && acc.profitAndLoss !== undefined) {
265
- stats.pnl = acc.profitAndLoss;
266
- }
267
- }
268
-
269
- // Check target/risk limits (using API P&L)
282
+ // Check target/risk limits (using SESSION P&L, not account total)
270
283
  if (stats.pnl >= dailyTarget) {
271
284
  stopReason = 'target';
272
285
  running = false;
273
- ui.addLog('success', `TARGET REACHED! +$${stats.pnl.toFixed(2)}`);
286
+ ui.addLog('success', `SESSION TARGET! +$${stats.pnl.toFixed(2)}`);
274
287
  } else if (stats.pnl <= -maxRisk) {
275
288
  stopReason = 'risk';
276
289
  running = false;
277
- ui.addLog('error', `MAX RISK! -$${Math.abs(stats.pnl).toFixed(2)}`);
290
+ ui.addLog('error', `SESSION MAX RISK! -$${Math.abs(stats.pnl).toFixed(2)}`);
278
291
  }
279
292
 
280
293
  } catch (e) {
281
- ui.addLog('error', `API Error: ${e.message}`);
294
+ ui.addLog('error', `API: ${e.message}`);
282
295
  }
283
296
  };
284
297