hedgequantx 2.6.51 → 2.6.52
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/one-account.js +5 -3
- package/src/pages/algo/ui.js +26 -10
package/package.json
CHANGED
|
@@ -739,12 +739,14 @@ const launchAlgo = async (service, account, contract, config) => {
|
|
|
739
739
|
const smartLogs = require('./smart-logs');
|
|
740
740
|
const stateLog = smartLogs.getMarketStateLog(ofi, zscore, mom, delta);
|
|
741
741
|
|
|
742
|
-
|
|
742
|
+
// Use stats.position from Rithmic API (real-time WebSocket)
|
|
743
|
+
const positionQty = stats.position || 0;
|
|
744
|
+
if (positionQty !== 0) {
|
|
743
745
|
// In position - show position status with varied messages
|
|
744
|
-
const side =
|
|
746
|
+
const side = positionQty > 0 ? 'LONG' : 'SHORT';
|
|
745
747
|
const unrealizedPnl = stats.openPnl || 0;
|
|
746
748
|
const holdTime = Math.floor((now - (stats.entryTime || now)) / 1000);
|
|
747
|
-
const posLog = smartLogs.getPositionUpdateLog(side, Math.abs(
|
|
749
|
+
const posLog = smartLogs.getPositionUpdateLog(side, Math.abs(positionQty), unrealizedPnl, stats.entryPrice, tickData.price, holdTime);
|
|
748
750
|
ui.addLog('trade', `${posLog.message} - ${posLog.details}`);
|
|
749
751
|
} else {
|
|
750
752
|
// Not in position - show market state with varied messages
|
package/src/pages/algo/ui.js
CHANGED
|
@@ -182,21 +182,37 @@ class AlgoUI {
|
|
|
182
182
|
|
|
183
183
|
this._line(chalk.cyan(GM));
|
|
184
184
|
|
|
185
|
-
// Row 2:
|
|
185
|
+
// Row 2: Open P&L | Closed P&L (essential trading metrics)
|
|
186
|
+
const openPnl = stats.openPnl;
|
|
187
|
+
const closedPnl = stats.closedPnl;
|
|
188
|
+
const openPnlStr = openPnl === null || openPnl === undefined
|
|
189
|
+
? '--'
|
|
190
|
+
: (openPnl >= 0 ? `+$${openPnl.toFixed(2)}` : `-$${Math.abs(openPnl).toFixed(2)}`);
|
|
191
|
+
const closedPnlStr = closedPnl === null || closedPnl === undefined
|
|
192
|
+
? '--'
|
|
193
|
+
: (closedPnl >= 0 ? `+$${closedPnl.toFixed(2)}` : `-$${Math.abs(closedPnl).toFixed(2)}`);
|
|
194
|
+
const openPnlColor = (openPnl || 0) >= 0 ? chalk.green : chalk.red;
|
|
195
|
+
const closedPnlColor = (closedPnl || 0) >= 0 ? chalk.green : chalk.red;
|
|
196
|
+
const r2c1 = buildCell('OPEN P&L', openPnlStr, openPnlColor, colL);
|
|
197
|
+
const r2c2 = buildCell('CLOSED P&L', closedPnlStr, closedPnlColor, colR);
|
|
198
|
+
row(r2c1.padded, r2c2.padded);
|
|
199
|
+
|
|
200
|
+
this._line(chalk.cyan(GM));
|
|
201
|
+
|
|
202
|
+
// Row 3: Target | Risk
|
|
186
203
|
const targetStr = stats.target !== null && stats.target !== undefined ? '$' + stats.target.toFixed(2) : '--';
|
|
187
204
|
const riskStr = stats.risk !== null && stats.risk !== undefined ? '$' + stats.risk.toFixed(2) : '--';
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
row(
|
|
205
|
+
const r3c1 = buildCell('TARGET', targetStr, chalk.green, colL);
|
|
206
|
+
const r3c2 = buildCell('RISK', riskStr, chalk.red, colR);
|
|
207
|
+
row(r3c1.padded, r3c2.padded);
|
|
191
208
|
|
|
192
209
|
this._line(chalk.cyan(GM));
|
|
193
210
|
|
|
194
|
-
// Row
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
row(r3c1t + pad(colL - r3c1p.length), r3c2.padded);
|
|
211
|
+
// Row 4: Trades W/L | Propfirm
|
|
212
|
+
const r4c1t = ` ${chalk.bold('TRADES')}: ${chalk.cyan.bold(stats.trades || 0)} ${chalk.bold('W/L')}: ${chalk.green.bold(stats.wins || 0)}/${chalk.red.bold(stats.losses || 0)}`;
|
|
213
|
+
const r4c1p = ` TRADES: ${stats.trades || 0} W/L: ${stats.wins || 0}/${stats.losses || 0}`;
|
|
214
|
+
const r4c2 = buildCell('PROPFIRM', stats.propfirm || 'N/A', chalk.cyan, colR);
|
|
215
|
+
row(r4c1t + pad(colL - r4c1p.length), r4c2.padded);
|
|
200
216
|
|
|
201
217
|
this._line(chalk.cyan(GB));
|
|
202
218
|
}
|