@stoqey/ib 1.3.6 → 1.3.8
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/api/api.d.ts +20 -7
- package/dist/api/api.js +19 -8
- package/dist/api/api.js.map +1 -1
- package/dist/api/contract/cfd.js +2 -3
- package/dist/api/contract/cfd.js.map +1 -1
- package/dist/api/contract/combo.js +2 -3
- package/dist/api/contract/combo.js.map +1 -1
- package/dist/api/contract/fop.js +3 -4
- package/dist/api/contract/fop.js.map +1 -1
- package/dist/api/contract/ind.js +2 -3
- package/dist/api/contract/ind.js.map +1 -1
- package/dist/api/contract/option.js +2 -3
- package/dist/api/contract/option.js.map +1 -1
- package/dist/api/contract/stock.js +2 -3
- package/dist/api/contract/stock.js.map +1 -1
- package/dist/api/data/enum/event-name.d.ts +3 -1
- package/dist/api/data/enum/event-name.js +2 -0
- package/dist/api/data/enum/event-name.js.map +1 -1
- package/dist/api/data/enum/min-server-version.js +3 -2
- package/dist/api/data/enum/min-server-version.js.map +1 -1
- package/dist/api/market/scannerSubscription.d.ts +4 -3
- package/dist/api/order/market.js +3 -4
- package/dist/api/order/market.js.map +1 -1
- package/dist/api/order/stop.js +3 -4
- package/dist/api/order/stop.js.map +1 -1
- package/dist/api/order/stopLimit.js +3 -4
- package/dist/api/order/stopLimit.js.map +1 -1
- package/dist/api/order/trailingStop.js +3 -4
- package/dist/api/order/trailingStop.js.map +1 -1
- package/dist/api-next/api-next.d.ts +44 -4
- package/dist/api-next/api-next.js +235 -94
- package/dist/api-next/api-next.js.map +1 -1
- package/dist/api-next/common/error.d.ts +2 -0
- package/dist/api-next/common/item-list-update.d.ts +2 -0
- package/dist/api-next/market-scanner/market-scanner.d.ts +224 -0
- package/dist/api-next/market-scanner/market-scanner.js +218 -0
- package/dist/api-next/market-scanner/market-scanner.js.map +1 -0
- package/dist/common/configuration.js +4 -1
- package/dist/common/configuration.js.map +1 -1
- package/dist/common/errorCode.js +3 -2
- package/dist/common/errorCode.js.map +1 -1
- package/dist/common/logger.js +10 -7
- package/dist/common/logger.js.map +1 -1
- package/dist/core/api-next/auto-connection.js +2 -2
- package/dist/core/api-next/auto-connection.js.map +1 -1
- package/dist/core/api-next/item-list-update.d.ts +2 -1
- package/dist/core/api-next/item-list-update.js +2 -1
- package/dist/core/api-next/item-list-update.js.map +1 -1
- package/dist/core/api-next/subscription-registry.js +1 -2
- package/dist/core/api-next/subscription-registry.js.map +1 -1
- package/dist/core/api-next/subscription.d.ts +7 -3
- package/dist/core/api-next/subscription.js +18 -10
- package/dist/core/api-next/subscription.js.map +1 -1
- package/dist/core/io/controller.js +4 -6
- package/dist/core/io/controller.js.map +1 -1
- package/dist/core/io/decoder.d.ts +9 -5
- package/dist/core/io/decoder.js +41 -25
- package/dist/core/io/decoder.js.map +1 -1
- package/dist/core/io/encoder.d.ts +3 -2
- package/dist/core/io/encoder.js +43 -41
- package/dist/core/io/encoder.js.map +1 -1
- package/dist/core/io/enum/in-msg-id.d.ts +2 -1
- package/dist/core/io/enum/in-msg-id.js +1 -0
- package/dist/core/io/enum/in-msg-id.js.map +1 -1
- package/dist/core/io/socket.js +15 -15
- package/dist/core/io/socket.js.map +1 -1
- package/dist/tests/unit/api/api.test.js +31 -54
- package/dist/tests/unit/api/api.test.js.map +1 -1
- package/dist/tests/unit/api/connect.test.js +40 -14
- package/dist/tests/unit/api/connect.test.js.map +1 -1
- package/dist/tests/unit/api/market-data.test.d.ts +1 -0
- package/dist/tests/unit/api/market-data.test.js +84 -0
- package/dist/tests/unit/api/market-data.test.js.map +1 -0
- package/dist/tests/unit/api/order/placeOrder.test.js +118 -28
- package/dist/tests/unit/api/order/placeOrder.test.js.map +1 -1
- package/dist/tests/unit/api/order/reqAllOpenOrders.test.js +22 -23
- package/dist/tests/unit/api/order/reqAllOpenOrders.test.js.map +1 -1
- package/dist/tests/unit/api-next/get-account-summary.test.js +21 -24
- package/dist/tests/unit/api-next/get-account-summary.test.js.map +1 -1
- package/dist/tests/unit/api-next/get-contract-details.test.js +1 -1
- package/dist/tests/unit/api-next/get-contract-details.test.js.map +1 -1
- package/dist/tests/unit/api-next/get-market-data.test.js +1 -1
- package/dist/tests/unit/api-next/get-market-data.test.js.map +1 -1
- package/dist/tests/unit/api-next/get-positions.test.js +8 -9
- package/dist/tests/unit/api-next/get-positions.test.js.map +1 -1
- package/dist/tests/unit/api-next/place-order.test.js +3 -3
- package/dist/tests/unit/api-next/place-order.test.js.map +1 -1
- package/dist/tools/account-summary.js +4 -7
- package/dist/tools/account-summary.js.map +1 -1
- package/dist/tools/commission-reports.js +3 -6
- package/dist/tools/commission-reports.js.map +1 -1
- package/dist/tools/common/ib-api-next-app.d.ts +20 -1
- package/dist/tools/common/ib-api-next-app.js +103 -38
- package/dist/tools/common/ib-api-next-app.js.map +1 -1
- package/dist/tools/contract-details.js +3 -28
- package/dist/tools/contract-details.js.map +1 -1
- package/dist/tools/current-time.js +2 -3
- package/dist/tools/current-time.js.map +1 -1
- package/dist/tools/execution-details.js +3 -6
- package/dist/tools/execution-details.js.map +1 -1
- package/dist/tools/get-head-timestamp.js +11 -30
- package/dist/tools/get-head-timestamp.js.map +1 -1
- package/dist/tools/histogram-data.js +2 -3
- package/dist/tools/histogram-data.js.map +1 -1
- package/dist/tools/historical-data-updates.js +3 -5
- package/dist/tools/historical-data-updates.js.map +1 -1
- package/dist/tools/historical-data.js +2 -3
- package/dist/tools/historical-data.js.map +1 -1
- package/dist/tools/historical-ticks-bid-ask.js +3 -5
- package/dist/tools/historical-ticks-bid-ask.js.map +1 -1
- package/dist/tools/historical-ticks-last.js +4 -7
- package/dist/tools/historical-ticks-last.js.map +1 -1
- package/dist/tools/historical-ticks-mid.js +3 -5
- package/dist/tools/historical-ticks-mid.js.map +1 -1
- package/dist/tools/managed-accts.js +2 -3
- package/dist/tools/managed-accts.js.map +1 -1
- package/dist/tools/{market-data-single.js → market-data-snapshot.js} +13 -39
- package/dist/tools/market-data-snapshot.js.map +1 -0
- package/dist/tools/market-data.js +9 -43
- package/dist/tools/market-data.js.map +1 -1
- package/dist/tools/market-depth-exchanges.js +2 -3
- package/dist/tools/market-depth-exchanges.js.map +1 -1
- package/dist/tools/market-depth.js +4 -7
- package/dist/tools/market-depth.js.map +1 -1
- package/dist/tools/market-scanner.d.ts +1 -0
- package/dist/tools/market-scanner.js +64 -0
- package/dist/tools/market-scanner.js.map +1 -0
- package/dist/tools/modify-order.js +2 -5
- package/dist/tools/modify-order.js.map +1 -1
- package/dist/tools/next-valid-order-id.js +2 -3
- package/dist/tools/next-valid-order-id.js.map +1 -1
- package/dist/tools/open-orders-auto.js +5 -10
- package/dist/tools/open-orders-auto.js.map +1 -1
- package/dist/tools/open-orders.js +2 -3
- package/dist/tools/open-orders.js.map +1 -1
- package/dist/tools/place-new-order.js +2 -4
- package/dist/tools/place-new-order.js.map +1 -1
- package/dist/tools/place-order.d.ts +1 -1
- package/dist/tools/place-order.js +24 -20
- package/dist/tools/place-order.js.map +1 -1
- package/dist/tools/pnl-single.js +3 -10
- package/dist/tools/pnl-single.js.map +1 -1
- package/dist/tools/pnl.js +3 -10
- package/dist/tools/pnl.js.map +1 -1
- package/dist/tools/positions.js +4 -12
- package/dist/tools/positions.js.map +1 -1
- package/dist/tools/search-contracts.js +2 -3
- package/dist/tools/search-contracts.js.map +1 -1
- package/dist/tools/sec-def-opt-params.js +7 -6
- package/dist/tools/sec-def-opt-params.js.map +1 -1
- package/dist/tools/user-info.d.ts +4 -0
- package/dist/tools/user-info.js +51 -0
- package/dist/tools/user-info.js.map +1 -0
- package/package.json +51 -53
- package/dist/tools/market-data-single.js.map +0 -1
- /package/dist/tools/{market-data-single.d.ts → market-data-snapshot.d.ts} +0 -0
|
@@ -59,7 +59,6 @@ class IBApiNext {
|
|
|
59
59
|
* @param options Creation options.
|
|
60
60
|
*/
|
|
61
61
|
constructor(options) {
|
|
62
|
-
var _a, _b, _c;
|
|
63
62
|
this._nextReqId = 1;
|
|
64
63
|
/**
|
|
65
64
|
* The IBApi error [[Subject]].
|
|
@@ -85,13 +84,12 @@ class IBApiNext {
|
|
|
85
84
|
/** accountSummary event handler */
|
|
86
85
|
this.onAccountSummary = (subscriptions, reqId, account, tag, value, currency) => {
|
|
87
86
|
// get the subscription
|
|
88
|
-
var _a;
|
|
89
87
|
const subscription = subscriptions.get(reqId);
|
|
90
88
|
if (!subscription) {
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
93
91
|
// update latest value on cache
|
|
94
|
-
const cached =
|
|
92
|
+
const cached = subscription.lastAllValue ?? new mutable_account_summary_1.MutableAccountSummaries();
|
|
95
93
|
const lastValue = cached
|
|
96
94
|
.getOrAdd(account, () => new mutable_account_summary_1.MutableAccountSummaryTagValues())
|
|
97
95
|
.getOrAdd(tag, () => new mutable_account_summary_1.MutableAccountSummaryValues());
|
|
@@ -137,10 +135,9 @@ class IBApiNext {
|
|
|
137
135
|
this.onUpdateAccountValue = (subscriptions, tag, value, currency, account) => {
|
|
138
136
|
this.logger.debug(LOG_TAG, `onUpdateAccountValue(${tag}, ${value}, ${currency}, ${account})`);
|
|
139
137
|
subscriptions.forEach((subscription) => {
|
|
140
|
-
var _a, _b;
|
|
141
138
|
// update latest value on cache
|
|
142
|
-
const all =
|
|
143
|
-
const cached =
|
|
139
|
+
const all = subscription.lastAllValue ?? {};
|
|
140
|
+
const cached = all?.value ?? new mutable_account_summary_1.MutableAccountSummaries();
|
|
144
141
|
const lastValue = cached
|
|
145
142
|
.getOrAdd(account, () => new mutable_account_summary_1.MutableAccountSummaryTagValues())
|
|
146
143
|
.getOrAdd(tag, () => new mutable_account_summary_1.MutableAccountSummaryValues());
|
|
@@ -191,15 +188,23 @@ class IBApiNext {
|
|
|
191
188
|
*/
|
|
192
189
|
this.onUpdatePortfolio = (subscriptions, contract, pos, marketPrice, marketValue, avgCost, unrealizedPNL, realizedPNL, account) => {
|
|
193
190
|
this.logger.debug(LOG_TAG, `onUpdatePortfolio(${contract.symbol}, ${pos}, ${marketPrice}, ${marketValue}, ${avgCost}, ${unrealizedPNL}, ${realizedPNL}, ${account})`);
|
|
194
|
-
const updatedPosition = {
|
|
191
|
+
const updatedPosition = {
|
|
192
|
+
account,
|
|
193
|
+
contract,
|
|
194
|
+
pos,
|
|
195
|
+
avgCost,
|
|
196
|
+
marketPrice,
|
|
197
|
+
marketValue,
|
|
198
|
+
unrealizedPNL,
|
|
199
|
+
realizedPNL,
|
|
200
|
+
};
|
|
195
201
|
// notify all subscribers
|
|
196
202
|
subscriptions.forEach((subscription) => {
|
|
197
203
|
// update latest value on cache
|
|
198
|
-
var _a, _b;
|
|
199
204
|
let hasAdded = false;
|
|
200
205
|
let hasRemoved = false;
|
|
201
|
-
const all =
|
|
202
|
-
const cached =
|
|
206
|
+
const all = subscription.lastAllValue ?? {};
|
|
207
|
+
const cached = all?.portfolio ?? new mutable_account_positions_update_1.MutableAccountPositions();
|
|
203
208
|
const accountPositions = cached.getOrAdd(account, () => []);
|
|
204
209
|
const changePositionIndex = accountPositions.findIndex((p) => p.contract.conId == contract.conId);
|
|
205
210
|
if (changePositionIndex === -1) {
|
|
@@ -222,19 +227,31 @@ class IBApiNext {
|
|
|
222
227
|
if (hasAdded) {
|
|
223
228
|
subscription.next({
|
|
224
229
|
all: all,
|
|
225
|
-
added: {
|
|
230
|
+
added: {
|
|
231
|
+
portfolio: new mutable_account_positions_update_1.MutableAccountPositions([
|
|
232
|
+
[account, [updatedPosition]],
|
|
233
|
+
]),
|
|
234
|
+
},
|
|
226
235
|
});
|
|
227
236
|
}
|
|
228
237
|
else if (hasRemoved) {
|
|
229
238
|
subscription.next({
|
|
230
239
|
all: all,
|
|
231
|
-
removed: {
|
|
240
|
+
removed: {
|
|
241
|
+
portfolio: new mutable_account_positions_update_1.MutableAccountPositions([
|
|
242
|
+
[account, [updatedPosition]],
|
|
243
|
+
]),
|
|
244
|
+
},
|
|
232
245
|
});
|
|
233
246
|
}
|
|
234
247
|
else {
|
|
235
248
|
subscription.next({
|
|
236
249
|
all: all,
|
|
237
|
-
changed: {
|
|
250
|
+
changed: {
|
|
251
|
+
portfolio: new mutable_account_positions_update_1.MutableAccountPositions([
|
|
252
|
+
[account, [updatedPosition]],
|
|
253
|
+
]),
|
|
254
|
+
},
|
|
238
255
|
});
|
|
239
256
|
}
|
|
240
257
|
});
|
|
@@ -250,9 +267,8 @@ class IBApiNext {
|
|
|
250
267
|
this.onUpdateAccountTime = (subscriptions, timeStamp) => {
|
|
251
268
|
this.logger.debug(LOG_TAG, `onUpdateAccountTime(${timeStamp})`);
|
|
252
269
|
subscriptions.forEach((sub) => {
|
|
253
|
-
var _a;
|
|
254
270
|
const changed = { timestamp: timeStamp };
|
|
255
|
-
const all =
|
|
271
|
+
const all = sub.lastAllValue ?? {};
|
|
256
272
|
all.timestamp = changed.timestamp;
|
|
257
273
|
sub.next({
|
|
258
274
|
all: all,
|
|
@@ -278,10 +294,9 @@ class IBApiNext {
|
|
|
278
294
|
// notify all subscribers
|
|
279
295
|
subscriptions.forEach((subscription) => {
|
|
280
296
|
// update latest value on cache
|
|
281
|
-
var _a;
|
|
282
297
|
let hasAdded = false;
|
|
283
298
|
let hasRemoved = false;
|
|
284
|
-
const cached =
|
|
299
|
+
const cached = subscription.lastAllValue ?? new mutable_account_positions_update_1.MutableAccountPositions();
|
|
285
300
|
const accountPositions = cached.getOrAdd(account, () => []);
|
|
286
301
|
const changePositionIndex = accountPositions.findIndex((p) => p.contract.conId == contract.conId);
|
|
287
302
|
if (changePositionIndex === -1) {
|
|
@@ -323,13 +338,12 @@ class IBApiNext {
|
|
|
323
338
|
/** contractDetails event handler */
|
|
324
339
|
this.onContractDetails = (subscriptions, reqId, details) => {
|
|
325
340
|
// get the subscription
|
|
326
|
-
var _a;
|
|
327
341
|
const subscription = subscriptions.get(reqId);
|
|
328
342
|
if (!subscription) {
|
|
329
343
|
return;
|
|
330
344
|
}
|
|
331
345
|
// append to list
|
|
332
|
-
const cached =
|
|
346
|
+
const cached = subscription.lastAllValue ?? [];
|
|
333
347
|
cached.push(details);
|
|
334
348
|
// sent change to subscribers
|
|
335
349
|
subscription.next({
|
|
@@ -338,26 +352,24 @@ class IBApiNext {
|
|
|
338
352
|
};
|
|
339
353
|
/** contractDetailsEnd event handler */
|
|
340
354
|
this.onContractDetailsEnd = (subscriptions, reqId) => {
|
|
341
|
-
|
|
342
|
-
(_a = subscriptions.get(reqId)) === null || _a === void 0 ? void 0 : _a.complete();
|
|
355
|
+
subscriptions.get(reqId)?.complete();
|
|
343
356
|
};
|
|
344
357
|
/** securityDefinitionOptionParameter event handler */
|
|
345
358
|
this.onSecurityDefinitionOptionParameter = (subscriptions, reqId, exchange, underlyingConId, tradingClass, multiplier, expirations, strikes) => {
|
|
346
359
|
// get the subscription
|
|
347
|
-
var _a;
|
|
348
360
|
const subscription = subscriptions.get(reqId);
|
|
349
361
|
if (!subscription) {
|
|
350
362
|
return;
|
|
351
363
|
}
|
|
352
364
|
// append to list
|
|
353
|
-
const cached =
|
|
365
|
+
const cached = subscription.lastAllValue ?? [];
|
|
354
366
|
cached.push({
|
|
355
367
|
exchange: exchange,
|
|
356
368
|
underlyingConId: underlyingConId,
|
|
357
369
|
tradingClass: tradingClass,
|
|
358
370
|
multiplier: parseInt(multiplier),
|
|
359
371
|
expirations: expirations,
|
|
360
|
-
strikes: strikes
|
|
372
|
+
strikes: strikes,
|
|
361
373
|
});
|
|
362
374
|
// sent change to subscribers
|
|
363
375
|
subscription.next({
|
|
@@ -366,8 +378,7 @@ class IBApiNext {
|
|
|
366
378
|
};
|
|
367
379
|
/** securityDefinitionOptionParameterEnd event handler */
|
|
368
380
|
this.onSecurityDefinitionOptionParameterEnd = (subscriptions, reqId) => {
|
|
369
|
-
|
|
370
|
-
(_a = subscriptions.get(reqId)) === null || _a === void 0 ? void 0 : _a.complete();
|
|
381
|
+
subscriptions.get(reqId)?.complete();
|
|
371
382
|
};
|
|
372
383
|
/** pnl event handler. */
|
|
373
384
|
this.onPnL = (subscriptions, reqId, dailyPnL, unrealizedPnL, realizedPnL) => {
|
|
@@ -402,7 +413,6 @@ class IBApiNext {
|
|
|
402
413
|
/** tickPrice, tickSize and tickGeneric event handler */
|
|
403
414
|
this.onTick = (subscriptions, reqId, tickType, value) => {
|
|
404
415
|
// convert -1 on Bid/Ask to undefined
|
|
405
|
-
var _a;
|
|
406
416
|
if (value === -1 &&
|
|
407
417
|
(tickType === _1.IBApiTickType.BID ||
|
|
408
418
|
tickType === _1.IBApiTickType.DELAYED_BID ||
|
|
@@ -416,7 +426,7 @@ class IBApiNext {
|
|
|
416
426
|
return;
|
|
417
427
|
}
|
|
418
428
|
// update latest value on cache
|
|
419
|
-
const cached =
|
|
429
|
+
const cached = subscription.lastAllValue ?? new mutable_market_data_1.MutableMarketData();
|
|
420
430
|
const hasChanged = cached.has(tickType);
|
|
421
431
|
const updatedValue = {
|
|
422
432
|
value,
|
|
@@ -440,7 +450,6 @@ class IBApiNext {
|
|
|
440
450
|
/** tickOptionComputationHandler event handler */
|
|
441
451
|
this.onTickOptionComputation = (subscriptions, reqId, field, impliedVolatility, delta, optPrice, pvDividend, gamma, vega, theta, undPrice) => {
|
|
442
452
|
// get subscription
|
|
443
|
-
var _a;
|
|
444
453
|
const subscription = subscriptions.get(reqId);
|
|
445
454
|
if (!subscription) {
|
|
446
455
|
return;
|
|
@@ -471,7 +480,10 @@ class IBApiNext {
|
|
|
471
480
|
], [
|
|
472
481
|
_1.IBApiNextTickType.BID_OPTION_GAMMA,
|
|
473
482
|
{ value: gamma, ingressTm: now },
|
|
474
|
-
], [_1.IBApiNextTickType.BID_OPTION_VEGA, { value: vega, ingressTm: now }], [
|
|
483
|
+
], [_1.IBApiNextTickType.BID_OPTION_VEGA, { value: vega, ingressTm: now }], [
|
|
484
|
+
_1.IBApiNextTickType.BID_OPTION_THETA,
|
|
485
|
+
{ value: theta, ingressTm: now },
|
|
486
|
+
]);
|
|
475
487
|
break;
|
|
476
488
|
case _1.IBApiTickType.DELAYED_BID_OPTION:
|
|
477
489
|
ticks.push([
|
|
@@ -507,7 +519,10 @@ class IBApiNext {
|
|
|
507
519
|
], [
|
|
508
520
|
_1.IBApiNextTickType.ASK_OPTION_GAMMA,
|
|
509
521
|
{ value: gamma, ingressTm: now },
|
|
510
|
-
], [_1.IBApiNextTickType.ASK_OPTION_VEGA, { value: vega, ingressTm: now }], [
|
|
522
|
+
], [_1.IBApiNextTickType.ASK_OPTION_VEGA, { value: vega, ingressTm: now }], [
|
|
523
|
+
_1.IBApiNextTickType.ASK_OPTION_THETA,
|
|
524
|
+
{ value: theta, ingressTm: now },
|
|
525
|
+
]);
|
|
511
526
|
break;
|
|
512
527
|
case _1.IBApiTickType.DELAYED_ASK_OPTION:
|
|
513
528
|
ticks.push([
|
|
@@ -613,7 +628,7 @@ class IBApiNext {
|
|
|
613
628
|
break;
|
|
614
629
|
}
|
|
615
630
|
// update latest value on cache
|
|
616
|
-
const cached =
|
|
631
|
+
const cached = subscription.lastAllValue ?? new mutable_market_data_1.MutableMarketData();
|
|
617
632
|
const added = new mutable_market_data_1.MutableMarketData();
|
|
618
633
|
const changed = new mutable_market_data_1.MutableMarketData();
|
|
619
634
|
ticks.forEach((tick) => {
|
|
@@ -636,8 +651,7 @@ class IBApiNext {
|
|
|
636
651
|
};
|
|
637
652
|
/** tickSnapshotEnd event handler */
|
|
638
653
|
this.onTickSnapshotEnd = (subscriptions, reqId) => {
|
|
639
|
-
|
|
640
|
-
(_a = subscriptions.get(reqId)) === null || _a === void 0 ? void 0 : _a.complete();
|
|
654
|
+
subscriptions.get(reqId)?.complete();
|
|
641
655
|
};
|
|
642
656
|
/**
|
|
643
657
|
* @deprecated please use getMarketDataSnapshot instead of getMarketDataSingle.
|
|
@@ -657,7 +671,6 @@ class IBApiNext {
|
|
|
657
671
|
/** historicalData event handler */
|
|
658
672
|
this.onHistoricalData = (subscriptions, reqId, time, open, high, low, close, volume, count, WAP) => {
|
|
659
673
|
// get subscription
|
|
660
|
-
var _a;
|
|
661
674
|
const subscription = subscriptions.get(reqId);
|
|
662
675
|
if (!subscription) {
|
|
663
676
|
return;
|
|
@@ -667,7 +680,7 @@ class IBApiNext {
|
|
|
667
680
|
subscription.complete();
|
|
668
681
|
}
|
|
669
682
|
else {
|
|
670
|
-
const all =
|
|
683
|
+
const all = subscription.lastAllValue ?? [];
|
|
671
684
|
const current = { time };
|
|
672
685
|
if (open !== -1) {
|
|
673
686
|
current.open = open;
|
|
@@ -699,13 +712,12 @@ class IBApiNext {
|
|
|
699
712
|
/** historicalDataUpdate event handler */
|
|
700
713
|
this.onHistoricalDataUpdate = (subscriptions, reqId, time, open, high, low, close, volume, count, WAP) => {
|
|
701
714
|
// get subscription
|
|
702
|
-
var _a;
|
|
703
715
|
const subscription = subscriptions.get(reqId);
|
|
704
716
|
if (!subscription) {
|
|
705
717
|
return;
|
|
706
718
|
}
|
|
707
719
|
// update bar
|
|
708
|
-
const current =
|
|
720
|
+
const current = subscription.lastAllValue ?? {};
|
|
709
721
|
current.time = time;
|
|
710
722
|
current.open = open !== -1 ? open : undefined;
|
|
711
723
|
current.high = high !== -1 ? high : undefined;
|
|
@@ -779,28 +791,19 @@ class IBApiNext {
|
|
|
779
791
|
});
|
|
780
792
|
};
|
|
781
793
|
/** updateMktDepth event handler */
|
|
782
|
-
this.onUpdateMktDepth = (subscriptions,
|
|
794
|
+
this.onUpdateMktDepth = (subscriptions, reqId, position, operation, side, price, size) => {
|
|
783
795
|
// forward to L2 handler, but w/o market maker and smart depth set to false
|
|
784
|
-
this.onUpdateMktDepthL2(subscriptions,
|
|
785
|
-
};
|
|
786
|
-
// mutable
|
|
787
|
-
this.insertAtIndex = (index, key, value, map) => {
|
|
788
|
-
const arr = Array.from(map);
|
|
789
|
-
arr.splice(index, 0, [key, value]);
|
|
790
|
-
map.clear();
|
|
791
|
-
arr.forEach(([k, v]) => map.set(k, v));
|
|
792
|
-
return map;
|
|
796
|
+
this.onUpdateMktDepthL2(subscriptions, reqId, position, undefined, operation, side, price, size, false);
|
|
793
797
|
};
|
|
794
798
|
/** marketDepthL2 event handler */
|
|
795
|
-
this.onUpdateMktDepthL2 = (subscriptions,
|
|
796
|
-
var _a;
|
|
799
|
+
this.onUpdateMktDepthL2 = (subscriptions, reqId, position, marketMaker, operation, side, price, size, isSmartDepth) => {
|
|
797
800
|
// get subscription
|
|
798
|
-
const subscription = subscriptions.get(
|
|
801
|
+
const subscription = subscriptions.get(reqId);
|
|
799
802
|
if (!subscription) {
|
|
800
803
|
return;
|
|
801
804
|
}
|
|
802
805
|
// update cached
|
|
803
|
-
const cached =
|
|
806
|
+
const cached = subscription.lastAllValue ?? {
|
|
804
807
|
bids: new Map(),
|
|
805
808
|
asks: new Map(),
|
|
806
809
|
};
|
|
@@ -827,13 +830,13 @@ class IBApiNext {
|
|
|
827
830
|
switch (operation) {
|
|
828
831
|
case 0:
|
|
829
832
|
// it's an insert
|
|
830
|
-
this.
|
|
833
|
+
this.insertAtMapIndex(position, position, {
|
|
831
834
|
marketMaker: marketMaker,
|
|
832
835
|
price: price,
|
|
833
836
|
size: size,
|
|
834
837
|
isSmartDepth: isSmartDepth,
|
|
835
838
|
}, cachedRows);
|
|
836
|
-
this.
|
|
839
|
+
this.insertAtMapIndex(position, position, {
|
|
837
840
|
marketMaker: marketMaker,
|
|
838
841
|
price: price,
|
|
839
842
|
size: size,
|
|
@@ -878,6 +881,83 @@ class IBApiNext {
|
|
|
878
881
|
break;
|
|
879
882
|
}
|
|
880
883
|
};
|
|
884
|
+
this.onScannerParameters = (subscriptions, xml) => {
|
|
885
|
+
subscriptions.forEach((sub) => {
|
|
886
|
+
sub.next({ all: xml });
|
|
887
|
+
sub.complete();
|
|
888
|
+
});
|
|
889
|
+
};
|
|
890
|
+
/**
|
|
891
|
+
* Provides the data resulting from the market scanner request.
|
|
892
|
+
* @param subscriptions
|
|
893
|
+
* @param reqId the request's identifier
|
|
894
|
+
* @param rank the ranking within the response of this bar.
|
|
895
|
+
* @param contract the data's ContractDetails
|
|
896
|
+
* @param distance according to query
|
|
897
|
+
* @param benchmark according to query
|
|
898
|
+
* @param projection according to query
|
|
899
|
+
* @param legStr describes the combo legs when the scanner is returning EFP
|
|
900
|
+
* @returns void
|
|
901
|
+
*/
|
|
902
|
+
this.onScannerData = (subscriptions, reqId, rank, contract, distance, benchmark, projection, legStr) => {
|
|
903
|
+
// get subscription
|
|
904
|
+
const subscription = subscriptions.get(reqId);
|
|
905
|
+
if (!subscription) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
const item = {
|
|
909
|
+
rank,
|
|
910
|
+
contract,
|
|
911
|
+
distance,
|
|
912
|
+
benchmark,
|
|
913
|
+
projection,
|
|
914
|
+
legStr,
|
|
915
|
+
};
|
|
916
|
+
// console.log("onScannerData", item);
|
|
917
|
+
const lastValue = subscription.lastValue ?? {
|
|
918
|
+
all: new Map(),
|
|
919
|
+
allset: false,
|
|
920
|
+
};
|
|
921
|
+
const existing = lastValue.all.get(rank) != undefined;
|
|
922
|
+
lastValue.all.set(rank, item);
|
|
923
|
+
if (lastValue.allset) {
|
|
924
|
+
const updated = new Map();
|
|
925
|
+
updated.set(rank, item);
|
|
926
|
+
subscription.next({
|
|
927
|
+
all: lastValue.all,
|
|
928
|
+
allset: lastValue.allset,
|
|
929
|
+
changed: existing ? updated : undefined,
|
|
930
|
+
added: existing ? undefined : updated,
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
// console.log("saving for future use", lastValue);
|
|
935
|
+
subscription.lastValue = lastValue;
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
/**
|
|
939
|
+
* Indicates the scanner data reception has terminated.
|
|
940
|
+
* @param subscriptions
|
|
941
|
+
* @param reqId the request's identifier
|
|
942
|
+
* @returns
|
|
943
|
+
*/
|
|
944
|
+
this.onScannerDataEnd = (subscriptions, reqId) => {
|
|
945
|
+
const subscription = subscriptions.get(reqId);
|
|
946
|
+
if (!subscription) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const lastValue = subscription.lastValue ?? {
|
|
950
|
+
all: new Map(),
|
|
951
|
+
};
|
|
952
|
+
const updated = {
|
|
953
|
+
all: lastValue.all,
|
|
954
|
+
allset: true,
|
|
955
|
+
added: lastValue.all,
|
|
956
|
+
};
|
|
957
|
+
// console.log("onScannerDataEnd", updated);
|
|
958
|
+
// subscription.next(updated);
|
|
959
|
+
subscription.next(updated);
|
|
960
|
+
};
|
|
881
961
|
/** histogramData event handler */
|
|
882
962
|
this.onHistogramData = (subscriptions, reqId, data) => {
|
|
883
963
|
// get the subscription
|
|
@@ -902,12 +982,17 @@ class IBApiNext {
|
|
|
902
982
|
*/
|
|
903
983
|
this.onOpenOrder = (subscriptions, orderId, contract, order, orderState) => {
|
|
904
984
|
subscriptions.forEach((sub) => {
|
|
905
|
-
|
|
906
|
-
const allOrders = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
|
|
985
|
+
const allOrders = sub.lastAllValue ?? [];
|
|
907
986
|
const changeOrderIndex = allOrders.findIndex((p) => p.order.permId == order.permId);
|
|
908
987
|
if (changeOrderIndex === -1) {
|
|
909
988
|
// new open order - add it
|
|
910
|
-
const addedOrder = {
|
|
989
|
+
const addedOrder = {
|
|
990
|
+
orderId,
|
|
991
|
+
contract,
|
|
992
|
+
order,
|
|
993
|
+
orderState,
|
|
994
|
+
orderStatus: undefined,
|
|
995
|
+
};
|
|
911
996
|
allOrders.push(addedOrder);
|
|
912
997
|
sub.next({
|
|
913
998
|
all: allOrders,
|
|
@@ -959,7 +1044,7 @@ class IBApiNext {
|
|
|
959
1044
|
* This is probably unused now.
|
|
960
1045
|
* Neither reqAllOpenOrders, reqAutoOpenOrders nor reqOpenOrders documentation reference this event.
|
|
961
1046
|
* Even getAutoOpenOrders(true) doesn't call it!
|
|
962
|
-
|
|
1047
|
+
*/
|
|
963
1048
|
this.logger.warn(LOG_TAG, `Unexpected onOrderBound(${orderId}, ${apiClientId}, ${apiOrderId}) called.`);
|
|
964
1049
|
};
|
|
965
1050
|
/**
|
|
@@ -990,15 +1075,14 @@ class IBApiNext {
|
|
|
990
1075
|
lastFillPrice: undefined,
|
|
991
1076
|
clientId,
|
|
992
1077
|
whyHeld,
|
|
993
|
-
mktCapPrice
|
|
1078
|
+
mktCapPrice,
|
|
994
1079
|
};
|
|
995
1080
|
if (filled) {
|
|
996
1081
|
orderStatus.avgFillPrice = avgFillPrice;
|
|
997
1082
|
orderStatus.lastFillPrice = lastFillPrice;
|
|
998
1083
|
}
|
|
999
1084
|
subscriptions.forEach((sub) => {
|
|
1000
|
-
|
|
1001
|
-
const allOrders = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
|
|
1085
|
+
const allOrders = sub.lastAllValue ?? [];
|
|
1002
1086
|
const changeOrderIndex = allOrders.findIndex((p) => p.order.permId == permId);
|
|
1003
1087
|
if (changeOrderIndex !== -1) {
|
|
1004
1088
|
const updatedOrder = allOrders[changeOrderIndex];
|
|
@@ -1042,8 +1126,7 @@ class IBApiNext {
|
|
|
1042
1126
|
*/
|
|
1043
1127
|
this.onExecDetails = (subscriptions, reqId, contract, execution) => {
|
|
1044
1128
|
subscriptions.forEach((sub) => {
|
|
1045
|
-
|
|
1046
|
-
const allTrades = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
|
|
1129
|
+
const allTrades = sub.lastAllValue ?? [];
|
|
1047
1130
|
allTrades.push({ reqId, contract, execution });
|
|
1048
1131
|
sub.next({
|
|
1049
1132
|
all: allTrades,
|
|
@@ -1067,8 +1150,7 @@ class IBApiNext {
|
|
|
1067
1150
|
/** comissionReport event handler. */
|
|
1068
1151
|
this.onComissionReport = (subscriptions, commissionReport) => {
|
|
1069
1152
|
subscriptions.forEach((sub) => {
|
|
1070
|
-
|
|
1071
|
-
const commissionReports = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
|
|
1153
|
+
const commissionReports = sub.lastAllValue ?? [];
|
|
1072
1154
|
commissionReports.push(commissionReport);
|
|
1073
1155
|
sub.next({
|
|
1074
1156
|
all: commissionReports,
|
|
@@ -1079,24 +1161,37 @@ class IBApiNext {
|
|
|
1079
1161
|
this.onSymbolSamples = (subscriptions, reqId, contractDescriptions) => {
|
|
1080
1162
|
const sub = subscriptions.get(reqId);
|
|
1081
1163
|
subscriptions.delete(reqId);
|
|
1082
|
-
sub
|
|
1164
|
+
sub?.next({
|
|
1083
1165
|
all: contractDescriptions,
|
|
1084
1166
|
});
|
|
1085
|
-
sub
|
|
1167
|
+
sub?.complete();
|
|
1168
|
+
};
|
|
1169
|
+
/** userInfo event handler. */
|
|
1170
|
+
this.onUserInfo = (subscriptions, reqId, whiteBrandingId) => {
|
|
1171
|
+
const sub = subscriptions.get(reqId);
|
|
1172
|
+
subscriptions.delete(reqId);
|
|
1173
|
+
sub?.next({
|
|
1174
|
+
all: whiteBrandingId,
|
|
1175
|
+
});
|
|
1176
|
+
sub?.complete();
|
|
1086
1177
|
};
|
|
1087
|
-
this.logger = new logger_1.IBApiNextLogger(
|
|
1178
|
+
this.logger = new logger_1.IBApiNextLogger(options?.logger ?? new console_logger_1.ConsoleLogger());
|
|
1088
1179
|
// create the IBApiAutoConnection and subscription registry
|
|
1089
|
-
this.api = new auto_connection_1.IBApiAutoConnection(
|
|
1180
|
+
this.api = new auto_connection_1.IBApiAutoConnection(options?.reconnectInterval ?? 0, (options?.connectionWatchdogInterval ?? 0) * 1000, this.logger, options);
|
|
1090
1181
|
this.subscriptions = new subscription_registry_1.IBApiNextSubscriptionRegistry(this.api, this);
|
|
1091
1182
|
// setup error event handler (bound to lifetime of IBApiAutoConnection so we never unregister)
|
|
1092
|
-
this.api.on(__1.EventName.error, (error, code, reqId) => {
|
|
1093
|
-
|
|
1094
|
-
|
|
1183
|
+
this.api.on(__1.EventName.error, (error, code, reqId, advancedOrderReject) => {
|
|
1184
|
+
const apiError = {
|
|
1185
|
+
error,
|
|
1186
|
+
code,
|
|
1187
|
+
reqId,
|
|
1188
|
+
advancedOrderReject,
|
|
1189
|
+
};
|
|
1095
1190
|
// handle warnings - they are also reported on TWS error callback, but we DO NOT want to emit
|
|
1096
1191
|
// it as error into the subject (and cancel the subscription).
|
|
1097
|
-
if ((code >= 2100 && code < 3000)
|
|
1098
|
-
|
|
1099
|
-
|
|
1192
|
+
if ((code >= 2100 && code < 3000) ||
|
|
1193
|
+
code === __1.ErrorCode.PART_OF_REQUESTED_DATA_NOT_SUBSCRIBED ||
|
|
1194
|
+
code === __1.ErrorCode.DISPLAYING_DELAYED_DATA) {
|
|
1100
1195
|
this.logger.warn(TWS_LOG_TAG, `${error.message} - Code: ${code} - ReqId: ${reqId}`);
|
|
1101
1196
|
return;
|
|
1102
1197
|
}
|
|
@@ -1184,8 +1279,7 @@ class IBApiNext {
|
|
|
1184
1279
|
return (0, rxjs_1.lastValueFrom)(this.subscriptions
|
|
1185
1280
|
.register(() => {
|
|
1186
1281
|
this.api.reqCurrentTime();
|
|
1187
|
-
}, undefined, [[__1.EventName.currentTime, this.onCurrentTime]], "
|
|
1188
|
-
)
|
|
1282
|
+
}, undefined, [[__1.EventName.currentTime, this.onCurrentTime]], "getCurrentTime")
|
|
1189
1283
|
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1190
1284
|
defaultValue: 0,
|
|
1191
1285
|
});
|
|
@@ -1197,8 +1291,7 @@ class IBApiNext {
|
|
|
1197
1291
|
return (0, rxjs_1.lastValueFrom)(this.subscriptions
|
|
1198
1292
|
.register(() => {
|
|
1199
1293
|
this.api.reqManagedAccts();
|
|
1200
|
-
}, undefined, [[__1.EventName.managedAccounts, this.onManagedAccts]], "getManagedAccounts"
|
|
1201
|
-
)
|
|
1294
|
+
}, undefined, [[__1.EventName.managedAccounts, this.onManagedAccts]], "getManagedAccounts")
|
|
1202
1295
|
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1203
1296
|
defaultValue: [],
|
|
1204
1297
|
});
|
|
@@ -1277,8 +1370,7 @@ class IBApiNext {
|
|
|
1277
1370
|
[__1.EventName.updatePortfolio, this.onUpdatePortfolio],
|
|
1278
1371
|
[__1.EventName.updateAccountTime, this.onUpdateAccountTime],
|
|
1279
1372
|
[__1.EventName.accountDownloadEnd, this.onAccountDownloadEnd],
|
|
1280
|
-
],
|
|
1281
|
-
);
|
|
1373
|
+
], acctCode ? `getAccountUpdates+${acctCode}` : "getAccountUpdates");
|
|
1282
1374
|
}
|
|
1283
1375
|
/**
|
|
1284
1376
|
* Create subscription to receive the positions on all accessible accounts.
|
|
@@ -1328,8 +1420,14 @@ class IBApiNext {
|
|
|
1328
1420
|
.register((reqId) => {
|
|
1329
1421
|
this.api.reqSecDefOptParams(reqId, underlyingSymbol, futFopExchange, underlyingSecType, underlyingConId);
|
|
1330
1422
|
}, undefined, [
|
|
1331
|
-
[
|
|
1332
|
-
|
|
1423
|
+
[
|
|
1424
|
+
__1.EventName.securityDefinitionOptionParameter,
|
|
1425
|
+
this.onSecurityDefinitionOptionParameter,
|
|
1426
|
+
],
|
|
1427
|
+
[
|
|
1428
|
+
__1.EventName.securityDefinitionOptionParameterEnd,
|
|
1429
|
+
this.onSecurityDefinitionOptionParameterEnd,
|
|
1430
|
+
],
|
|
1333
1431
|
])
|
|
1334
1432
|
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1335
1433
|
defaultValue: [],
|
|
@@ -1428,7 +1526,6 @@ class IBApiNext {
|
|
|
1428
1526
|
[__1.EventName.tickGeneric, this.onTick],
|
|
1429
1527
|
[__1.EventName.tickOptionComputation, this.onTickOptionComputation],
|
|
1430
1528
|
[__1.EventName.tickSnapshotEnd, this.onTickSnapshotEnd],
|
|
1431
|
-
// [EventName.error, this.onMarketDataError]
|
|
1432
1529
|
], snapshot || regulatorySnapshot
|
|
1433
1530
|
? undefined
|
|
1434
1531
|
: `${JSON.stringify(contract)}:${genericTickList}`);
|
|
@@ -1635,12 +1732,19 @@ class IBApiNext {
|
|
|
1635
1732
|
return (0, rxjs_1.lastValueFrom)(this.subscriptions
|
|
1636
1733
|
.register(() => {
|
|
1637
1734
|
this.api.reqMktDepthExchanges();
|
|
1638
|
-
}, undefined, [[__1.EventName.mktDepthExchanges, this.onMktDepthExchanges]], "
|
|
1639
|
-
)
|
|
1735
|
+
}, undefined, [[__1.EventName.mktDepthExchanges, this.onMktDepthExchanges]], "getMarketDepthExchanges")
|
|
1640
1736
|
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1641
1737
|
defaultValue: [],
|
|
1642
1738
|
});
|
|
1643
1739
|
}
|
|
1740
|
+
// mutable
|
|
1741
|
+
insertAtMapIndex(index, key, value, map) {
|
|
1742
|
+
const arr = Array.from(map);
|
|
1743
|
+
arr.splice(index, 0, [key, value]);
|
|
1744
|
+
map.clear();
|
|
1745
|
+
arr.forEach(([k, v]) => map.set(k, v));
|
|
1746
|
+
return map;
|
|
1747
|
+
}
|
|
1644
1748
|
/**
|
|
1645
1749
|
* Requests the contract's market depth (order book).
|
|
1646
1750
|
*
|
|
@@ -1664,6 +1768,35 @@ class IBApiNext {
|
|
|
1664
1768
|
[__1.EventName.updateMktDepthL2, this.onUpdateMktDepthL2],
|
|
1665
1769
|
], `${JSON.stringify(contract)}:${numRows}:${isSmartDepth}:${mktDepthOptions}`);
|
|
1666
1770
|
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Requests an XML string that describes all possible scanner queries.
|
|
1773
|
+
*/
|
|
1774
|
+
getScannerParameters() {
|
|
1775
|
+
return (0, rxjs_1.lastValueFrom)(this.subscriptions
|
|
1776
|
+
.register(() => {
|
|
1777
|
+
this.api.reqScannerParameters();
|
|
1778
|
+
}, undefined, [[__1.EventName.scannerParameters, this.onScannerParameters]], "getScannerParameters")
|
|
1779
|
+
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1780
|
+
defaultValue: "",
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* It returns an observable that will emit a list of scanner subscriptions.
|
|
1785
|
+
* @param {ScannerSubscription} scannerSubscription - ScannerSubscription
|
|
1786
|
+
* @param {TagValue[]} [scannerSubscriptionOptions] - An array of TagValue objects.
|
|
1787
|
+
* @param {TagValue[]} [scannerSubscriptionFilterOptions] - An optional array of TagValue objects.
|
|
1788
|
+
* @returns An observable that will emit a list of items.
|
|
1789
|
+
*/
|
|
1790
|
+
getMarketScanner(scannerSubscription, scannerSubscriptionOptions, scannerSubscriptionFilterOptions) {
|
|
1791
|
+
return this.subscriptions.register((reqId) => {
|
|
1792
|
+
this.api.reqScannerSubscription(reqId, scannerSubscription, scannerSubscriptionOptions, scannerSubscriptionFilterOptions);
|
|
1793
|
+
}, (reqId) => {
|
|
1794
|
+
this.api.cancelScannerSubscription(reqId);
|
|
1795
|
+
}, [
|
|
1796
|
+
[__1.EventName.scannerData, this.onScannerData],
|
|
1797
|
+
[__1.EventName.scannerDataEnd, this.onScannerDataEnd],
|
|
1798
|
+
], `getMarketScanner-${JSON.stringify(scannerSubscription)}`);
|
|
1799
|
+
}
|
|
1667
1800
|
/**
|
|
1668
1801
|
* Get data histogram of specified contract.
|
|
1669
1802
|
*
|
|
@@ -1695,8 +1828,7 @@ class IBApiNext {
|
|
|
1695
1828
|
[__1.EventName.orderStatus, this.onOrderStatus],
|
|
1696
1829
|
[__1.EventName.orderBound, this.onOrderBound],
|
|
1697
1830
|
[__1.EventName.openOrderEnd, this.onOpenOrderEnd],
|
|
1698
|
-
], "getAllOpenOrders"
|
|
1699
|
-
)
|
|
1831
|
+
], "getAllOpenOrders")
|
|
1700
1832
|
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1701
1833
|
defaultValue: [],
|
|
1702
1834
|
});
|
|
@@ -1706,15 +1838,13 @@ class IBApiNext {
|
|
|
1706
1838
|
* For client ID 0, this will bind previous manual TWS orders.
|
|
1707
1839
|
*/
|
|
1708
1840
|
getOpenOrders() {
|
|
1709
|
-
return this.subscriptions
|
|
1710
|
-
.register(() => {
|
|
1841
|
+
return this.subscriptions.register(() => {
|
|
1711
1842
|
this.api.reqOpenOrders();
|
|
1712
1843
|
}, undefined, [
|
|
1713
1844
|
[__1.EventName.openOrder, this.onOpenOrder],
|
|
1714
1845
|
[__1.EventName.orderStatus, this.onOrderStatus],
|
|
1715
1846
|
[__1.EventName.orderBound, this.onOrderBound],
|
|
1716
|
-
], "getOpenOrders"
|
|
1717
|
-
);
|
|
1847
|
+
], "getOpenOrders");
|
|
1718
1848
|
}
|
|
1719
1849
|
/**
|
|
1720
1850
|
* Requests status updates AND (IB documentation not correct on this point) future orders placed from TWS. Can only be used with client ID 0.
|
|
@@ -1731,8 +1861,7 @@ class IBApiNext {
|
|
|
1731
1861
|
[__1.EventName.openOrder, this.onOpenOrder],
|
|
1732
1862
|
[__1.EventName.orderStatus, this.onOrderStatus],
|
|
1733
1863
|
[__1.EventName.orderBound, this.onOrderBound],
|
|
1734
|
-
], "getAutoOpenOrders"
|
|
1735
|
-
);
|
|
1864
|
+
], "getAutoOpenOrders");
|
|
1736
1865
|
}
|
|
1737
1866
|
/**
|
|
1738
1867
|
* Requests the next valid order ID at the current moment.
|
|
@@ -1844,6 +1973,18 @@ class IBApiNext {
|
|
|
1844
1973
|
}, undefined, [[__1.EventName.symbolSamples, this.onSymbolSamples]])
|
|
1845
1974
|
.pipe((0, operators_1.map)((v) => v.all)));
|
|
1846
1975
|
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Get the user info of the logged user.
|
|
1978
|
+
*/
|
|
1979
|
+
getUserInfo() {
|
|
1980
|
+
return (0, rxjs_1.lastValueFrom)(this.subscriptions
|
|
1981
|
+
.register((reqId) => {
|
|
1982
|
+
this.api.reqUserInfo(reqId);
|
|
1983
|
+
}, undefined, [[__1.EventName.userInfo, this.onUserInfo]], "getUserInfo")
|
|
1984
|
+
.pipe((0, operators_1.map)((v) => v.all)), {
|
|
1985
|
+
defaultValue: undefined,
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1847
1988
|
}
|
|
1848
1989
|
exports.IBApiNext = IBApiNext;
|
|
1849
1990
|
//# sourceMappingURL=api-next.js.map
|