hedgequantx 2.9.238 → 2.9.239
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/m/ultra-scalping.js +22 -21
- package/package.json +1 -1
|
@@ -158,40 +158,41 @@ class HQXUltraScalpingStrategy extends EventEmitter {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* Process a tick -
|
|
161
|
+
* Process a tick - TICK-BY-TICK processing (matches Python backtest)
|
|
162
|
+
* Each tick is treated as a single-tick "bar" for model calculations
|
|
162
163
|
*/
|
|
163
164
|
processTick(tick) {
|
|
164
165
|
const contractId = tick.contractId;
|
|
166
|
+
const price = tick.price;
|
|
167
|
+
const volume = tick.volume || 1;
|
|
168
|
+
const timestamp = tick.timestamp || Date.now();
|
|
165
169
|
|
|
166
170
|
if (!this.barHistory.has(contractId)) {
|
|
167
171
|
this.initialize(contractId);
|
|
168
172
|
}
|
|
169
|
-
|
|
170
|
-
// Add tick to buffer
|
|
171
|
-
let ticks = this.tickBuffer.get(contractId);
|
|
172
|
-
ticks.push(tick);
|
|
173
173
|
|
|
174
|
-
// Track total ticks and last price
|
|
174
|
+
// Track total ticks and last price
|
|
175
175
|
this._totalTicks = (this._totalTicks || 0) + 1;
|
|
176
|
-
this._lastPrice =
|
|
176
|
+
this._lastPrice = price;
|
|
177
177
|
this._currentContractId = contractId;
|
|
178
178
|
|
|
179
|
-
//
|
|
180
|
-
const
|
|
179
|
+
// Create single-tick bar (matches Python backtest behavior)
|
|
180
|
+
const bar = {
|
|
181
|
+
timestamp,
|
|
182
|
+
open: price,
|
|
183
|
+
high: price,
|
|
184
|
+
low: price,
|
|
185
|
+
close: price,
|
|
186
|
+
volume
|
|
187
|
+
};
|
|
181
188
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.
|
|
186
|
-
|
|
187
|
-
if (bar) {
|
|
188
|
-
const signal = this.processBar(contractId, bar);
|
|
189
|
-
if (signal) {
|
|
190
|
-
this.emit('signal', signal);
|
|
191
|
-
return signal;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
189
|
+
// Process bar and emit signal if generated
|
|
190
|
+
const signal = this.processBar(contractId, bar);
|
|
191
|
+
if (signal) {
|
|
192
|
+
this.emit('signal', signal);
|
|
193
|
+
return signal;
|
|
194
194
|
}
|
|
195
|
+
|
|
195
196
|
return null;
|
|
196
197
|
}
|
|
197
198
|
|