@stoqey/ib 1.3.5 → 1.3.7

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.
Files changed (141) hide show
  1. package/dist/api/api.d.ts +16 -3
  2. package/dist/api/api.js +13 -2
  3. package/dist/api/api.js.map +1 -1
  4. package/dist/api/contract/cfd.js +2 -3
  5. package/dist/api/contract/cfd.js.map +1 -1
  6. package/dist/api/contract/combo.js +2 -3
  7. package/dist/api/contract/combo.js.map +1 -1
  8. package/dist/api/contract/fop.js +3 -4
  9. package/dist/api/contract/fop.js.map +1 -1
  10. package/dist/api/contract/ind.js +2 -3
  11. package/dist/api/contract/ind.js.map +1 -1
  12. package/dist/api/contract/option.js +2 -3
  13. package/dist/api/contract/option.js.map +1 -1
  14. package/dist/api/contract/stock.js +2 -3
  15. package/dist/api/contract/stock.js.map +1 -1
  16. package/dist/api/data/enum/event-name.d.ts +3 -1
  17. package/dist/api/data/enum/event-name.js +2 -0
  18. package/dist/api/data/enum/event-name.js.map +1 -1
  19. package/dist/api/data/enum/min-server-version.js +3 -2
  20. package/dist/api/data/enum/min-server-version.js.map +1 -1
  21. package/dist/api/order/market.js +3 -4
  22. package/dist/api/order/market.js.map +1 -1
  23. package/dist/api/order/stop.js +3 -4
  24. package/dist/api/order/stop.js.map +1 -1
  25. package/dist/api/order/stopLimit.js +3 -4
  26. package/dist/api/order/stopLimit.js.map +1 -1
  27. package/dist/api/order/trailingStop.js +3 -4
  28. package/dist/api/order/trailingStop.js.map +1 -1
  29. package/dist/api-next/account/account-summary.d.ts +5 -5
  30. package/dist/api-next/account/account-update.d.ts +1 -1
  31. package/dist/api-next/api-next.d.ts +8 -2
  32. package/dist/api-next/api-next.js +148 -113
  33. package/dist/api-next/api-next.js.map +1 -1
  34. package/dist/api-next/common/common-types.d.ts +3 -3
  35. package/dist/api-next/common/error.d.ts +2 -0
  36. package/dist/api-next/contract/contract-details-update.d.ts +1 -1
  37. package/dist/api-next/market/market-data.d.ts +2 -2
  38. package/dist/api-next/market-depth/order-book.d.ts +3 -3
  39. package/dist/api-next/order/open-order-update.d.ts +1 -1
  40. package/dist/api-next/order/open-order.d.ts +1 -1
  41. package/dist/api-next/position/position.d.ts +2 -2
  42. package/dist/common/configuration.js +10 -3
  43. package/dist/common/configuration.js.map +1 -1
  44. package/dist/common/errorCode.js +3 -2
  45. package/dist/common/errorCode.js.map +1 -1
  46. package/dist/common/logger.js +15 -8
  47. package/dist/common/logger.js.map +1 -1
  48. package/dist/core/api-next/auto-connection.js +7 -3
  49. package/dist/core/api-next/auto-connection.js.map +1 -1
  50. package/dist/core/api-next/console-logger.js +5 -1
  51. package/dist/core/api-next/console-logger.js.map +1 -1
  52. package/dist/core/api-next/subscription-registry.d.ts +2 -2
  53. package/dist/core/api-next/subscription-registry.js +1 -2
  54. package/dist/core/api-next/subscription-registry.js.map +1 -1
  55. package/dist/core/api-next/subscription.js +2 -3
  56. package/dist/core/api-next/subscription.js.map +1 -1
  57. package/dist/core/io/controller.js +5 -7
  58. package/dist/core/io/controller.js.map +1 -1
  59. package/dist/core/io/decoder.d.ts +9 -5
  60. package/dist/core/io/decoder.js +38 -22
  61. package/dist/core/io/decoder.js.map +1 -1
  62. package/dist/core/io/encoder.d.ts +1 -0
  63. package/dist/core/io/encoder.js +31 -27
  64. package/dist/core/io/encoder.js.map +1 -1
  65. package/dist/core/io/enum/in-msg-id.d.ts +2 -1
  66. package/dist/core/io/enum/in-msg-id.js +1 -0
  67. package/dist/core/io/enum/in-msg-id.js.map +1 -1
  68. package/dist/core/io/socket.js +15 -15
  69. package/dist/core/io/socket.js.map +1 -1
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.js +5 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/tests/unit/api/api.test.js +31 -54
  74. package/dist/tests/unit/api/api.test.js.map +1 -1
  75. package/dist/tests/unit/api/connect.test.js +40 -14
  76. package/dist/tests/unit/api/connect.test.js.map +1 -1
  77. package/dist/tests/unit/api/market-data.test.d.ts +1 -0
  78. package/dist/tests/unit/api/market-data.test.js +84 -0
  79. package/dist/tests/unit/api/market-data.test.js.map +1 -0
  80. package/dist/tests/unit/api/order/placeOrder.test.js +91 -24
  81. package/dist/tests/unit/api/order/placeOrder.test.js.map +1 -1
  82. package/dist/tests/unit/api/order/reqAllOpenOrders.test.js +22 -23
  83. package/dist/tests/unit/api/order/reqAllOpenOrders.test.js.map +1 -1
  84. package/dist/tests/unit/api-next/get-account-summary.test.js +22 -25
  85. package/dist/tests/unit/api-next/get-account-summary.test.js.map +1 -1
  86. package/dist/tests/unit/api-next/get-contract-details.test.js +1 -1
  87. package/dist/tests/unit/api-next/get-contract-details.test.js.map +1 -1
  88. package/dist/tests/unit/api-next/get-market-data.test.js +2 -2
  89. package/dist/tests/unit/api-next/get-market-data.test.js.map +1 -1
  90. package/dist/tests/unit/api-next/get-positions.test.js +8 -9
  91. package/dist/tests/unit/api-next/get-positions.test.js.map +1 -1
  92. package/dist/tests/unit/api-next/place-order.test.js +3 -3
  93. package/dist/tests/unit/api-next/place-order.test.js.map +1 -1
  94. package/dist/tests/unit/api-next/search-contracts.test.js +2 -2
  95. package/dist/tests/unit/api-next/search-contracts.test.js.map +1 -1
  96. package/dist/tools/account-summary.js +2 -4
  97. package/dist/tools/account-summary.js.map +1 -1
  98. package/dist/tools/common/ib-api-next-app.d.ts +4 -0
  99. package/dist/tools/common/ib-api-next-app.js +43 -12
  100. package/dist/tools/common/ib-api-next-app.js.map +1 -1
  101. package/dist/tools/contract-details.js +2 -26
  102. package/dist/tools/contract-details.js.map +1 -1
  103. package/dist/tools/get-head-timestamp.js +2 -26
  104. package/dist/tools/get-head-timestamp.js.map +1 -1
  105. package/dist/tools/historical-data-updates.js +1 -2
  106. package/dist/tools/historical-data-updates.js.map +1 -1
  107. package/dist/tools/historical-ticks-bid-ask.js +2 -3
  108. package/dist/tools/historical-ticks-bid-ask.js.map +1 -1
  109. package/dist/tools/historical-ticks-last.js +3 -5
  110. package/dist/tools/historical-ticks-last.js.map +1 -1
  111. package/dist/tools/historical-ticks-mid.js +2 -3
  112. package/dist/tools/historical-ticks-mid.js.map +1 -1
  113. package/dist/tools/{market-data-single.js → market-data-snapshot.js} +9 -35
  114. package/dist/tools/market-data-snapshot.js.map +1 -0
  115. package/dist/tools/market-data.js +7 -40
  116. package/dist/tools/market-data.js.map +1 -1
  117. package/dist/tools/market-depth.js +2 -4
  118. package/dist/tools/market-depth.js.map +1 -1
  119. package/dist/tools/modify-order.js +1 -2
  120. package/dist/tools/modify-order.js.map +1 -1
  121. package/dist/tools/open-orders-auto.js +1 -2
  122. package/dist/tools/open-orders-auto.js.map +1 -1
  123. package/dist/tools/open-orders.js +4 -2
  124. package/dist/tools/open-orders.js.map +1 -1
  125. package/dist/tools/place-order.d.ts +1 -1
  126. package/dist/tools/place-order.js +23 -19
  127. package/dist/tools/place-order.js.map +1 -1
  128. package/dist/tools/pnl-single.js +1 -2
  129. package/dist/tools/pnl-single.js.map +1 -1
  130. package/dist/tools/pnl.js +1 -2
  131. package/dist/tools/pnl.js.map +1 -1
  132. package/dist/tools/positions.js +1 -2
  133. package/dist/tools/positions.js.map +1 -1
  134. package/dist/tools/sec-def-opt-params.js +1 -2
  135. package/dist/tools/sec-def-opt-params.js.map +1 -1
  136. package/dist/tools/user-info.d.ts +4 -0
  137. package/dist/tools/user-info.js +52 -0
  138. package/dist/tools/user-info.js.map +1 -0
  139. package/package.json +51 -53
  140. package/dist/tools/market-data-single.js.map +0 -1
  141. /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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : new mutable_account_summary_1.MutableAccountSummaries();
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : {};
143
- const cached = (_b = all === null || all === void 0 ? void 0 : all.value) !== null && _b !== void 0 ? _b : new mutable_account_summary_1.MutableAccountSummaries();
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 = { account, contract, pos, avgCost, marketPrice, marketValue, unrealizedPNL, realizedPNL };
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : {};
202
- const cached = (_b = all === null || all === void 0 ? void 0 : all.portfolio) !== null && _b !== void 0 ? _b : new mutable_account_positions_update_1.MutableAccountPositions();
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: { portfolio: new mutable_account_positions_update_1.MutableAccountPositions([[account, [updatedPosition]]]) },
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: { portfolio: new mutable_account_positions_update_1.MutableAccountPositions([[account, [updatedPosition]]]) },
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: { portfolio: new mutable_account_positions_update_1.MutableAccountPositions([[account, [updatedPosition]]]) },
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 = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : {};
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : new mutable_account_positions_update_1.MutableAccountPositions();
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : [];
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
- var _a;
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : [];
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
- var _a;
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : new mutable_market_data_1.MutableMarketData();
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 }], [_1.IBApiNextTickType.BID_OPTION_THETA, { value: theta, 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 }], [_1.IBApiNextTickType.ASK_OPTION_THETA, { value: theta, 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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : new mutable_market_data_1.MutableMarketData();
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
- var _a;
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : [];
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 = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : {};
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;
@@ -793,14 +805,13 @@ class IBApiNext {
793
805
  };
794
806
  /** marketDepthL2 event handler */
795
807
  this.onUpdateMktDepthL2 = (subscriptions, tickerId, position, marketMaker, operation, side, price, size, isSmartDepth) => {
796
- var _a;
797
808
  // get subscription
798
809
  const subscription = subscriptions.get(tickerId);
799
810
  if (!subscription) {
800
811
  return;
801
812
  }
802
813
  // update cached
803
- const cached = (_a = subscription.lastAllValue) !== null && _a !== void 0 ? _a : {
814
+ const cached = subscription.lastAllValue ?? {
804
815
  bids: new Map(),
805
816
  asks: new Map(),
806
817
  };
@@ -902,12 +913,17 @@ class IBApiNext {
902
913
  */
903
914
  this.onOpenOrder = (subscriptions, orderId, contract, order, orderState) => {
904
915
  subscriptions.forEach((sub) => {
905
- var _a;
906
- const allOrders = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
916
+ const allOrders = sub.lastAllValue ?? [];
907
917
  const changeOrderIndex = allOrders.findIndex((p) => p.order.permId == order.permId);
908
918
  if (changeOrderIndex === -1) {
909
919
  // new open order - add it
910
- const addedOrder = { orderId, contract, order, orderState, orderStatus: undefined };
920
+ const addedOrder = {
921
+ orderId,
922
+ contract,
923
+ order,
924
+ orderState,
925
+ orderStatus: undefined,
926
+ };
911
927
  allOrders.push(addedOrder);
912
928
  sub.next({
913
929
  all: allOrders,
@@ -959,7 +975,7 @@ class IBApiNext {
959
975
  * This is probably unused now.
960
976
  * Neither reqAllOpenOrders, reqAutoOpenOrders nor reqOpenOrders documentation reference this event.
961
977
  * Even getAutoOpenOrders(true) doesn't call it!
962
- */
978
+ */
963
979
  this.logger.warn(LOG_TAG, `Unexpected onOrderBound(${orderId}, ${apiClientId}, ${apiOrderId}) called.`);
964
980
  };
965
981
  /**
@@ -990,15 +1006,14 @@ class IBApiNext {
990
1006
  lastFillPrice: undefined,
991
1007
  clientId,
992
1008
  whyHeld,
993
- mktCapPrice
1009
+ mktCapPrice,
994
1010
  };
995
1011
  if (filled) {
996
1012
  orderStatus.avgFillPrice = avgFillPrice;
997
1013
  orderStatus.lastFillPrice = lastFillPrice;
998
1014
  }
999
1015
  subscriptions.forEach((sub) => {
1000
- var _a;
1001
- const allOrders = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
1016
+ const allOrders = sub.lastAllValue ?? [];
1002
1017
  const changeOrderIndex = allOrders.findIndex((p) => p.order.permId == permId);
1003
1018
  if (changeOrderIndex !== -1) {
1004
1019
  const updatedOrder = allOrders[changeOrderIndex];
@@ -1042,8 +1057,7 @@ class IBApiNext {
1042
1057
  */
1043
1058
  this.onExecDetails = (subscriptions, reqId, contract, execution) => {
1044
1059
  subscriptions.forEach((sub) => {
1045
- var _a;
1046
- const allTrades = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
1060
+ const allTrades = sub.lastAllValue ?? [];
1047
1061
  allTrades.push({ reqId, contract, execution });
1048
1062
  sub.next({
1049
1063
  all: allTrades,
@@ -1067,8 +1081,7 @@ class IBApiNext {
1067
1081
  /** comissionReport event handler. */
1068
1082
  this.onComissionReport = (subscriptions, commissionReport) => {
1069
1083
  subscriptions.forEach((sub) => {
1070
- var _a;
1071
- const commissionReports = (_a = sub.lastAllValue) !== null && _a !== void 0 ? _a : [];
1084
+ const commissionReports = sub.lastAllValue ?? [];
1072
1085
  commissionReports.push(commissionReport);
1073
1086
  sub.next({
1074
1087
  all: commissionReports,
@@ -1079,24 +1092,37 @@ class IBApiNext {
1079
1092
  this.onSymbolSamples = (subscriptions, reqId, contractDescriptions) => {
1080
1093
  const sub = subscriptions.get(reqId);
1081
1094
  subscriptions.delete(reqId);
1082
- sub === null || sub === void 0 ? void 0 : sub.next({
1095
+ sub?.next({
1083
1096
  all: contractDescriptions,
1084
1097
  });
1085
- sub === null || sub === void 0 ? void 0 : sub.complete();
1098
+ sub?.complete();
1099
+ };
1100
+ /** userInfo event handler. */
1101
+ this.onUserInfo = (subscriptions, reqId, whiteBrandingId) => {
1102
+ const sub = subscriptions.get(reqId);
1103
+ subscriptions.delete(reqId);
1104
+ sub?.next({
1105
+ all: whiteBrandingId,
1106
+ });
1107
+ sub?.complete();
1086
1108
  };
1087
- this.logger = new logger_1.IBApiNextLogger((_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : new console_logger_1.ConsoleLogger());
1109
+ this.logger = new logger_1.IBApiNextLogger(options?.logger ?? new console_logger_1.ConsoleLogger());
1088
1110
  // create the IBApiAutoConnection and subscription registry
1089
- this.api = new auto_connection_1.IBApiAutoConnection((_b = options === null || options === void 0 ? void 0 : options.reconnectInterval) !== null && _b !== void 0 ? _b : 0, ((_c = options === null || options === void 0 ? void 0 : options.connectionWatchdogInterval) !== null && _c !== void 0 ? _c : 0) * 1000, this.logger, options);
1111
+ this.api = new auto_connection_1.IBApiAutoConnection(options?.reconnectInterval ?? 0, (options?.connectionWatchdogInterval ?? 0) * 1000, this.logger, options);
1090
1112
  this.subscriptions = new subscription_registry_1.IBApiNextSubscriptionRegistry(this.api, this);
1091
1113
  // setup error event handler (bound to lifetime of IBApiAutoConnection so we never unregister)
1092
- this.api.on(__1.EventName.error, (error, code, reqId) => {
1093
- // console.log(reqId,'generic error ---',code, error,'---')
1094
- const apiError = { error, code, reqId };
1114
+ this.api.on(__1.EventName.error, (error, code, reqId, advancedOrderReject) => {
1115
+ const apiError = {
1116
+ error,
1117
+ code,
1118
+ reqId,
1119
+ advancedOrderReject,
1120
+ };
1095
1121
  // handle warnings - they are also reported on TWS error callback, but we DO NOT want to emit
1096
1122
  // it as error into the subject (and cancel the subscription).
1097
- if ((code >= 2100 && code < 3000)
1098
- || code === __1.ErrorCode.PART_OF_REQUESTED_DATA_NOT_SUBSCRIBED
1099
- || code === __1.ErrorCode.DISPLAYING_DELAYED_DATA) {
1123
+ if ((code >= 2100 && code < 3000) ||
1124
+ code === __1.ErrorCode.PART_OF_REQUESTED_DATA_NOT_SUBSCRIBED ||
1125
+ code === __1.ErrorCode.DISPLAYING_DELAYED_DATA) {
1100
1126
  this.logger.warn(TWS_LOG_TAG, `${error.message} - Code: ${code} - ReqId: ${reqId}`);
1101
1127
  return;
1102
1128
  }
@@ -1181,12 +1207,11 @@ class IBApiNext {
1181
1207
  * Get TWS's current time.
1182
1208
  */
1183
1209
  getCurrentTime() {
1184
- return rxjs_1.lastValueFrom(this.subscriptions
1210
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1185
1211
  .register(() => {
1186
1212
  this.api.reqCurrentTime();
1187
- }, undefined, [[__1.EventName.currentTime, this.onCurrentTime]], "reqCurrentTime" // use same instance id each time, to make sure there is only 1 pending request at time
1188
- )
1189
- .pipe(operators_1.map((v) => v.all)), {
1213
+ }, undefined, [[__1.EventName.currentTime, this.onCurrentTime]], "getCurrentTime")
1214
+ .pipe((0, operators_1.map)((v) => v.all)), {
1190
1215
  defaultValue: 0,
1191
1216
  });
1192
1217
  }
@@ -1194,12 +1219,11 @@ class IBApiNext {
1194
1219
  * Get the accounts to which the logged user has access to.
1195
1220
  */
1196
1221
  getManagedAccounts() {
1197
- return rxjs_1.lastValueFrom(this.subscriptions
1222
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1198
1223
  .register(() => {
1199
1224
  this.api.reqManagedAccts();
1200
- }, undefined, [[__1.EventName.managedAccounts, this.onManagedAccts]], "getManagedAccounts" // use same instance id each time, to make sure there is only 1 pending request at time
1201
- )
1202
- .pipe(operators_1.map((v) => v.all)), {
1225
+ }, undefined, [[__1.EventName.managedAccounts, this.onManagedAccts]], "getManagedAccounts")
1226
+ .pipe((0, operators_1.map)((v) => v.all)), {
1203
1227
  defaultValue: [],
1204
1228
  });
1205
1229
  }
@@ -1277,8 +1301,7 @@ class IBApiNext {
1277
1301
  [__1.EventName.updatePortfolio, this.onUpdatePortfolio],
1278
1302
  [__1.EventName.updateAccountTime, this.onUpdateAccountTime],
1279
1303
  [__1.EventName.accountDownloadEnd, this.onAccountDownloadEnd],
1280
- ], (acctCode ? `getAccountUpdates+${acctCode}` : "getAccountUpdates") // use same instance id each time, to make sure there is only 1 pending request at time
1281
- );
1304
+ ], acctCode ? `getAccountUpdates+${acctCode}` : "getAccountUpdates");
1282
1305
  }
1283
1306
  /**
1284
1307
  * Create subscription to receive the positions on all accessible accounts.
@@ -1302,14 +1325,14 @@ class IBApiNext {
1302
1325
  * @param contract The contract used as sample to query the available contracts.
1303
1326
  */
1304
1327
  getContractDetails(contract) {
1305
- return rxjs_1.lastValueFrom(this.subscriptions
1328
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1306
1329
  .register((reqId) => {
1307
1330
  this.api.reqContractDetails(reqId, contract);
1308
1331
  }, undefined, [
1309
1332
  [__1.EventName.contractDetails, this.onContractDetails],
1310
1333
  [__1.EventName.contractDetailsEnd, this.onContractDetailsEnd],
1311
1334
  ])
1312
- .pipe(operators_1.map((v) => v.all)), {
1335
+ .pipe((0, operators_1.map)((v) => v.all)), {
1313
1336
  defaultValue: [],
1314
1337
  });
1315
1338
  }
@@ -1324,14 +1347,20 @@ class IBApiNext {
1324
1347
  * @param underlyingConId the contract ID of the underlying security.
1325
1348
  */
1326
1349
  getSecDefOptParams(underlyingSymbol, futFopExchange, underlyingSecType, underlyingConId) {
1327
- return rxjs_1.lastValueFrom(this.subscriptions
1350
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1328
1351
  .register((reqId) => {
1329
1352
  this.api.reqSecDefOptParams(reqId, underlyingSymbol, futFopExchange, underlyingSecType, underlyingConId);
1330
1353
  }, undefined, [
1331
- [__1.EventName.securityDefinitionOptionParameter, this.onSecurityDefinitionOptionParameter],
1332
- [__1.EventName.securityDefinitionOptionParameterEnd, this.onSecurityDefinitionOptionParameterEnd],
1354
+ [
1355
+ __1.EventName.securityDefinitionOptionParameter,
1356
+ this.onSecurityDefinitionOptionParameter,
1357
+ ],
1358
+ [
1359
+ __1.EventName.securityDefinitionOptionParameterEnd,
1360
+ this.onSecurityDefinitionOptionParameterEnd,
1361
+ ],
1333
1362
  ])
1334
- .pipe(operators_1.map((v) => v.all)), {
1363
+ .pipe((0, operators_1.map)((v) => v.all)), {
1335
1364
  defaultValue: [],
1336
1365
  });
1337
1366
  }
@@ -1348,7 +1377,7 @@ class IBApiNext {
1348
1377
  }, (reqId) => {
1349
1378
  this.api.cancelPnL(reqId);
1350
1379
  }, [[__1.EventName.pnl, this.onPnL]], `${account}:${model}`)
1351
- .pipe(operators_1.map((v) => v.all));
1380
+ .pipe((0, operators_1.map)((v) => v.all));
1352
1381
  }
1353
1382
  /**
1354
1383
  * Create a subscription to receive real time updates for daily PnL of individual positions.
@@ -1364,7 +1393,7 @@ class IBApiNext {
1364
1393
  }, (reqId) => {
1365
1394
  this.api.cancelPnLSingle(reqId);
1366
1395
  }, [[__1.EventName.pnlSingle, this.onPnLSingle]], `${account}:${modelCode}:${conId}`)
1367
- .pipe(operators_1.map((v) => v.all));
1396
+ .pipe((0, operators_1.map)((v) => v.all));
1368
1397
  }
1369
1398
  /**
1370
1399
  * Switches data type returned from reqMktData request to "frozen", "delayed" or "delayed-frozen" market data.
@@ -1428,7 +1457,6 @@ class IBApiNext {
1428
1457
  [__1.EventName.tickGeneric, this.onTick],
1429
1458
  [__1.EventName.tickOptionComputation, this.onTickOptionComputation],
1430
1459
  [__1.EventName.tickSnapshotEnd, this.onTickSnapshotEnd],
1431
- // [EventName.error, this.onMarketDataError]
1432
1460
  ], snapshot || regulatorySnapshot
1433
1461
  ? undefined
1434
1462
  : `${JSON.stringify(contract)}:${genericTickList}`);
@@ -1447,7 +1475,7 @@ class IBApiNext {
1447
1475
  * One-time snapshot of current market price that will incur a fee of 1 cent to the account per snapshot.
1448
1476
  */
1449
1477
  getMarketDataSnapshot(contract, genericTickList, regulatorySnapshot) {
1450
- return rxjs_1.lastValueFrom(this.getMarketData(contract, genericTickList, true, regulatorySnapshot).pipe(operators_1.map((v) => v.all)), {
1478
+ return (0, rxjs_1.lastValueFrom)(this.getMarketData(contract, genericTickList, true, regulatorySnapshot).pipe((0, operators_1.map)((v) => v.all)), {
1451
1479
  defaultValue: new mutable_market_data_1.MutableMarketData(),
1452
1480
  });
1453
1481
  }
@@ -1460,13 +1488,13 @@ class IBApiNext {
1460
1488
  * @param formatDate Set to 1 to obtain the bars' time as yyyyMMdd HH:mm:ss, set to 2 to obtain it like system time format in seconds.
1461
1489
  */
1462
1490
  getHeadTimestamp(contract, whatToShow, useRTH, formatDate) {
1463
- return rxjs_1.lastValueFrom(this.subscriptions
1491
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1464
1492
  .register((reqId) => {
1465
1493
  this.api.reqHeadTimestamp(reqId, contract, whatToShow, useRTH, formatDate);
1466
1494
  }, (reqId) => {
1467
1495
  this.api.cancelHeadTimestamp(reqId);
1468
1496
  }, [[__1.EventName.headTimestamp, this.onHeadTimestamp]], `${JSON.stringify(contract)}:${whatToShow}:${useRTH}:${formatDate}`)
1469
- .pipe(operators_1.map((v) => v.all)), {
1497
+ .pipe((0, operators_1.map)((v) => v.all)), {
1470
1498
  defaultValue: "",
1471
1499
  });
1472
1500
  }
@@ -1519,11 +1547,11 @@ class IBApiNext {
1519
1547
  * @param formatDate Set to 1 to obtain the bars' time as yyyyMMdd HH:mm:ss, set to 2 to obtain it like system time format in seconds
1520
1548
  */
1521
1549
  getHistoricalData(contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate) {
1522
- return rxjs_1.lastValueFrom(this.subscriptions
1550
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1523
1551
  .register((reqId) => {
1524
1552
  this.api.reqHistoricalData(reqId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, false);
1525
1553
  }, undefined, [[__1.EventName.historicalData, this.onHistoricalData]], undefined)
1526
- .pipe(operators_1.map((v) => v.all)), {
1554
+ .pipe((0, operators_1.map)((v) => v.all)), {
1527
1555
  defaultValue: [],
1528
1556
  });
1529
1557
  }
@@ -1568,7 +1596,7 @@ class IBApiNext {
1568
1596
  }, (reqId) => {
1569
1597
  this.api.cancelHistoricalData(reqId);
1570
1598
  }, [[__1.EventName.historicalDataUpdate, this.onHistoricalDataUpdate]], `${JSON.stringify(contract)}:${barSizeSetting}:${whatToShow}:${formatDate}`)
1571
- .pipe(operators_1.map((v) => v.all));
1599
+ .pipe((0, operators_1.map)((v) => v.all));
1572
1600
  }
1573
1601
  /**
1574
1602
  * Create a subscription to receive historical mid prices from Time&Sales data of an instrument.
@@ -1587,7 +1615,7 @@ class IBApiNext {
1587
1615
  .register((reqId) => {
1588
1616
  this.api.reqHistoricalTicks(reqId, contract, startDateTime, endDateTime, numberOfTicks, "MIDPOINT", useRTH, false);
1589
1617
  }, undefined, [[__1.EventName.historicalTicks, this.onHistoricalTicks]], undefined)
1590
- .pipe(operators_1.map((v) => v.all));
1618
+ .pipe((0, operators_1.map)((v) => v.all));
1591
1619
  }
1592
1620
  /**
1593
1621
  * Create a subscription to receive historical bid and ask prices from Time&Sales data of an instrument.
@@ -1607,7 +1635,7 @@ class IBApiNext {
1607
1635
  .register((reqId) => {
1608
1636
  this.api.reqHistoricalTicks(reqId, contract, startDateTime, endDateTime, numberOfTicks, "BID_ASK", useRTH, ignoreSize);
1609
1637
  }, undefined, [[__1.EventName.historicalTicksBidAsk, this.onHistoricalTicksBidAsk]], undefined)
1610
- .pipe(operators_1.map((v) => v.all));
1638
+ .pipe((0, operators_1.map)((v) => v.all));
1611
1639
  }
1612
1640
  /**
1613
1641
  * Create a subscription to receive historical last trade prices from Time&Sales data of an instrument.
@@ -1626,18 +1654,17 @@ class IBApiNext {
1626
1654
  .register((reqId) => {
1627
1655
  this.api.reqHistoricalTicks(reqId, contract, startDateTime, endDateTime, numberOfTicks, "TRADES", useRTH, false);
1628
1656
  }, undefined, [[__1.EventName.historicalTicksLast, this.onHistoricalTicksLast]], undefined)
1629
- .pipe(operators_1.map((v) => v.all));
1657
+ .pipe((0, operators_1.map)((v) => v.all));
1630
1658
  }
1631
1659
  /**
1632
1660
  * Get venues for which market data is returned on getMarketDepthL2 (those with market makers).
1633
1661
  */
1634
1662
  getMarketDepthExchanges() {
1635
- return rxjs_1.lastValueFrom(this.subscriptions
1663
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1636
1664
  .register(() => {
1637
1665
  this.api.reqMktDepthExchanges();
1638
- }, undefined, [[__1.EventName.mktDepthExchanges, this.onMktDepthExchanges]], "reqMktDepthExchanges" // use same instance id each time, to make sure there is only 1 pending request at time
1639
- )
1640
- .pipe(operators_1.map((v) => v.all)), {
1666
+ }, undefined, [[__1.EventName.mktDepthExchanges, this.onMktDepthExchanges]], "getMarketDepthExchanges")
1667
+ .pipe((0, operators_1.map)((v) => v.all)), {
1641
1668
  defaultValue: [],
1642
1669
  });
1643
1670
  }
@@ -1673,13 +1700,13 @@ class IBApiNext {
1673
1700
  * @param durationUnit Duration unit of which data is being requested
1674
1701
  */
1675
1702
  getHistogramData(contract, useRTH, duration, durationUnit) {
1676
- return rxjs_1.lastValueFrom(this.subscriptions
1703
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1677
1704
  .register((reqId) => {
1678
1705
  this.api.reqHistogramData(reqId, contract, useRTH, duration, durationUnit);
1679
1706
  }, (reqId) => {
1680
1707
  this.api.cancelHistogramData(reqId);
1681
1708
  }, [[__1.EventName.histogramData, this.onHistogramData]], `${JSON.stringify(contract)}:${useRTH}:${duration}:${durationUnit}`)
1682
- .pipe(operators_1.map((v) => v.all)), {
1709
+ .pipe((0, operators_1.map)((v) => v.all)), {
1683
1710
  defaultValue: [],
1684
1711
  });
1685
1712
  }
@@ -1687,7 +1714,7 @@ class IBApiNext {
1687
1714
  * Requests all current open orders in associated accounts at the current moment.
1688
1715
  */
1689
1716
  getAllOpenOrders() {
1690
- return rxjs_1.lastValueFrom(this.subscriptions
1717
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1691
1718
  .register(() => {
1692
1719
  this.api.reqAllOpenOrders();
1693
1720
  }, undefined, [
@@ -1695,9 +1722,8 @@ class IBApiNext {
1695
1722
  [__1.EventName.orderStatus, this.onOrderStatus],
1696
1723
  [__1.EventName.orderBound, this.onOrderBound],
1697
1724
  [__1.EventName.openOrderEnd, this.onOpenOrderEnd],
1698
- ], "getAllOpenOrders" // use same instance id each time, to make sure there is only 1 pending request at time
1699
- )
1700
- .pipe(operators_1.map((v) => v.all)), {
1725
+ ], "getAllOpenOrders")
1726
+ .pipe((0, operators_1.map)((v) => v.all)), {
1701
1727
  defaultValue: [],
1702
1728
  });
1703
1729
  }
@@ -1706,15 +1732,13 @@ class IBApiNext {
1706
1732
  * For client ID 0, this will bind previous manual TWS orders.
1707
1733
  */
1708
1734
  getOpenOrders() {
1709
- return this.subscriptions
1710
- .register(() => {
1735
+ return this.subscriptions.register(() => {
1711
1736
  this.api.reqOpenOrders();
1712
1737
  }, undefined, [
1713
1738
  [__1.EventName.openOrder, this.onOpenOrder],
1714
1739
  [__1.EventName.orderStatus, this.onOrderStatus],
1715
1740
  [__1.EventName.orderBound, this.onOrderBound],
1716
- ], "getOpenOrders" // use same instance id each time, to make sure there is only 1 pending request at time
1717
- );
1741
+ ], "getOpenOrders");
1718
1742
  }
1719
1743
  /**
1720
1744
  * 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,18 +1755,17 @@ class IBApiNext {
1731
1755
  [__1.EventName.openOrder, this.onOpenOrder],
1732
1756
  [__1.EventName.orderStatus, this.onOrderStatus],
1733
1757
  [__1.EventName.orderBound, this.onOrderBound],
1734
- ], "getAutoOpenOrders" // use same instance id each time, to make sure there is only 1 pending request at time
1735
- );
1758
+ ], "getAutoOpenOrders");
1736
1759
  }
1737
1760
  /**
1738
1761
  * Requests the next valid order ID at the current moment.
1739
1762
  */
1740
1763
  getNextValidOrderId() {
1741
- return rxjs_1.lastValueFrom(this.subscriptions
1764
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1742
1765
  .register(() => {
1743
1766
  this.api.reqIds();
1744
1767
  }, undefined, [[__1.EventName.nextValidId, this.onNextValidId]])
1745
- .pipe(operators_1.map((v) => v.all)), {
1768
+ .pipe((0, operators_1.map)((v) => v.all)), {
1746
1769
  defaultValue: -1,
1747
1770
  });
1748
1771
  }
@@ -1805,14 +1828,14 @@ class IBApiNext {
1805
1828
  * @param filter filter trade data on [[ExecutionFilter]]
1806
1829
  */
1807
1830
  getExecutionDetails(filter) {
1808
- return rxjs_1.lastValueFrom(this.subscriptions
1831
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1809
1832
  .register((reqId) => {
1810
1833
  this.api.reqExecutions(reqId, filter);
1811
1834
  }, undefined, [
1812
1835
  [__1.EventName.execDetails, this.onExecDetails],
1813
1836
  [__1.EventName.execDetailsEnd, this.onExecDetailsEnd],
1814
1837
  ])
1815
- .pipe(operators_1.map((v) => v.all)), {
1838
+ .pipe((0, operators_1.map)((v) => v.all)), {
1816
1839
  defaultValue: [],
1817
1840
  });
1818
1841
  }
@@ -1821,14 +1844,14 @@ class IBApiNext {
1821
1844
  * @param filter filter trade data on [[ExecutionFilter]]
1822
1845
  */
1823
1846
  getCommissionReport(filter) {
1824
- return rxjs_1.lastValueFrom(this.subscriptions
1847
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1825
1848
  .register((reqId) => {
1826
1849
  this.api.reqExecutions(reqId, filter);
1827
1850
  }, undefined, [
1828
1851
  [__1.EventName.execDetailsEnd, this.onExecDetailsEnd],
1829
1852
  [__1.EventName.commissionReport, this.onComissionReport],
1830
1853
  ])
1831
- .pipe(operators_1.map((v) => v.all)), {
1854
+ .pipe((0, operators_1.map)((v) => v.all)), {
1832
1855
  defaultValue: [],
1833
1856
  });
1834
1857
  }
@@ -1838,11 +1861,23 @@ class IBApiNext {
1838
1861
  * @param pattern Either start of ticker symbol or (for larger strings) company name.
1839
1862
  */
1840
1863
  searchContracts(pattern) {
1841
- return rxjs_1.lastValueFrom(this.subscriptions
1864
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1842
1865
  .register((reqId) => {
1843
1866
  this.api.reqMatchingSymbols(reqId, pattern);
1844
1867
  }, undefined, [[__1.EventName.symbolSamples, this.onSymbolSamples]])
1845
- .pipe(operators_1.map((v) => v.all)));
1868
+ .pipe((0, operators_1.map)((v) => v.all)));
1869
+ }
1870
+ /**
1871
+ * Get the user info of the logged user.
1872
+ */
1873
+ getUserInfo() {
1874
+ return (0, rxjs_1.lastValueFrom)(this.subscriptions
1875
+ .register((reqId) => {
1876
+ this.api.reqUserInfo(reqId);
1877
+ }, undefined, [[__1.EventName.userInfo, this.onUserInfo]], "getUserInfo")
1878
+ .pipe((0, operators_1.map)((v) => v.all)), {
1879
+ defaultValue: undefined,
1880
+ });
1846
1881
  }
1847
1882
  }
1848
1883
  exports.IBApiNext = IBApiNext;