hedgequantx 2.9.167 → 2.9.169
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
|
@@ -85,17 +85,23 @@ const fetchAllFrontMonths = (service) => {
|
|
|
85
85
|
|
|
86
86
|
const tickerState = service.tickerConn.connectionState;
|
|
87
87
|
const tickerConnected = service.tickerConn.isConnected;
|
|
88
|
-
|
|
88
|
+
|
|
89
|
+
// Direct console.log for daemon broker.log (always visible)
|
|
90
|
+
const brokerLog = (msg, data) => console.log(`[CONTRACTS] ${msg}`, JSON.stringify(data));
|
|
91
|
+
|
|
92
|
+
brokerLog('fetchAllFrontMonths starting', { tickerState, tickerConnected });
|
|
89
93
|
|
|
90
94
|
return new Promise((resolve) => {
|
|
91
95
|
const contracts = new Map();
|
|
92
96
|
const productsToCheck = new Map();
|
|
93
97
|
let msgCount = 0;
|
|
98
|
+
let productMsgCount = 0;
|
|
94
99
|
|
|
95
100
|
// Handler for ProductCodes responses
|
|
96
101
|
const productHandler = (msg) => {
|
|
97
102
|
msgCount++;
|
|
98
103
|
if (msg.templateId !== 112) return;
|
|
104
|
+
productMsgCount++;
|
|
99
105
|
|
|
100
106
|
const decoded = decodeProductCodes(msg.data);
|
|
101
107
|
if (!decoded.productCode || !decoded.exchange) return;
|
|
@@ -117,11 +123,27 @@ const fetchAllFrontMonths = (service) => {
|
|
|
117
123
|
};
|
|
118
124
|
|
|
119
125
|
// Handler for FrontMonth responses
|
|
126
|
+
let frontMonthMsgCount = 0;
|
|
127
|
+
let template114Count = 0;
|
|
120
128
|
const frontMonthHandler = (msg) => {
|
|
121
129
|
msgCount++;
|
|
130
|
+
frontMonthMsgCount++;
|
|
122
131
|
if (msg.templateId !== 114) return;
|
|
132
|
+
template114Count++;
|
|
123
133
|
|
|
124
134
|
const decoded = decodeFrontMonthContract(msg.data);
|
|
135
|
+
|
|
136
|
+
// Log first few responses to diagnose
|
|
137
|
+
if (template114Count <= 5) {
|
|
138
|
+
brokerLog('FrontMonth response', {
|
|
139
|
+
template114Count,
|
|
140
|
+
rpCode: decoded.rpCode,
|
|
141
|
+
tradingSymbol: decoded.tradingSymbol,
|
|
142
|
+
userMsg: decoded.userMsg,
|
|
143
|
+
exchange: decoded.exchange
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
125
147
|
if (decoded.rpCode[0] === '0' && decoded.tradingSymbol) {
|
|
126
148
|
contracts.set(decoded.userMsg, {
|
|
127
149
|
symbol: decoded.tradingSymbol,
|
|
@@ -135,25 +157,31 @@ const fetchAllFrontMonths = (service) => {
|
|
|
135
157
|
service.tickerConn.on('message', frontMonthHandler);
|
|
136
158
|
|
|
137
159
|
// Request all product codes
|
|
138
|
-
|
|
160
|
+
brokerLog('Sending RequestProductCodes', { templateId: 111 });
|
|
139
161
|
try {
|
|
140
162
|
service.tickerConn.send('RequestProductCodes', {
|
|
141
163
|
templateId: 111,
|
|
142
164
|
userMsg: ['get-products'],
|
|
143
165
|
});
|
|
166
|
+
brokerLog('RequestProductCodes sent OK', {});
|
|
144
167
|
} catch (err) {
|
|
145
|
-
|
|
168
|
+
brokerLog('FAILED to send RequestProductCodes', { error: err.message });
|
|
146
169
|
}
|
|
147
170
|
|
|
148
171
|
// After timeout, request front months
|
|
149
172
|
setTimeout(() => {
|
|
150
173
|
service.tickerConn.removeListener('message', productHandler);
|
|
151
|
-
|
|
174
|
+
brokerLog('ProductCodes phase complete', {
|
|
175
|
+
productsFound: productsToCheck.size,
|
|
176
|
+
totalMsgs: msgCount,
|
|
177
|
+
productMsgs: productMsgCount
|
|
178
|
+
});
|
|
152
179
|
|
|
153
180
|
if (productsToCheck.size === 0) {
|
|
154
|
-
|
|
181
|
+
brokerLog('WARNING: No products collected - TICKER may not be responding', {});
|
|
155
182
|
}
|
|
156
183
|
|
|
184
|
+
let sentCount = 0;
|
|
157
185
|
for (const product of productsToCheck.values()) {
|
|
158
186
|
try {
|
|
159
187
|
service.tickerConn.send('RequestFrontMonthContract', {
|
|
@@ -162,10 +190,12 @@ const fetchAllFrontMonths = (service) => {
|
|
|
162
190
|
symbol: product.productCode,
|
|
163
191
|
exchange: product.exchange,
|
|
164
192
|
});
|
|
193
|
+
sentCount++;
|
|
165
194
|
} catch (err) {
|
|
166
|
-
|
|
195
|
+
brokerLog('Failed to send RequestFrontMonthContract', { product: product.productCode, error: err.message });
|
|
167
196
|
}
|
|
168
197
|
}
|
|
198
|
+
brokerLog('RequestFrontMonthContract sent', { sentCount, totalProducts: productsToCheck.size });
|
|
169
199
|
|
|
170
200
|
// Collect results after timeout
|
|
171
201
|
setTimeout(() => {
|
|
@@ -191,7 +221,12 @@ const fetchAllFrontMonths = (service) => {
|
|
|
191
221
|
// Sort alphabetically by base symbol
|
|
192
222
|
results.sort((a, b) => a.baseSymbol.localeCompare(b.baseSymbol));
|
|
193
223
|
|
|
194
|
-
|
|
224
|
+
brokerLog('FrontMonth phase complete', {
|
|
225
|
+
contractsFound: results.length,
|
|
226
|
+
totalMsgs: msgCount,
|
|
227
|
+
frontMonthMsgs: frontMonthMsgCount,
|
|
228
|
+
template114Received: template114Count
|
|
229
|
+
});
|
|
195
230
|
resolve(results);
|
|
196
231
|
}, TIMEOUTS.RITHMIC_PRODUCTS);
|
|
197
232
|
}, TIMEOUTS.RITHMIC_CONTRACTS);
|