hedgequantx 2.9.178 → 2.9.180
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
|
@@ -28,8 +28,18 @@ const getContracts = async (service) => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
try {
|
|
31
|
-
// Connect to TICKER_PLANT if needed
|
|
32
|
-
|
|
31
|
+
// Connect to TICKER_PLANT if needed - check both existence AND logged in state
|
|
32
|
+
const tickerReady = service.tickerConn?.isConnected &&
|
|
33
|
+
service.tickerConn?.connectionState === 'LOGGED_IN';
|
|
34
|
+
|
|
35
|
+
if (!tickerReady) {
|
|
36
|
+
// Force fresh connection if ticker exists but not ready
|
|
37
|
+
if (service.tickerConn) {
|
|
38
|
+
log.debug('TICKER_PLANT exists but not ready, reconnecting', {
|
|
39
|
+
state: service.tickerConn.connectionState,
|
|
40
|
+
connected: service.tickerConn.isConnected
|
|
41
|
+
});
|
|
42
|
+
}
|
|
33
43
|
const connected = await service.connectTicker(service.credentials.username, service.credentials.password);
|
|
34
44
|
if (!connected) {
|
|
35
45
|
return { success: false, error: 'Failed to connect to TICKER_PLANT' };
|
|
@@ -178,7 +188,14 @@ const fetchAllFrontMonths = (service) => {
|
|
|
178
188
|
if (msg.templateId !== 114) return;
|
|
179
189
|
template114Count++;
|
|
180
190
|
|
|
181
|
-
|
|
191
|
+
// Use official protobuf decoder
|
|
192
|
+
let decoded;
|
|
193
|
+
try {
|
|
194
|
+
decoded = proto.decode('ResponseFrontMonthContract', msg.data);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
brokerLog('FrontMonth decode error', { error: e.message });
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
182
199
|
|
|
183
200
|
// Log first few responses to diagnose
|
|
184
201
|
if (template114Count <= 5) {
|
|
@@ -191,10 +208,11 @@ const fetchAllFrontMonths = (service) => {
|
|
|
191
208
|
});
|
|
192
209
|
}
|
|
193
210
|
|
|
194
|
-
if (decoded.rpCode[0] === '0' && decoded.tradingSymbol) {
|
|
195
|
-
|
|
211
|
+
if (decoded.rpCode && decoded.rpCode[0] === '0' && decoded.tradingSymbol) {
|
|
212
|
+
const baseSymbol = decoded.userMsg?.[0] || decoded.symbol;
|
|
213
|
+
contracts.set(baseSymbol, {
|
|
196
214
|
symbol: decoded.tradingSymbol,
|
|
197
|
-
baseSymbol:
|
|
215
|
+
baseSymbol: baseSymbol,
|
|
198
216
|
exchange: decoded.exchange,
|
|
199
217
|
});
|
|
200
218
|
}
|