hedgequantx 2.9.75 → 2.9.77
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/lib/smart-logs-messages.js +366 -0
- package/src/lib/smart-logs.js +26 -332
- package/src/pages/algo/algo-executor.js +58 -36
package/package.json
CHANGED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* Smart Logs Messages - HF Grade Message Pools
|
|
4
|
+
* =============================================================================
|
|
5
|
+
* Large pools of professional, institutional-grade messages
|
|
6
|
+
* Separated from logic for modularity (RULES.md: max 500 lines per file)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// MESSAGE POOLS - Market Flow (Bullish)
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
const LONG_BIAS_MESSAGES = [
|
|
16
|
+
'Buyers taking control of the tape with aggressive lifting',
|
|
17
|
+
'Bid side absorbing sell pressure at current levels',
|
|
18
|
+
'Bullish order flow detected on liquidity sweep',
|
|
19
|
+
'Buy programs actively lifting offers through resistance',
|
|
20
|
+
'Strong buyer presence accumulating at bid levels',
|
|
21
|
+
'Accumulation pattern forming with increasing volume',
|
|
22
|
+
'Demand exceeding supply - bid stack strengthening',
|
|
23
|
+
'Buyers stepping up with institutional size orders',
|
|
24
|
+
'Long-side momentum building with positive delta',
|
|
25
|
+
'Bid accumulation detected at key support structure',
|
|
26
|
+
'Bullish delta divergence confirmed on tape reading',
|
|
27
|
+
'Buy-side imbalance driving price action higher',
|
|
28
|
+
'Institutional buying flow detected on time and sales',
|
|
29
|
+
'Aggressive bid lifting through stacked offers',
|
|
30
|
+
'Bullish microstructure with strong delta confirmation',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// MESSAGE POOLS - Market Flow (Bearish)
|
|
35
|
+
// =============================================================================
|
|
36
|
+
|
|
37
|
+
const SHORT_BIAS_MESSAGES = [
|
|
38
|
+
'Sellers taking control of the tape with aggressive hitting',
|
|
39
|
+
'Offer side absorbing buy pressure at current levels',
|
|
40
|
+
'Bearish order flow detected on liquidity sweep',
|
|
41
|
+
'Sell programs actively hitting bids through support',
|
|
42
|
+
'Strong seller presence distributing at offer levels',
|
|
43
|
+
'Distribution pattern forming with increasing volume',
|
|
44
|
+
'Supply exceeding demand - offer stack strengthening',
|
|
45
|
+
'Sellers stepping in with institutional size orders',
|
|
46
|
+
'Short-side momentum building with negative delta',
|
|
47
|
+
'Offer distribution detected at key resistance structure',
|
|
48
|
+
'Bearish delta divergence confirmed on tape reading',
|
|
49
|
+
'Sell-side imbalance driving price action lower',
|
|
50
|
+
'Institutional selling flow detected on time and sales',
|
|
51
|
+
'Aggressive offer hitting through stacked bids',
|
|
52
|
+
'Bearish microstructure with weak delta confirmation',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// MESSAGE POOLS - Market Flow (Neutral)
|
|
57
|
+
// =============================================================================
|
|
58
|
+
|
|
59
|
+
const FLAT_BIAS_MESSAGES = [
|
|
60
|
+
'Market balanced with two-way institutional flow',
|
|
61
|
+
'Two-way flow active - no clear directional bias',
|
|
62
|
+
'Consolidation mode with balanced order book',
|
|
63
|
+
'No clear direction - awaiting catalyst for breakout',
|
|
64
|
+
'Mixed signals detected across multiple timeframes',
|
|
65
|
+
'Range-bound activity with absorption on both sides',
|
|
66
|
+
'Equilibrium state - buyers and sellers balanced',
|
|
67
|
+
'Neutral order flow with symmetric book depth',
|
|
68
|
+
'Balanced book pressure at current price levels',
|
|
69
|
+
'Rotation in progress between support and resistance',
|
|
70
|
+
'Price discovery phase with low conviction moves',
|
|
71
|
+
'Awaiting catalyst - volume declining in range',
|
|
72
|
+
'Sideways chop detected with mean reversion behavior',
|
|
73
|
+
'Mean reversion zone - fading extremes profitable',
|
|
74
|
+
'Liquidity absorption on both bid and offer sides',
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// MESSAGE POOLS - Trading Signals
|
|
79
|
+
// =============================================================================
|
|
80
|
+
|
|
81
|
+
const SIGNAL_LONG_MESSAGES = [
|
|
82
|
+
'Buy signal generated with high confidence score',
|
|
83
|
+
'Long opportunity detected at key support level',
|
|
84
|
+
'Bullish setup confirmed with volume confirmation',
|
|
85
|
+
'Entry signal: LONG with optimal risk-reward ratio',
|
|
86
|
+
'Buy zone activated after liquidity sweep completion',
|
|
87
|
+
'Long trigger fired on support zone rejection',
|
|
88
|
+
'Bullish confirmation received from multiple factors',
|
|
89
|
+
'Buy entry validated with strong momentum backing',
|
|
90
|
+
'Long setup materialized with clean price action',
|
|
91
|
+
'Bullish pattern complete - entry conditions met',
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
const SIGNAL_SHORT_MESSAGES = [
|
|
95
|
+
'Sell signal generated with high confidence score',
|
|
96
|
+
'Short opportunity detected at key resistance level',
|
|
97
|
+
'Bearish setup confirmed with volume confirmation',
|
|
98
|
+
'Entry signal: SHORT with optimal risk-reward ratio',
|
|
99
|
+
'Sell zone activated after liquidity sweep completion',
|
|
100
|
+
'Short trigger fired on resistance zone rejection',
|
|
101
|
+
'Bearish confirmation received from multiple factors',
|
|
102
|
+
'Sell entry validated with strong momentum backing',
|
|
103
|
+
'Short setup materialized with clean price action',
|
|
104
|
+
'Bearish pattern complete - entry conditions met',
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
// =============================================================================
|
|
108
|
+
// MESSAGE POOLS - Trade Execution
|
|
109
|
+
// =============================================================================
|
|
110
|
+
|
|
111
|
+
const ENTRY_LONG_MESSAGES = [
|
|
112
|
+
'Long position opened at optimal entry price',
|
|
113
|
+
'Buy order filled with minimal slippage execution',
|
|
114
|
+
'Entered long with bracket orders attached',
|
|
115
|
+
'Long initiated at support zone rejection level',
|
|
116
|
+
'Position: LONG with defined risk parameters',
|
|
117
|
+
'Long execution complete with stop and target set',
|
|
118
|
+
'Buy fill confirmed at expected price level',
|
|
119
|
+
'Long entry executed with tight spread capture',
|
|
120
|
+
'Bought at market with immediate fill confirmation',
|
|
121
|
+
'Long position established with risk management active',
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
const ENTRY_SHORT_MESSAGES = [
|
|
125
|
+
'Short position opened at optimal entry price',
|
|
126
|
+
'Sell order filled with minimal slippage execution',
|
|
127
|
+
'Entered short with bracket orders attached',
|
|
128
|
+
'Short initiated at resistance zone rejection level',
|
|
129
|
+
'Position: SHORT with defined risk parameters',
|
|
130
|
+
'Short execution complete with stop and target set',
|
|
131
|
+
'Sell fill confirmed at expected price level',
|
|
132
|
+
'Short entry executed with tight spread capture',
|
|
133
|
+
'Sold at market with immediate fill confirmation',
|
|
134
|
+
'Short position established with risk management active',
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const EXIT_PROFIT_MESSAGES = [
|
|
138
|
+
'Target reached - profit locked successfully',
|
|
139
|
+
'Profit taken at predetermined target level',
|
|
140
|
+
'Winner closed with full target achievement',
|
|
141
|
+
'TP hit - position closed with realized gain',
|
|
142
|
+
'Profit locked after successful trade execution',
|
|
143
|
+
'Gain realized - trade objective completed',
|
|
144
|
+
'Profitable exit at optimal price level',
|
|
145
|
+
'Target achieved with clean execution',
|
|
146
|
+
'Winner booked - adding to session P&L',
|
|
147
|
+
'Profit captured at resistance/support level',
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
const EXIT_LOSS_MESSAGES = [
|
|
151
|
+
'Stop triggered - risk contained as planned',
|
|
152
|
+
'Loss taken within acceptable risk parameters',
|
|
153
|
+
'Loser closed - preserving capital for next setup',
|
|
154
|
+
'SL hit - position closed with controlled loss',
|
|
155
|
+
'Risk contained - stop loss executed properly',
|
|
156
|
+
'Loss realized within predefined risk budget',
|
|
157
|
+
'Stop executed at predetermined level',
|
|
158
|
+
'Risk managed - loss within acceptable range',
|
|
159
|
+
'Loser booked - maintaining risk discipline',
|
|
160
|
+
'Loss controlled - ready for next opportunity',
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
// =============================================================================
|
|
164
|
+
// MESSAGE POOLS - Zone Analysis
|
|
165
|
+
// =============================================================================
|
|
166
|
+
|
|
167
|
+
const ZONE_APPROACH_MESSAGES = [
|
|
168
|
+
'Approaching key liquidity zone for potential sweep',
|
|
169
|
+
'Zone test incoming - monitoring for rejection',
|
|
170
|
+
'Near decision point - watching order flow closely',
|
|
171
|
+
'Level approach detected with increasing volume',
|
|
172
|
+
'Key zone in range - preparing for reaction',
|
|
173
|
+
'Price nearing structure with momentum building',
|
|
174
|
+
'Zone proximity alert - sweep opportunity forming',
|
|
175
|
+
'Testing liquidity zone for potential entry',
|
|
176
|
+
'Approaching pivot level with volume confirmation',
|
|
177
|
+
'Near high-volume node - expecting reaction',
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
const ZONE_CONFIRMED_MESSAGES = [
|
|
181
|
+
'Zone confirmation - level holding with rejection',
|
|
182
|
+
'Level validated with strong order flow response',
|
|
183
|
+
'Support/resistance active with visible defense',
|
|
184
|
+
'Zone reaction detected - entry signal possible',
|
|
185
|
+
'Level holding with institutional participation',
|
|
186
|
+
'Structure confirmed by price action rejection',
|
|
187
|
+
'Zone defense active with absorption visible',
|
|
188
|
+
'Level response detected on tape reading',
|
|
189
|
+
'Pivot confirmed with volume at level',
|
|
190
|
+
'Volume node reaction - zone integrity intact',
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
// =============================================================================
|
|
194
|
+
// MESSAGE POOLS - Volatility
|
|
195
|
+
// =============================================================================
|
|
196
|
+
|
|
197
|
+
const HIGH_VOLATILITY_MESSAGES = [
|
|
198
|
+
'Volatility elevated - widening stops recommended',
|
|
199
|
+
'High ATR detected - adjust position sizing',
|
|
200
|
+
'Increased price range with fast moves',
|
|
201
|
+
'Market volatile - exercise caution on entries',
|
|
202
|
+
'Wide swings detected with rapid reversals',
|
|
203
|
+
'Volatility expansion phase - breakout conditions',
|
|
204
|
+
'Range expanding with momentum acceleration',
|
|
205
|
+
'High activity zone - increased tick velocity',
|
|
206
|
+
'Momentum surge with strong directional moves',
|
|
207
|
+
'Breakout conditions with volume confirmation',
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
const LOW_VOLATILITY_MESSAGES = [
|
|
211
|
+
'Low volatility - tighten stops for efficiency',
|
|
212
|
+
'Tight range detected - breakout pending',
|
|
213
|
+
'Compressed price action before expansion',
|
|
214
|
+
'Market quiet - awaiting catalyst for move',
|
|
215
|
+
'Narrow swings with decreasing volume',
|
|
216
|
+
'Volatility contraction - coiling for breakout',
|
|
217
|
+
'Range compressing with lowering highs/lows',
|
|
218
|
+
'Low activity zone - patience required',
|
|
219
|
+
'Momentum cooling with decreasing velocity',
|
|
220
|
+
'Consolidation forming before next move',
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
// =============================================================================
|
|
224
|
+
// MESSAGE POOLS - Risk Management
|
|
225
|
+
// =============================================================================
|
|
226
|
+
|
|
227
|
+
const RISK_PASSED_MESSAGES = [
|
|
228
|
+
'Risk check passed - trade within parameters',
|
|
229
|
+
'Trade approved by risk management filters',
|
|
230
|
+
'Within risk limits - position size acceptable',
|
|
231
|
+
'Risk validated - all criteria satisfied',
|
|
232
|
+
'Clear to trade - no risk constraints violated',
|
|
233
|
+
'Risk parameters met for current market conditions',
|
|
234
|
+
'Position size approved within daily limits',
|
|
235
|
+
'Risk budget OK - sufficient margin available',
|
|
236
|
+
'Trade authorized by all risk filters',
|
|
237
|
+
'Risk constraints satisfied - executing trade',
|
|
238
|
+
];
|
|
239
|
+
|
|
240
|
+
const RISK_BLOCKED_MESSAGES = [
|
|
241
|
+
'Risk limit reached - trade blocked for protection',
|
|
242
|
+
'Trade blocked - exceeds position size limits',
|
|
243
|
+
'Exceeds risk threshold - reduce size or wait',
|
|
244
|
+
'Risk rejected - daily loss limit approaching',
|
|
245
|
+
'Waiting for conditions - risk too elevated',
|
|
246
|
+
'Risk parameters exceeded - trade not allowed',
|
|
247
|
+
'Position size rejected - above maximum allowed',
|
|
248
|
+
'Risk budget depleted - no new trades until reset',
|
|
249
|
+
'Trade denied - would exceed drawdown limits',
|
|
250
|
+
'Risk constraints violated - protecting capital',
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
// =============================================================================
|
|
254
|
+
// MESSAGE POOLS - Status
|
|
255
|
+
// =============================================================================
|
|
256
|
+
|
|
257
|
+
const SCANNING_MESSAGES = [
|
|
258
|
+
'Scanning market for liquidity sweep opportunities...',
|
|
259
|
+
'Analyzing order flow for directional bias...',
|
|
260
|
+
'Monitoring market structure for zone formation...',
|
|
261
|
+
'Watching for swing point development...',
|
|
262
|
+
'Evaluating conditions for high-probability setup...',
|
|
263
|
+
'Processing market data through strategy filters...',
|
|
264
|
+
'Analyzing order book depth and imbalances...',
|
|
265
|
+
'Monitoring tape for institutional activity...',
|
|
266
|
+
'Scanning for alpha-generating opportunities...',
|
|
267
|
+
'Evaluating price action at key levels...',
|
|
268
|
+
'Analyzing microstructure for edge detection...',
|
|
269
|
+
'Monitoring bid/ask imbalances for signals...',
|
|
270
|
+
'Scanning liquidity zones for sweep setups...',
|
|
271
|
+
'Evaluating momentum across timeframes...',
|
|
272
|
+
'Analyzing market regime for strategy alignment...',
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
const WAITING_MESSAGES = [
|
|
276
|
+
'Waiting for sweep confirmation before entry...',
|
|
277
|
+
'Pending trigger - zone penetration required...',
|
|
278
|
+
'Standby mode - conditions not yet met...',
|
|
279
|
+
'Awaiting signal - monitoring zone closely...',
|
|
280
|
+
'Ready to act on confirmed liquidity sweep...',
|
|
281
|
+
'Monitoring for entry trigger activation...',
|
|
282
|
+
'Waiting for setup completion with rejection...',
|
|
283
|
+
'Confirmation pending - need price rejection...',
|
|
284
|
+
'Entry conditions not met - patience required...',
|
|
285
|
+
'Awaiting confluence of multiple factors...',
|
|
286
|
+
];
|
|
287
|
+
|
|
288
|
+
// =============================================================================
|
|
289
|
+
// MESSAGE POOLS - Data Flow
|
|
290
|
+
// =============================================================================
|
|
291
|
+
|
|
292
|
+
const TICK_FLOW_MESSAGES = [
|
|
293
|
+
'Processing tick data from Rithmic feed',
|
|
294
|
+
'Market data flowing with normal latency',
|
|
295
|
+
'Live feed active - all systems operational',
|
|
296
|
+
'Tick stream healthy with consistent flow',
|
|
297
|
+
'Data streaming from ticker plant connection',
|
|
298
|
+
'Feed connection stable - no packet loss',
|
|
299
|
+
'Real-time data active and synchronized',
|
|
300
|
+
'Tick processing nominal - strategy receiving',
|
|
301
|
+
'Data pipeline healthy - low latency confirmed',
|
|
302
|
+
'Market feed online with full depth',
|
|
303
|
+
'Tick ingestion active at expected rate',
|
|
304
|
+
'Data flow nominal - no gaps detected',
|
|
305
|
+
'Stream latency optimal for execution',
|
|
306
|
+
'Feed quality excellent - clean data',
|
|
307
|
+
'Data throughput normal for current session',
|
|
308
|
+
];
|
|
309
|
+
|
|
310
|
+
const BUILDING_BARS_MESSAGES = [
|
|
311
|
+
'Building price bars from tick aggregation',
|
|
312
|
+
'Aggregating ticks into OHLC structure',
|
|
313
|
+
'Forming candles for pattern analysis',
|
|
314
|
+
'Bar construction in progress with volume',
|
|
315
|
+
'Chart building from real-time tick data',
|
|
316
|
+
'OHLC aggregation updating continuously',
|
|
317
|
+
'Bar formation active for strategy input',
|
|
318
|
+
'Candle building with volume profile',
|
|
319
|
+
'Time bar processing for signal generation',
|
|
320
|
+
'Bar data updating with new tick input',
|
|
321
|
+
];
|
|
322
|
+
|
|
323
|
+
const MODEL_ANALYSIS_MESSAGES = [
|
|
324
|
+
'Running quantitative models on live data',
|
|
325
|
+
'Analyzing patterns for signal generation',
|
|
326
|
+
'Computing signals from multiple factors',
|
|
327
|
+
'Model evaluation in progress continuously',
|
|
328
|
+
'Strategy analysis with real-time inputs',
|
|
329
|
+
'Pattern recognition scanning price action',
|
|
330
|
+
'Signal computation from order flow data',
|
|
331
|
+
'Model processing tick-by-tick updates',
|
|
332
|
+
'Algorithm evaluation for trade signals',
|
|
333
|
+
'Quantitative analysis of market microstructure',
|
|
334
|
+
'Statistical modeling of price behavior',
|
|
335
|
+
'Feature extraction from market data',
|
|
336
|
+
'Predictive analysis for entry timing',
|
|
337
|
+
'Model optimization based on conditions',
|
|
338
|
+
'Multi-factor analysis for signal quality',
|
|
339
|
+
];
|
|
340
|
+
|
|
341
|
+
// =============================================================================
|
|
342
|
+
// EXPORTS
|
|
343
|
+
// =============================================================================
|
|
344
|
+
|
|
345
|
+
module.exports = {
|
|
346
|
+
LONG_BIAS_MESSAGES,
|
|
347
|
+
SHORT_BIAS_MESSAGES,
|
|
348
|
+
FLAT_BIAS_MESSAGES,
|
|
349
|
+
SIGNAL_LONG_MESSAGES,
|
|
350
|
+
SIGNAL_SHORT_MESSAGES,
|
|
351
|
+
ENTRY_LONG_MESSAGES,
|
|
352
|
+
ENTRY_SHORT_MESSAGES,
|
|
353
|
+
EXIT_PROFIT_MESSAGES,
|
|
354
|
+
EXIT_LOSS_MESSAGES,
|
|
355
|
+
ZONE_APPROACH_MESSAGES,
|
|
356
|
+
ZONE_CONFIRMED_MESSAGES,
|
|
357
|
+
HIGH_VOLATILITY_MESSAGES,
|
|
358
|
+
LOW_VOLATILITY_MESSAGES,
|
|
359
|
+
RISK_PASSED_MESSAGES,
|
|
360
|
+
RISK_BLOCKED_MESSAGES,
|
|
361
|
+
SCANNING_MESSAGES,
|
|
362
|
+
WAITING_MESSAGES,
|
|
363
|
+
TICK_FLOW_MESSAGES,
|
|
364
|
+
BUILDING_BARS_MESSAGES,
|
|
365
|
+
MODEL_ANALYSIS_MESSAGES,
|
|
366
|
+
};
|
package/src/lib/smart-logs.js
CHANGED
|
@@ -3,18 +3,42 @@
|
|
|
3
3
|
* Smart Logging System - HF Grade
|
|
4
4
|
* =============================================================================
|
|
5
5
|
* Non-repetitive, contextual, varied log messages for professional HF CLI
|
|
6
|
-
* - Large message pools (
|
|
6
|
+
* - Large message pools (15 per category) to avoid repetition
|
|
7
7
|
* - Tracks recent messages to ensure variety
|
|
8
8
|
* - Professional, institutional-grade messaging
|
|
9
|
+
*
|
|
10
|
+
* Messages are in separate file: smart-logs-messages.js (RULES.md compliance)
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
'use strict';
|
|
12
14
|
|
|
13
15
|
const chalk = require('chalk');
|
|
16
|
+
const {
|
|
17
|
+
LONG_BIAS_MESSAGES,
|
|
18
|
+
SHORT_BIAS_MESSAGES,
|
|
19
|
+
FLAT_BIAS_MESSAGES,
|
|
20
|
+
SIGNAL_LONG_MESSAGES,
|
|
21
|
+
SIGNAL_SHORT_MESSAGES,
|
|
22
|
+
ENTRY_LONG_MESSAGES,
|
|
23
|
+
ENTRY_SHORT_MESSAGES,
|
|
24
|
+
EXIT_PROFIT_MESSAGES,
|
|
25
|
+
EXIT_LOSS_MESSAGES,
|
|
26
|
+
ZONE_APPROACH_MESSAGES,
|
|
27
|
+
ZONE_CONFIRMED_MESSAGES,
|
|
28
|
+
HIGH_VOLATILITY_MESSAGES,
|
|
29
|
+
LOW_VOLATILITY_MESSAGES,
|
|
30
|
+
RISK_PASSED_MESSAGES,
|
|
31
|
+
RISK_BLOCKED_MESSAGES,
|
|
32
|
+
SCANNING_MESSAGES,
|
|
33
|
+
WAITING_MESSAGES,
|
|
34
|
+
TICK_FLOW_MESSAGES,
|
|
35
|
+
BUILDING_BARS_MESSAGES,
|
|
36
|
+
MODEL_ANALYSIS_MESSAGES,
|
|
37
|
+
} = require('./smart-logs-messages');
|
|
14
38
|
|
|
15
39
|
// Track recently used messages to avoid repetition
|
|
16
40
|
const recentMessages = new Map();
|
|
17
|
-
const MAX_RECENT = 8;
|
|
41
|
+
const MAX_RECENT = 8;
|
|
18
42
|
|
|
19
43
|
/**
|
|
20
44
|
* Get a message from a pool, avoiding recent ones
|
|
@@ -36,336 +60,6 @@ function getVariedMessage(category, pool, defaultMsg) {
|
|
|
36
60
|
return chosen;
|
|
37
61
|
}
|
|
38
62
|
|
|
39
|
-
// =============================================================================
|
|
40
|
-
// MESSAGE POOLS - Market Flow (Bullish)
|
|
41
|
-
// =============================================================================
|
|
42
|
-
|
|
43
|
-
const LONG_BIAS_MESSAGES = [
|
|
44
|
-
'Buyers taking control of the tape',
|
|
45
|
-
'Bid side absorbing sell pressure',
|
|
46
|
-
'Bullish order flow detected on sweep',
|
|
47
|
-
'Buy programs actively lifting offers',
|
|
48
|
-
'Strong buyer presence at current levels',
|
|
49
|
-
'Accumulation pattern forming on volume',
|
|
50
|
-
'Demand exceeding supply at bid',
|
|
51
|
-
'Buyers stepping up with size',
|
|
52
|
-
'Long-side momentum building steadily',
|
|
53
|
-
'Bid accumulation detected at support',
|
|
54
|
-
'Bullish delta divergence confirmed',
|
|
55
|
-
'Buy-side imbalance driving price higher',
|
|
56
|
-
'Institutional buying detected on tape',
|
|
57
|
-
'Aggressive bid lifting through offers',
|
|
58
|
-
'Bullish tape reading with strong delta',
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
// =============================================================================
|
|
62
|
-
// MESSAGE POOLS - Market Flow (Bearish)
|
|
63
|
-
// =============================================================================
|
|
64
|
-
|
|
65
|
-
const SHORT_BIAS_MESSAGES = [
|
|
66
|
-
'Sellers taking control of the tape',
|
|
67
|
-
'Offer side absorbing buy pressure',
|
|
68
|
-
'Bearish order flow detected on sweep',
|
|
69
|
-
'Sell programs actively hitting bids',
|
|
70
|
-
'Strong seller presence at current levels',
|
|
71
|
-
'Distribution pattern forming on volume',
|
|
72
|
-
'Supply exceeding demand at offer',
|
|
73
|
-
'Sellers stepping in with size',
|
|
74
|
-
'Short-side momentum building steadily',
|
|
75
|
-
'Offer distribution detected at resistance',
|
|
76
|
-
'Bearish delta divergence confirmed',
|
|
77
|
-
'Sell-side imbalance driving price lower',
|
|
78
|
-
'Institutional selling detected on tape',
|
|
79
|
-
'Aggressive offer hitting through bids',
|
|
80
|
-
'Bearish tape reading with weak delta',
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
// =============================================================================
|
|
84
|
-
// MESSAGE POOLS - Market Flow (Neutral)
|
|
85
|
-
// =============================================================================
|
|
86
|
-
|
|
87
|
-
const FLAT_BIAS_MESSAGES = [
|
|
88
|
-
'Market balanced',
|
|
89
|
-
'Two-way flow active',
|
|
90
|
-
'Consolidation mode',
|
|
91
|
-
'No clear direction',
|
|
92
|
-
'Mixed signals detected',
|
|
93
|
-
'Range-bound activity',
|
|
94
|
-
'Equilibrium state',
|
|
95
|
-
'Neutral order flow',
|
|
96
|
-
'Balanced book pressure',
|
|
97
|
-
'Rotation in progress',
|
|
98
|
-
'Price discovery phase',
|
|
99
|
-
'Awaiting catalyst',
|
|
100
|
-
'Sideways chop detected',
|
|
101
|
-
'Mean reversion zone',
|
|
102
|
-
'Liquidity absorption',
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
// =============================================================================
|
|
106
|
-
// MESSAGE POOLS - Trading Signals
|
|
107
|
-
// =============================================================================
|
|
108
|
-
|
|
109
|
-
const SIGNAL_LONG_MESSAGES = [
|
|
110
|
-
'Buy signal generated',
|
|
111
|
-
'Long opportunity detected',
|
|
112
|
-
'Bullish setup confirmed',
|
|
113
|
-
'Entry signal: LONG',
|
|
114
|
-
'Buy zone activated',
|
|
115
|
-
'Long trigger fired',
|
|
116
|
-
'Bullish confirmation received',
|
|
117
|
-
'Buy entry validated',
|
|
118
|
-
'Long setup materialized',
|
|
119
|
-
'Bullish pattern complete',
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
const SIGNAL_SHORT_MESSAGES = [
|
|
123
|
-
'Sell signal generated',
|
|
124
|
-
'Short opportunity detected',
|
|
125
|
-
'Bearish setup confirmed',
|
|
126
|
-
'Entry signal: SHORT',
|
|
127
|
-
'Sell zone activated',
|
|
128
|
-
'Short trigger fired',
|
|
129
|
-
'Bearish confirmation received',
|
|
130
|
-
'Sell entry validated',
|
|
131
|
-
'Short setup materialized',
|
|
132
|
-
'Bearish pattern complete',
|
|
133
|
-
];
|
|
134
|
-
|
|
135
|
-
// =============================================================================
|
|
136
|
-
// MESSAGE POOLS - Trade Execution
|
|
137
|
-
// =============================================================================
|
|
138
|
-
|
|
139
|
-
const ENTRY_LONG_MESSAGES = [
|
|
140
|
-
'Long position opened',
|
|
141
|
-
'Buy order filled',
|
|
142
|
-
'Entered long',
|
|
143
|
-
'Long initiated',
|
|
144
|
-
'Position: LONG',
|
|
145
|
-
'Long execution complete',
|
|
146
|
-
'Buy fill confirmed',
|
|
147
|
-
'Long entry executed',
|
|
148
|
-
'Bought at market',
|
|
149
|
-
'Long position established',
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
const ENTRY_SHORT_MESSAGES = [
|
|
153
|
-
'Short position opened',
|
|
154
|
-
'Sell order filled',
|
|
155
|
-
'Entered short',
|
|
156
|
-
'Short initiated',
|
|
157
|
-
'Position: SHORT',
|
|
158
|
-
'Short execution complete',
|
|
159
|
-
'Sell fill confirmed',
|
|
160
|
-
'Short entry executed',
|
|
161
|
-
'Sold at market',
|
|
162
|
-
'Short position established',
|
|
163
|
-
];
|
|
164
|
-
|
|
165
|
-
const EXIT_PROFIT_MESSAGES = [
|
|
166
|
-
'Target reached',
|
|
167
|
-
'Profit taken',
|
|
168
|
-
'Winner closed',
|
|
169
|
-
'TP hit',
|
|
170
|
-
'Profit locked',
|
|
171
|
-
'Gain realized',
|
|
172
|
-
'Profitable exit',
|
|
173
|
-
'Target achieved',
|
|
174
|
-
'Winner booked',
|
|
175
|
-
'Profit captured',
|
|
176
|
-
];
|
|
177
|
-
|
|
178
|
-
const EXIT_LOSS_MESSAGES = [
|
|
179
|
-
'Stop triggered',
|
|
180
|
-
'Loss taken',
|
|
181
|
-
'Loser closed',
|
|
182
|
-
'SL hit',
|
|
183
|
-
'Risk contained',
|
|
184
|
-
'Loss realized',
|
|
185
|
-
'Stop executed',
|
|
186
|
-
'Risk managed',
|
|
187
|
-
'Loser booked',
|
|
188
|
-
'Loss controlled',
|
|
189
|
-
];
|
|
190
|
-
|
|
191
|
-
// =============================================================================
|
|
192
|
-
// MESSAGE POOLS - Zone Analysis
|
|
193
|
-
// =============================================================================
|
|
194
|
-
|
|
195
|
-
const ZONE_APPROACH_MESSAGES = [
|
|
196
|
-
'Approaching key level',
|
|
197
|
-
'Zone test incoming',
|
|
198
|
-
'Near decision point',
|
|
199
|
-
'Level approach detected',
|
|
200
|
-
'Key zone in range',
|
|
201
|
-
'Price nearing structure',
|
|
202
|
-
'Zone proximity alert',
|
|
203
|
-
'Testing liquidity zone',
|
|
204
|
-
'Approaching pivot',
|
|
205
|
-
'Near high-volume node',
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
const ZONE_CONFIRMED_MESSAGES = [
|
|
209
|
-
'Zone confirmation',
|
|
210
|
-
'Level validated',
|
|
211
|
-
'Support/resistance active',
|
|
212
|
-
'Zone reaction detected',
|
|
213
|
-
'Level holding',
|
|
214
|
-
'Structure confirmed',
|
|
215
|
-
'Zone defense active',
|
|
216
|
-
'Level response detected',
|
|
217
|
-
'Pivot confirmed',
|
|
218
|
-
'Volume node reaction',
|
|
219
|
-
];
|
|
220
|
-
|
|
221
|
-
// =============================================================================
|
|
222
|
-
// MESSAGE POOLS - Volatility
|
|
223
|
-
// =============================================================================
|
|
224
|
-
|
|
225
|
-
const HIGH_VOLATILITY_MESSAGES = [
|
|
226
|
-
'Volatility elevated',
|
|
227
|
-
'High ATR detected',
|
|
228
|
-
'Increased price range',
|
|
229
|
-
'Market volatile',
|
|
230
|
-
'Wide swings detected',
|
|
231
|
-
'Volatility expansion',
|
|
232
|
-
'Range expanding',
|
|
233
|
-
'High activity zone',
|
|
234
|
-
'Momentum surge',
|
|
235
|
-
'Breakout conditions',
|
|
236
|
-
];
|
|
237
|
-
|
|
238
|
-
const LOW_VOLATILITY_MESSAGES = [
|
|
239
|
-
'Low volatility',
|
|
240
|
-
'Tight range detected',
|
|
241
|
-
'Compressed price action',
|
|
242
|
-
'Market quiet',
|
|
243
|
-
'Narrow swings',
|
|
244
|
-
'Volatility contraction',
|
|
245
|
-
'Range compressing',
|
|
246
|
-
'Low activity zone',
|
|
247
|
-
'Momentum cooling',
|
|
248
|
-
'Consolidation forming',
|
|
249
|
-
];
|
|
250
|
-
|
|
251
|
-
// =============================================================================
|
|
252
|
-
// MESSAGE POOLS - Risk Management
|
|
253
|
-
// =============================================================================
|
|
254
|
-
|
|
255
|
-
const RISK_PASSED_MESSAGES = [
|
|
256
|
-
'Risk check passed',
|
|
257
|
-
'Trade approved',
|
|
258
|
-
'Within risk limits',
|
|
259
|
-
'Risk validated',
|
|
260
|
-
'Clear to trade',
|
|
261
|
-
'Risk parameters met',
|
|
262
|
-
'Position size approved',
|
|
263
|
-
'Risk budget OK',
|
|
264
|
-
'Trade authorized',
|
|
265
|
-
'Risk constraints satisfied',
|
|
266
|
-
];
|
|
267
|
-
|
|
268
|
-
const RISK_BLOCKED_MESSAGES = [
|
|
269
|
-
'Risk limit reached',
|
|
270
|
-
'Trade blocked',
|
|
271
|
-
'Exceeds risk threshold',
|
|
272
|
-
'Risk rejected',
|
|
273
|
-
'Waiting for conditions',
|
|
274
|
-
'Risk parameters exceeded',
|
|
275
|
-
'Position size rejected',
|
|
276
|
-
'Risk budget depleted',
|
|
277
|
-
'Trade denied',
|
|
278
|
-
'Risk constraints violated',
|
|
279
|
-
];
|
|
280
|
-
|
|
281
|
-
// =============================================================================
|
|
282
|
-
// MESSAGE POOLS - Status
|
|
283
|
-
// =============================================================================
|
|
284
|
-
|
|
285
|
-
const SCANNING_MESSAGES = [
|
|
286
|
-
'Scanning market...',
|
|
287
|
-
'Analyzing flow...',
|
|
288
|
-
'Monitoring structure...',
|
|
289
|
-
'Watching for setups...',
|
|
290
|
-
'Evaluating conditions...',
|
|
291
|
-
'Processing market data...',
|
|
292
|
-
'Analyzing order book...',
|
|
293
|
-
'Monitoring tape...',
|
|
294
|
-
'Scanning for alpha...',
|
|
295
|
-
'Evaluating price action...',
|
|
296
|
-
'Analyzing microstructure...',
|
|
297
|
-
'Monitoring imbalances...',
|
|
298
|
-
'Scanning liquidity zones...',
|
|
299
|
-
'Evaluating momentum...',
|
|
300
|
-
'Analyzing market regime...',
|
|
301
|
-
];
|
|
302
|
-
|
|
303
|
-
const WAITING_MESSAGES = [
|
|
304
|
-
'Waiting for confirmation...',
|
|
305
|
-
'Pending trigger...',
|
|
306
|
-
'Standby mode...',
|
|
307
|
-
'Awaiting signal...',
|
|
308
|
-
'Ready to act...',
|
|
309
|
-
'Monitoring for entry...',
|
|
310
|
-
'Waiting for setup...',
|
|
311
|
-
'Confirmation pending...',
|
|
312
|
-
'Entry conditions not met...',
|
|
313
|
-
'Awaiting confluence...',
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
// =============================================================================
|
|
317
|
-
// MESSAGE POOLS - Data Flow
|
|
318
|
-
// =============================================================================
|
|
319
|
-
|
|
320
|
-
const TICK_FLOW_MESSAGES = [
|
|
321
|
-
'Processing tick data',
|
|
322
|
-
'Market data flowing',
|
|
323
|
-
'Live feed active',
|
|
324
|
-
'Tick stream healthy',
|
|
325
|
-
'Data streaming',
|
|
326
|
-
'Feed connection stable',
|
|
327
|
-
'Real-time data active',
|
|
328
|
-
'Tick processing nominal',
|
|
329
|
-
'Data pipeline healthy',
|
|
330
|
-
'Market feed online',
|
|
331
|
-
'Tick ingestion active',
|
|
332
|
-
'Data flow nominal',
|
|
333
|
-
'Stream latency optimal',
|
|
334
|
-
'Feed quality excellent',
|
|
335
|
-
'Data throughput normal',
|
|
336
|
-
];
|
|
337
|
-
|
|
338
|
-
const BUILDING_BARS_MESSAGES = [
|
|
339
|
-
'Building price bars',
|
|
340
|
-
'Aggregating ticks',
|
|
341
|
-
'Forming candles',
|
|
342
|
-
'Bar construction',
|
|
343
|
-
'Chart building',
|
|
344
|
-
'OHLC aggregation',
|
|
345
|
-
'Bar formation active',
|
|
346
|
-
'Candle building',
|
|
347
|
-
'Time bar processing',
|
|
348
|
-
'Bar data updating',
|
|
349
|
-
];
|
|
350
|
-
|
|
351
|
-
const MODEL_ANALYSIS_MESSAGES = [
|
|
352
|
-
'Running models',
|
|
353
|
-
'Analyzing patterns',
|
|
354
|
-
'Computing signals',
|
|
355
|
-
'Model evaluation',
|
|
356
|
-
'Strategy analysis',
|
|
357
|
-
'ML inference active',
|
|
358
|
-
'Pattern recognition',
|
|
359
|
-
'Signal computation',
|
|
360
|
-
'Model processing',
|
|
361
|
-
'Algorithm evaluation',
|
|
362
|
-
'Quantitative analysis',
|
|
363
|
-
'Statistical modeling',
|
|
364
|
-
'Feature extraction',
|
|
365
|
-
'Predictive analysis',
|
|
366
|
-
'Model optimization',
|
|
367
|
-
];
|
|
368
|
-
|
|
369
63
|
// =============================================================================
|
|
370
64
|
// SMART LOG GENERATORS
|
|
371
65
|
// =============================================================================
|
|
@@ -219,10 +219,14 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
219
219
|
let sellVolume = 0;
|
|
220
220
|
let barCount = 0;
|
|
221
221
|
|
|
222
|
+
// Track tick arrival times for latency estimation
|
|
223
|
+
let lastTickTime = 0;
|
|
224
|
+
let tickLatencies = [];
|
|
225
|
+
|
|
222
226
|
marketFeed.on('tick', (tick) => {
|
|
223
227
|
tickCount++;
|
|
224
|
-
const
|
|
225
|
-
const currentSecond = Math.floor(
|
|
228
|
+
const now = Date.now();
|
|
229
|
+
const currentSecond = Math.floor(now / 1000);
|
|
226
230
|
|
|
227
231
|
// Count ticks per second
|
|
228
232
|
if (currentSecond === lastTickSecond) {
|
|
@@ -288,17 +292,37 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
288
292
|
// Combined single line for zones info
|
|
289
293
|
ui.addLog('analysis', `Zones: ${state.activeZones} | R: ${resStr} | S: ${supStr} | Swings: ${state.swingsDetected}`);
|
|
290
294
|
|
|
295
|
+
// HF-grade proximity logs with precise distance info
|
|
296
|
+
if (price && state.nearestResistance) {
|
|
297
|
+
const gapR = state.nearestResistance - price;
|
|
298
|
+
const ticksR = Math.round(gapR / tickSize);
|
|
299
|
+
const dirR = gapR > 0 ? 'below' : 'above';
|
|
300
|
+
const absTicksR = Math.abs(ticksR);
|
|
301
|
+
if (absTicksR <= 50) { // Only show if within 50 ticks
|
|
302
|
+
ui.addLog('analysis', `PROX R: ${Math.abs(gapR).toFixed(2)} pts (${absTicksR} ticks ${dirR}) | Trigger: price must sweep ABOVE then reject`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (price && state.nearestSupport) {
|
|
306
|
+
const gapS = price - state.nearestSupport;
|
|
307
|
+
const ticksS = Math.round(gapS / tickSize);
|
|
308
|
+
const dirS = gapS > 0 ? 'above' : 'below';
|
|
309
|
+
const absTicksS = Math.abs(ticksS);
|
|
310
|
+
if (absTicksS <= 50) { // Only show if within 50 ticks
|
|
311
|
+
ui.addLog('analysis', `PROX S: ${Math.abs(gapS).toFixed(2)} pts (${absTicksS} ticks ${dirS}) | Trigger: price must sweep BELOW then reject`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
291
315
|
// Strategy status - what we're waiting for
|
|
292
316
|
if (state.activeZones === 0) {
|
|
293
|
-
ui.addLog('risk', '
|
|
317
|
+
ui.addLog('risk', 'Building liquidity map - scanning swing points for zone formation...');
|
|
294
318
|
} else if (!state.nearestSupport && !state.nearestResistance) {
|
|
295
|
-
ui.addLog('risk', 'Zones detected but
|
|
319
|
+
ui.addLog('risk', 'Zones detected but outside proximity range - waiting for price approach');
|
|
296
320
|
} else if (!state.nearestSupport) {
|
|
297
|
-
ui.addLog('analysis', '
|
|
321
|
+
ui.addLog('analysis', 'Monitoring resistance for HIGH SWEEP opportunity (SHORT entry on rejection)');
|
|
298
322
|
} else if (!state.nearestResistance) {
|
|
299
|
-
ui.addLog('analysis', '
|
|
323
|
+
ui.addLog('analysis', 'Monitoring support for LOW SWEEP opportunity (LONG entry on rejection)');
|
|
300
324
|
} else {
|
|
301
|
-
ui.addLog('ready', 'Both zones active - monitoring for liquidity sweep');
|
|
325
|
+
ui.addLog('ready', 'Both zones active - monitoring for liquidity sweep with rejection confirmation');
|
|
302
326
|
}
|
|
303
327
|
}
|
|
304
328
|
}
|
|
@@ -340,16 +364,30 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
340
364
|
timestamp: tick.timestamp || Date.now()
|
|
341
365
|
});
|
|
342
366
|
|
|
343
|
-
// Calculate
|
|
367
|
+
// Calculate latency based on tick timestamp or inter-tick timing
|
|
344
368
|
if (tick.timestamp) {
|
|
345
369
|
const tickTime = typeof tick.timestamp === 'number' ? tick.timestamp : Date.parse(tick.timestamp);
|
|
346
|
-
if (!isNaN(tickTime)) {
|
|
347
|
-
stats.latency = Math.max(0,
|
|
370
|
+
if (!isNaN(tickTime) && tickTime > 1000000000000) { // Valid millisecond timestamp
|
|
371
|
+
stats.latency = Math.max(0, now - tickTime);
|
|
348
372
|
}
|
|
373
|
+
} else if (tick.ssboe && tick.usecs) {
|
|
374
|
+
// Rithmic sends ssboe (seconds since epoch) and usecs (microseconds)
|
|
375
|
+
const tickTimeMs = tick.ssboe * 1000 + Math.floor(tick.usecs / 1000);
|
|
376
|
+
stats.latency = Math.max(0, now - tickTimeMs);
|
|
349
377
|
} else {
|
|
350
|
-
//
|
|
351
|
-
|
|
378
|
+
// Estimate latency from tick frequency - if we're getting real-time data, latency should be low
|
|
379
|
+
if (lastTickTime > 0) {
|
|
380
|
+
const timeSinceLastTick = now - lastTickTime;
|
|
381
|
+
// If ticks are coming frequently, latency is low
|
|
382
|
+
if (timeSinceLastTick < 100) {
|
|
383
|
+
tickLatencies.push(timeSinceLastTick);
|
|
384
|
+
if (tickLatencies.length > 20) tickLatencies.shift();
|
|
385
|
+
// Average of recent inter-tick times as proxy for latency
|
|
386
|
+
stats.latency = Math.round(tickLatencies.reduce((a, b) => a + b, 0) / tickLatencies.length);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
352
389
|
}
|
|
390
|
+
lastTickTime = now;
|
|
353
391
|
});
|
|
354
392
|
|
|
355
393
|
marketFeed.on('connected', () => {
|
|
@@ -419,31 +457,20 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
419
457
|
const pnlInterval = setInterval(() => { if (running) pollPnL(); }, 2000);
|
|
420
458
|
pollPnL();
|
|
421
459
|
|
|
422
|
-
// Keyboard handler
|
|
460
|
+
// Keyboard handler for exit (X or Ctrl+C)
|
|
423
461
|
const setupKeyHandler = () => {
|
|
424
462
|
if (!process.stdin.isTTY) return;
|
|
425
463
|
readline.emitKeypressEvents(process.stdin);
|
|
426
464
|
process.stdin.setRawMode(true);
|
|
427
465
|
process.stdin.resume();
|
|
428
|
-
|
|
429
|
-
const onKey = (str, key) => {
|
|
430
|
-
if (key && (key.name === 'x' || key.name === 'X' || (key.ctrl && key.name === 'c'))) {
|
|
431
|
-
running = false; stopReason = 'manual';
|
|
432
|
-
}
|
|
433
|
-
};
|
|
466
|
+
const onKey = (str, key) => { if (key && (key.name === 'x' || key.name === 'X' || (key.ctrl && key.name === 'c'))) { running = false; stopReason = 'manual'; } };
|
|
434
467
|
process.stdin.on('keypress', onKey);
|
|
435
|
-
return () => {
|
|
436
|
-
process.stdin.removeListener('keypress', onKey);
|
|
437
|
-
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
438
|
-
};
|
|
468
|
+
return () => { process.stdin.removeListener('keypress', onKey); if (process.stdin.isTTY) process.stdin.setRawMode(false); };
|
|
439
469
|
};
|
|
440
|
-
|
|
441
470
|
const cleanupKeys = setupKeyHandler();
|
|
442
471
|
|
|
443
|
-
// Wait for stop
|
|
444
|
-
await new Promise(resolve => {
|
|
445
|
-
const check = setInterval(() => { if (!running) { clearInterval(check); resolve(); } }, 100);
|
|
446
|
-
});
|
|
472
|
+
// Wait for stop signal
|
|
473
|
+
await new Promise(resolve => { const check = setInterval(() => { if (!running) { clearInterval(check); resolve(); } }, 100); });
|
|
447
474
|
|
|
448
475
|
// Cleanup
|
|
449
476
|
clearInterval(refreshInterval);
|
|
@@ -451,19 +478,14 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
451
478
|
await marketFeed.disconnect();
|
|
452
479
|
if (cleanupKeys) cleanupKeys();
|
|
453
480
|
ui.cleanup();
|
|
454
|
-
|
|
455
481
|
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
456
482
|
process.stdin.resume();
|
|
457
483
|
|
|
458
|
-
// Duration
|
|
484
|
+
// Duration and summary
|
|
459
485
|
const durationMs = Date.now() - stats.startTime;
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
const seconds = Math.floor((durationMs % 60000) / 1000);
|
|
463
|
-
stats.duration = hours > 0 ? `${hours}h ${minutes}m ${seconds}s` : minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
464
|
-
|
|
486
|
+
const h = Math.floor(durationMs / 3600000), m = Math.floor((durationMs % 3600000) / 60000), s = Math.floor((durationMs % 60000) / 1000);
|
|
487
|
+
stats.duration = h > 0 ? `${h}h ${m}m ${s}s` : m > 0 ? `${m}m ${s}s` : `${s}s`;
|
|
465
488
|
renderSessionSummary(stats, stopReason);
|
|
466
|
-
|
|
467
489
|
console.log('\n Returning to menu in 3 seconds...');
|
|
468
490
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
469
491
|
};
|