hedgequantx 2.6.29 → 2.6.30
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
CHANGED
|
@@ -76,9 +76,9 @@ class HFTTickStrategy extends EventEmitter {
|
|
|
76
76
|
constructor() {
|
|
77
77
|
super();
|
|
78
78
|
|
|
79
|
-
// Configuration
|
|
80
|
-
this.tickSize =
|
|
81
|
-
this.tickValue =
|
|
79
|
+
// Configuration - MUST be set via initialize() with API data
|
|
80
|
+
this.tickSize = null;
|
|
81
|
+
this.tickValue = null;
|
|
82
82
|
this.contractId = null;
|
|
83
83
|
this.initialized = false;
|
|
84
84
|
|
|
@@ -94,42 +94,55 @@ class HFTTickStrategy extends EventEmitter {
|
|
|
94
94
|
this.lastBid = 0;
|
|
95
95
|
this.lastAsk = 0;
|
|
96
96
|
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
97
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
98
|
+
// STRATEGY CONFIGURATION PARAMETERS
|
|
99
|
+
// These are algorithm tuning parameters, NOT trading data
|
|
100
|
+
// They define HOW the strategy calculates signals from real tick data
|
|
101
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
102
|
+
|
|
103
|
+
// OFI calculation windows (algorithm config)
|
|
104
|
+
this.ofiWindow = 50; // Number of ticks for OFI calculation
|
|
105
|
+
this.ofiValue = 0; // Calculated from real ticks
|
|
106
|
+
|
|
107
|
+
// Momentum windows (algorithm config)
|
|
108
|
+
this.momentumWindow = 20; // Number of ticks for momentum
|
|
109
|
+
this.momentum = 0; // Calculated from real tick prices
|
|
110
|
+
this.acceleration = 0; // Calculated from real tick prices
|
|
111
|
+
|
|
112
|
+
// Mean reversion windows (algorithm config)
|
|
113
|
+
this.zscoreWindow = 100; // Number of ticks for z-score
|
|
114
|
+
this.zscore = 0; // Calculated from real tick prices
|
|
115
|
+
this.mean = 0; // Calculated from real tick prices
|
|
116
|
+
this.std = 0; // Calculated from real tick prices
|
|
117
|
+
|
|
118
|
+
// Signal thresholds (algorithm tuning - from backtests)
|
|
119
|
+
this.ofiThreshold = 0.3; // |OFI| threshold for signal generation
|
|
120
|
+
this.zscoreThreshold = 1.5; // |Z| threshold for mean reversion
|
|
121
|
+
this.momentumThreshold = 0.5; // Momentum threshold for confirmation
|
|
122
|
+
this.minConfidence = 0.6; // Minimum composite score for signal
|
|
123
|
+
|
|
124
|
+
// Risk parameters in ticks (algorithm config)
|
|
125
|
+
this.baseStopTicks = 8; // Base stop distance in ticks
|
|
126
|
+
this.baseTargetTicks = 12; // Base target distance in ticks
|
|
127
|
+
|
|
128
|
+
// State tracking
|
|
129
|
+
this.tickCount = 0; // Counter from real ticks received
|
|
130
|
+
this.signalCount = 0; // Counter of signals generated
|
|
131
|
+
this.lastSignalTime = 0; // Timestamp of last signal
|
|
132
|
+
this.cooldownMs = 5000; // Cooldown between signals (ms)
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
/**
|
|
130
136
|
* Initialize strategy for a contract
|
|
137
|
+
* @param {string} contractId - Contract identifier from API
|
|
138
|
+
* @param {number} tickSize - Tick size from API (REQUIRED - no default)
|
|
139
|
+
* @param {number} tickValue - Tick value from API (REQUIRED - no default)
|
|
131
140
|
*/
|
|
132
|
-
initialize(contractId, tickSize
|
|
141
|
+
initialize(contractId, tickSize, tickValue) {
|
|
142
|
+
if (!contractId || tickSize === undefined || tickValue === undefined) {
|
|
143
|
+
throw new Error('HFT Strategy requires contractId, tickSize, and tickValue from API');
|
|
144
|
+
}
|
|
145
|
+
|
|
133
146
|
this.contractId = contractId;
|
|
134
147
|
this.tickSize = tickSize;
|
|
135
148
|
this.tickValue = tickValue;
|