hedgequantx 2.9.232 → 2.9.233
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-engine.js +76 -44
package/package.json
CHANGED
|
@@ -15,22 +15,44 @@
|
|
|
15
15
|
|
|
16
16
|
const chalk = require('chalk');
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// Rich color helpers for professional HF display
|
|
19
19
|
const C = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
// Symbol - bright cyan
|
|
21
|
+
sym: (s) => chalk.hex('#00FFFF').bold(s),
|
|
22
|
+
|
|
23
|
+
// Price - bright white/yellow
|
|
24
|
+
price: (p) => chalk.hex('#FFFFFF').bold(p),
|
|
25
|
+
priceUp: (p) => chalk.hex('#00FF00').bold(p),
|
|
26
|
+
priceDown: (p) => chalk.hex('#FF4444').bold(p),
|
|
27
|
+
|
|
28
|
+
// Direction
|
|
29
|
+
long: (s) => chalk.hex('#00FF00').bold(s),
|
|
30
|
+
short: (s) => chalk.hex('#FF4444').bold(s),
|
|
31
|
+
bull: (s) => chalk.hex('#00DD00')(s),
|
|
32
|
+
bear: (s) => chalk.hex('#FF6666')(s),
|
|
33
|
+
|
|
34
|
+
// Values & metrics
|
|
35
|
+
val: (v) => chalk.hex('#00BFFF')(v), // Deep sky blue
|
|
36
|
+
valHigh: (v) => chalk.hex('#FF00FF').bold(v), // Magenta for extreme
|
|
37
|
+
zscore: (v) => chalk.hex('#FFD700')(v), // Gold for Z-score
|
|
38
|
+
|
|
39
|
+
// Status indicators
|
|
40
|
+
ok: (s) => chalk.hex('#00FF00')(s),
|
|
41
|
+
warn: (s) => chalk.hex('#FFA500').bold(s), // Orange warning
|
|
42
|
+
danger: (s) => chalk.hex('#FF0000').bold(s), // Red danger
|
|
43
|
+
|
|
44
|
+
// Neutral/info
|
|
45
|
+
dim: (s) => chalk.hex('#888888')(s),
|
|
46
|
+
info: (s) => chalk.hex('#AAAAAA')(s),
|
|
47
|
+
muted: (s) => chalk.hex('#666666')(s),
|
|
48
|
+
|
|
49
|
+
// Special states
|
|
50
|
+
signal: (s) => chalk.hex('#FFFF00').bold(s), // Bright yellow signal
|
|
51
|
+
toxic: (s) => chalk.hex('#FF0000').bgHex('#330000').bold(s),
|
|
52
|
+
|
|
53
|
+
// Labels
|
|
54
|
+
label: (s) => chalk.hex('#888888')(s),
|
|
55
|
+
separator: () => chalk.hex('#444444')('|'),
|
|
34
56
|
};
|
|
35
57
|
|
|
36
58
|
const CONFIG = {
|
|
@@ -86,8 +108,9 @@ class SmartLogsEngine {
|
|
|
86
108
|
const priceNum = state.price || 0;
|
|
87
109
|
const lastPrice = this._lastPrice || priceNum;
|
|
88
110
|
const priceDiff = priceNum - lastPrice;
|
|
89
|
-
const priceDir = priceDiff > 0.01 ? '▲' : priceDiff < -0.01 ? '▼' : '
|
|
90
|
-
const priceDirColor = priceDiff > 0 ? C.bull : priceDiff < 0 ? C.bear : C.
|
|
111
|
+
const priceDir = priceDiff > 0.01 ? '▲' : priceDiff < -0.01 ? '▼' : '─';
|
|
112
|
+
const priceDirColor = priceDiff > 0 ? C.bull : priceDiff < 0 ? C.bear : C.muted;
|
|
113
|
+
const priceDisplay = priceDiff > 0 ? C.priceUp(price) : priceDiff < 0 ? C.priceDown(price) : C.price(price);
|
|
91
114
|
this._lastPrice = priceNum;
|
|
92
115
|
|
|
93
116
|
// Track tick velocity
|
|
@@ -100,9 +123,10 @@ class SmartLogsEngine {
|
|
|
100
123
|
if (dataPoints < 50 || !price) {
|
|
101
124
|
const pct = Math.min(100, Math.round((dataPoints / 50) * 100));
|
|
102
125
|
const remaining = 50 - dataPoints;
|
|
126
|
+
const pctColor = pct < 50 ? C.warn : C.ok;
|
|
103
127
|
return {
|
|
104
128
|
type: 'system',
|
|
105
|
-
message: `[${C.sym(sym)}] ${price ? C.price(price) : '-.--'}
|
|
129
|
+
message: `[${C.sym(sym)}] ${price ? C.price(price) : C.dim('-.--')} ${C.separator()} ${C.label('Calibrating')} ${pctColor(pct + '%')} ${C.separator()} ${C.val(remaining)} ${C.label('samples to ready')} ${C.separator()} ${C.dim('+' + tickVelocity + '/s')}`,
|
|
106
130
|
logToSession: false
|
|
107
131
|
};
|
|
108
132
|
}
|
|
@@ -114,38 +138,46 @@ class SmartLogsEngine {
|
|
|
114
138
|
const buyPctRound = Math.round(buyPct || 50);
|
|
115
139
|
const deltaRound = Math.round(delta || 0);
|
|
116
140
|
|
|
117
|
-
// Z-Score color based on level
|
|
141
|
+
// Z-Score color based on level - more vivid
|
|
118
142
|
const zColor = absZ >= CONFIG.Z_EXTREME ? C.valHigh :
|
|
119
|
-
absZ >= CONFIG.Z_HIGH ? C.
|
|
120
|
-
absZ >= CONFIG.Z_BUILDING ? C.
|
|
143
|
+
absZ >= CONFIG.Z_HIGH ? C.signal :
|
|
144
|
+
absZ >= CONFIG.Z_BUILDING ? C.zscore : C.muted;
|
|
121
145
|
const zStr = zColor(`${zScore.toFixed(2)}σ`);
|
|
122
146
|
|
|
123
|
-
// OFI color based on direction
|
|
124
|
-
const ofiColor = ofi > CONFIG.
|
|
125
|
-
ofi
|
|
147
|
+
// OFI color based on direction - more vivid
|
|
148
|
+
const ofiColor = ofi > CONFIG.OFI_STRONG ? C.long :
|
|
149
|
+
ofi > CONFIG.OFI_THRESHOLD ? C.bull :
|
|
150
|
+
ofi < -CONFIG.OFI_STRONG ? C.short :
|
|
151
|
+
ofi < -CONFIG.OFI_THRESHOLD ? C.bear : C.muted;
|
|
126
152
|
const ofiStr = ofiColor(`${ofi >= 0 ? '+' : ''}${ofiPct}%`);
|
|
127
153
|
|
|
128
|
-
// VPIN color based on toxicity
|
|
129
|
-
const vpinColor = vpin > CONFIG.VPIN_TOXIC ? C.
|
|
154
|
+
// VPIN color based on toxicity - more vivid
|
|
155
|
+
const vpinColor = vpin > CONFIG.VPIN_TOXIC ? C.toxic :
|
|
130
156
|
vpin > CONFIG.VPIN_ELEVATED ? C.warn : C.ok;
|
|
131
157
|
const vpinStr = vpinColor(`${vpinPct}%`);
|
|
132
158
|
|
|
133
|
-
// Delta (buy-sell imbalance) display
|
|
134
|
-
const
|
|
159
|
+
// Delta (buy-sell imbalance) display - more vivid
|
|
160
|
+
const deltaAbs = Math.abs(deltaRound);
|
|
161
|
+
const deltaColor = deltaRound > 50 ? C.long : deltaRound > 0 ? C.bull :
|
|
162
|
+
deltaRound < -50 ? C.short : deltaRound < 0 ? C.bear : C.muted;
|
|
135
163
|
const deltaStr = deltaColor(`${deltaRound > 0 ? '+' : ''}${deltaRound}`);
|
|
136
164
|
|
|
165
|
+
// Buy percentage color
|
|
166
|
+
const buyColor = buyPctRound > 60 ? C.bull : buyPctRound < 40 ? C.bear : C.muted;
|
|
167
|
+
const buyStr = buyColor(`${buyPctRound}%`);
|
|
168
|
+
|
|
137
169
|
// Active position - show position management with unique data
|
|
138
170
|
if (position !== 0) {
|
|
139
171
|
const isLong = position > 0;
|
|
140
|
-
const side = isLong ? C.long('LONG') : C.short('SHORT');
|
|
172
|
+
const side = isLong ? C.long('● LONG') : C.short('● SHORT');
|
|
141
173
|
const flowFavor = (isLong && ofi > 0) || (!isLong && ofi < 0);
|
|
142
|
-
const flowLabel = flowFavor ? C.ok('aligned') : C.warn('adverse');
|
|
174
|
+
const flowLabel = flowFavor ? C.ok('✓ aligned') : C.warn('⚠ adverse');
|
|
143
175
|
const exitClose = absZ < 0.5;
|
|
144
|
-
const exitInfo = exitClose ? C.warn('EXIT ZONE') : 'holding';
|
|
176
|
+
const exitInfo = exitClose ? C.warn('⚡ EXIT ZONE') : C.ok('holding');
|
|
145
177
|
|
|
146
178
|
return {
|
|
147
179
|
type: 'trade',
|
|
148
|
-
message: `[${C.sym(sym)}] ${side} ${priceDirColor(priceDir)} ${C.
|
|
180
|
+
message: `[${C.sym(sym)}] ${side} ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${exitInfo} ${C.separator()} ${C.label('Δ:')}${deltaStr} ${C.separator()} ${flowLabel}`,
|
|
149
181
|
logToSession: false
|
|
150
182
|
};
|
|
151
183
|
}
|
|
@@ -159,31 +191,31 @@ class SmartLogsEngine {
|
|
|
159
191
|
|
|
160
192
|
// VPIN toxic - highest priority blocker
|
|
161
193
|
if (vpin > CONFIG.VPIN_TOXIC) {
|
|
162
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
194
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('VPIN:')}${vpinStr} ${C.toxic('☠ TOXIC')} ${C.separator()} ${C.label('Z:')}${zStr} ${C.separator()} ${C.label('Δ:')}${deltaStr} ${C.separator()} ${C.danger('NO ENTRY')}`;
|
|
163
195
|
logType = 'risk';
|
|
164
196
|
}
|
|
165
197
|
// Z-Score extreme + OFI confirms = SIGNAL
|
|
166
198
|
else if (absZ >= CONFIG.Z_EXTREME &&
|
|
167
199
|
((zScore < 0 && ofi > CONFIG.OFI_THRESHOLD) || (zScore > 0 && ofi < -CONFIG.OFI_THRESHOLD))) {
|
|
168
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
200
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${C.signal('★ EXTREME')} ${C.separator()} ${C.label('OFI:')}${ofiStr} ${C.ok('✓')} ${C.separator()} ${dirColor('► ' + direction + ' SIGNAL')}`;
|
|
169
201
|
logType = 'signal';
|
|
170
202
|
}
|
|
171
203
|
// Z-Score extreme but OFI doesn't confirm
|
|
172
204
|
else if (absZ >= CONFIG.Z_EXTREME) {
|
|
173
|
-
const ofiNeed = zScore < 0 ?
|
|
174
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
205
|
+
const ofiNeed = zScore < 0 ? C.dim('need >15%') : C.dim('need <-15%');
|
|
206
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${C.signal('!')} ${C.separator()} ${C.label('OFI:')}${ofiStr} ${ofiNeed} ${C.separator()} ${C.warn('◐ PENDING')}`;
|
|
175
207
|
logType = 'signal';
|
|
176
208
|
}
|
|
177
209
|
// Z-Score high - setup forming
|
|
178
210
|
else if (absZ >= CONFIG.Z_HIGH) {
|
|
179
211
|
const needed = (CONFIG.Z_EXTREME - absZ).toFixed(2);
|
|
180
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
212
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${C.val('+' + needed + 'σ')} ${C.label('to signal')} ${C.separator()} ${C.label('OFI:')}${ofiStr} ${C.separator()} ${C.label('Δ:')}${deltaStr}`;
|
|
181
213
|
}
|
|
182
214
|
// Z-Score building
|
|
183
215
|
else if (absZ >= CONFIG.Z_BUILDING) {
|
|
184
216
|
const needed = (CONFIG.Z_HIGH - absZ).toFixed(2);
|
|
185
|
-
const bias = zScore < 0 ? 'bid' : 'ask';
|
|
186
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
217
|
+
const bias = zScore < 0 ? C.bull('bid ↑') : C.bear('ask ↓');
|
|
218
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${bias} ${C.separator()} ${C.val('+' + needed + 'σ')} ${C.label('to setup')} ${C.separator()} ${C.label('Δ:')}${deltaStr}`;
|
|
187
219
|
}
|
|
188
220
|
// Z-Score neutral - scanning
|
|
189
221
|
else {
|
|
@@ -192,18 +224,18 @@ class SmartLogsEngine {
|
|
|
192
224
|
let context;
|
|
193
225
|
switch (infoType) {
|
|
194
226
|
case 0:
|
|
195
|
-
context =
|
|
227
|
+
context = `${C.label('Δ:')}${deltaStr} ${C.separator()} ${C.label('Buy:')}${buyStr}`;
|
|
196
228
|
break;
|
|
197
229
|
case 1:
|
|
198
|
-
context =
|
|
230
|
+
context = `${C.label('VPIN:')}${vpinStr} ${C.separator()} ${C.label('OFI:')}${ofiStr}`;
|
|
199
231
|
break;
|
|
200
232
|
case 2:
|
|
201
|
-
context = `${tickVelocity} ticks/s
|
|
233
|
+
context = `${C.val(tickVelocity)} ${C.label('ticks/s')} ${C.separator()} ${C.label('Δ:')}${deltaStr}`;
|
|
202
234
|
break;
|
|
203
235
|
default:
|
|
204
|
-
context =
|
|
236
|
+
context = `${C.label('OFI:')}${ofiStr} ${C.separator()} ${C.label('Buy:')}${buyStr}`;
|
|
205
237
|
}
|
|
206
|
-
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${C.
|
|
238
|
+
message = `[${C.sym(sym)}] ${priceDirColor(priceDir)} ${priceDisplay} ${C.separator()} ${C.label('Z:')}${zStr} ${C.muted('scanning')} ${C.separator()} ${context}`;
|
|
207
239
|
}
|
|
208
240
|
|
|
209
241
|
return { type: logType, message, logToSession: logType === 'signal' };
|