hedgequantx 2.6.34 → 2.6.35
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
|
@@ -117,11 +117,14 @@ class RithmicConnection extends EventEmitter {
|
|
|
117
117
|
* Fast send - bypasses some ws overhead for hot path
|
|
118
118
|
* Use for time-critical order messages
|
|
119
119
|
* @param {Buffer} buffer - Pre-encoded protobuf buffer
|
|
120
|
+
* @returns {boolean} true if sent, false if connection not open
|
|
120
121
|
*/
|
|
121
122
|
fastSend(buffer) {
|
|
122
123
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
123
124
|
this.ws.send(buffer);
|
|
125
|
+
return true;
|
|
124
126
|
}
|
|
127
|
+
return false;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
/**
|
|
@@ -48,7 +48,7 @@ const OrderPool = {
|
|
|
48
48
|
quantity: 0,
|
|
49
49
|
transactionType: 1,
|
|
50
50
|
duration: 1,
|
|
51
|
-
orderType: 1
|
|
51
|
+
priceType: 2, // FIXED: was 'orderType: 1' - priceType 2 = MARKET order
|
|
52
52
|
manualOrAuto: 2,
|
|
53
53
|
},
|
|
54
54
|
|
|
@@ -102,11 +102,20 @@ const fastEntry = (service, orderData) => {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
try {
|
|
105
|
+
// FIXED: Use account-specific fcmId/ibId if available (some prop firms have different IDs per account)
|
|
106
|
+
const account = service.accounts?.find(a =>
|
|
107
|
+
a.accountId === orderData.accountId || a.rithmicAccountId === orderData.accountId
|
|
108
|
+
);
|
|
109
|
+
const effectiveLoginInfo = {
|
|
110
|
+
fcmId: account?.fcmId || service.loginInfo.fcmId,
|
|
111
|
+
ibId: account?.ibId || service.loginInfo.ibId,
|
|
112
|
+
};
|
|
113
|
+
|
|
105
114
|
// OPTIMIZED: Use pre-allocated order object
|
|
106
|
-
const order = OrderPool.fill(orderTag,
|
|
115
|
+
const order = OrderPool.fill(orderTag, effectiveLoginInfo, orderData);
|
|
107
116
|
|
|
108
117
|
// DEBUG: Log order details
|
|
109
|
-
console.log(`[ORDER] Sending: ${orderTag} | ${orderData.side === 0 ? 'BUY' : 'SELL'} ${orderData.size}x ${orderData.symbol} | acct=${orderData.accountId}`);
|
|
118
|
+
console.log(`[ORDER] Sending: ${orderTag} | ${orderData.side === 0 ? 'BUY' : 'SELL'} ${orderData.size}x ${orderData.symbol} | acct=${orderData.accountId} | fcm=${effectiveLoginInfo.fcmId} ib=${effectiveLoginInfo.ibId}`);
|
|
110
119
|
|
|
111
120
|
// OPTIMIZED: Use fastEncode with cached type
|
|
112
121
|
const buffer = proto.fastEncode('RequestNewOrder', order);
|
|
@@ -167,8 +176,17 @@ const fastExit = (service, orderData) => {
|
|
|
167
176
|
}
|
|
168
177
|
|
|
169
178
|
try {
|
|
179
|
+
// FIXED: Use account-specific fcmId/ibId if available
|
|
180
|
+
const account = service.accounts?.find(a =>
|
|
181
|
+
a.accountId === orderData.accountId || a.rithmicAccountId === orderData.accountId
|
|
182
|
+
);
|
|
183
|
+
const effectiveLoginInfo = {
|
|
184
|
+
fcmId: account?.fcmId || service.loginInfo.fcmId,
|
|
185
|
+
ibId: account?.ibId || service.loginInfo.ibId,
|
|
186
|
+
};
|
|
187
|
+
|
|
170
188
|
// OPTIMIZED: Use pre-allocated order object
|
|
171
|
-
const order = OrderPool.fill(orderTag,
|
|
189
|
+
const order = OrderPool.fill(orderTag, effectiveLoginInfo, orderData);
|
|
172
190
|
|
|
173
191
|
// OPTIMIZED: Use fastEncode with cached type
|
|
174
192
|
const buffer = proto.fastEncode('RequestNewOrder', order);
|
|
@@ -210,18 +228,23 @@ const placeOrder = async (service, orderData) => {
|
|
|
210
228
|
}
|
|
211
229
|
|
|
212
230
|
try {
|
|
231
|
+
// FIXED: Use account-specific fcmId/ibId if available
|
|
232
|
+
const account = service.accounts?.find(a =>
|
|
233
|
+
a.accountId === orderData.accountId || a.rithmicAccountId === orderData.accountId
|
|
234
|
+
);
|
|
235
|
+
|
|
213
236
|
service.orderConn.send('RequestNewOrder', {
|
|
214
237
|
templateId: REQ.NEW_ORDER,
|
|
215
238
|
userMsg: ['HQX'],
|
|
216
|
-
fcmId: service.loginInfo.fcmId,
|
|
217
|
-
ibId: service.loginInfo.ibId,
|
|
239
|
+
fcmId: account?.fcmId || service.loginInfo.fcmId,
|
|
240
|
+
ibId: account?.ibId || service.loginInfo.ibId,
|
|
218
241
|
accountId: orderData.accountId,
|
|
219
242
|
symbol: orderData.symbol,
|
|
220
243
|
exchange: orderData.exchange || 'CME',
|
|
221
244
|
quantity: orderData.size,
|
|
222
245
|
transactionType: orderData.side === 0 ? 1 : 2, // 1=Buy, 2=Sell
|
|
223
246
|
duration: 1, // DAY
|
|
224
|
-
|
|
247
|
+
priceType: orderData.type === 2 ? 2 : 1, // FIXED: was 'orderType' with inverted logic. priceType: 1=Limit, 2=Market
|
|
225
248
|
price: orderData.price || 0,
|
|
226
249
|
});
|
|
227
250
|
|