@stoqey/ib 1.3.29 → 1.4.0

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 (87) hide show
  1. package/README.md +1 -1
  2. package/dist/api/api.d.ts +2 -2
  3. package/dist/api/api.js +22 -3
  4. package/dist/api/api.js.map +1 -1
  5. package/dist/api/contract/priceIncrement.d.ts +7 -0
  6. package/dist/api/contract/priceIncrement.js +3 -0
  7. package/dist/api/contract/priceIncrement.js.map +1 -0
  8. package/dist/api/order/orderCancel.d.ts +1 -1
  9. package/dist/api-next/api-next.d.ts +24 -4
  10. package/dist/api-next/api-next.js +69 -48
  11. package/dist/api-next/api-next.js.map +1 -1
  12. package/dist/common/configuration.js +17 -7
  13. package/dist/common/configuration.js.map +1 -1
  14. package/dist/common/errorCode.d.ts +9 -3
  15. package/dist/common/errorCode.js +26 -5
  16. package/dist/common/errorCode.js.map +1 -1
  17. package/dist/common/logger.js +17 -7
  18. package/dist/common/logger.js.map +1 -1
  19. package/dist/core/api-next/auto-connection.js +17 -7
  20. package/dist/core/api-next/auto-connection.js.map +1 -1
  21. package/dist/core/api-next/console-logger.js +17 -7
  22. package/dist/core/api-next/console-logger.js.map +1 -1
  23. package/dist/core/api-next/subscription-registry.d.ts +3 -4
  24. package/dist/core/api-next/subscription-registry.js +7 -8
  25. package/dist/core/api-next/subscription-registry.js.map +1 -1
  26. package/dist/core/api-next/subscription.js +5 -5
  27. package/dist/core/api-next/subscription.js.map +1 -1
  28. package/dist/core/io/controller.d.ts +1 -1
  29. package/dist/core/io/controller.js +3 -4
  30. package/dist/core/io/controller.js.map +1 -1
  31. package/dist/core/io/decoder.d.ts +1 -1
  32. package/dist/core/io/decoder.js +7 -7
  33. package/dist/core/io/decoder.js.map +1 -1
  34. package/dist/core/io/encoder.d.ts +16 -16
  35. package/dist/core/io/encoder.js +78 -82
  36. package/dist/core/io/encoder.js.map +1 -1
  37. package/dist/core/io/socket.js +15 -27
  38. package/dist/core/io/socket.js.map +1 -1
  39. package/dist/index.d.ts +2 -1
  40. package/dist/index.js +2 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/tests/unit/api/historical-data.test.js +34 -42
  43. package/dist/tests/unit/api/historical-data.test.js.map +1 -1
  44. package/dist/tests/unit/api/market-data.test.js +1 -1
  45. package/dist/tests/unit/api/market-data.test.js.map +1 -1
  46. package/dist/tests/unit/api/market-scanner.test.js +19 -27
  47. package/dist/tests/unit/api/market-scanner.test.js.map +1 -1
  48. package/dist/tests/unit/api/order/cancelOrder.test.js +162 -28
  49. package/dist/tests/unit/api/order/cancelOrder.test.js.map +1 -1
  50. package/dist/tests/unit/api/order/placeConditionalOrder.test.js +117 -179
  51. package/dist/tests/unit/api/order/placeConditionalOrder.test.js.map +1 -1
  52. package/dist/tests/unit/api/order/placeOrder.test.js +68 -92
  53. package/dist/tests/unit/api/order/placeOrder.test.js.map +1 -1
  54. package/dist/tests/unit/api-next/get-account-summary.test.js +1 -1
  55. package/dist/tests/unit/api-next/get-account-updates.test.d.ts +4 -0
  56. package/dist/tests/unit/api-next/get-account-updates.test.js +86 -0
  57. package/dist/tests/unit/api-next/get-account-updates.test.js.map +1 -0
  58. package/dist/tests/unit/api-next/get-historical-data.test.js +1 -1
  59. package/dist/tests/unit/api-next/get-historical-data.test.js.map +1 -1
  60. package/dist/tests/unit/api-next/next-valid-order-id.test.js +1 -1
  61. package/dist/tests/unit/api-next/next-valid-order-id.test.js.map +1 -1
  62. package/dist/tests/unit/api-next-live/get-contract-details.test.js +31 -36
  63. package/dist/tests/unit/api-next-live/get-contract-details.test.js.map +1 -1
  64. package/dist/tests/unit/api-next-live/get-current-time.test.d.ts +4 -0
  65. package/dist/tests/unit/api-next-live/get-current-time.test.js +64 -0
  66. package/dist/tests/unit/api-next-live/get-current-time.test.js.map +1 -0
  67. package/dist/tests/unit/api-next-live/get-historical-ticks.test.js +7 -3
  68. package/dist/tests/unit/api-next-live/get-historical-ticks.test.js.map +1 -1
  69. package/dist/tests/unit/api-next-live/get-managed-accounts.test.d.ts +4 -0
  70. package/dist/tests/unit/api-next-live/get-managed-accounts.test.js +48 -0
  71. package/dist/tests/unit/api-next-live/get-managed-accounts.test.js.map +1 -0
  72. package/dist/tests/unit/api-next-live/get-market-rule.test.d.ts +4 -0
  73. package/dist/tests/unit/api-next-live/get-market-rule.test.js +64 -0
  74. package/dist/tests/unit/api-next-live/get-market-rule.test.js.map +1 -0
  75. package/dist/tests/unit/api-next-live/get-user-info.test.d.ts +4 -0
  76. package/dist/tests/unit/api-next-live/get-user-info.test.js +50 -0
  77. package/dist/tests/unit/api-next-live/get-user-info.test.js.map +1 -0
  78. package/dist/tests/unit/api-next-live/subscription-registry.test.js +12 -8
  79. package/dist/tests/unit/api-next-live/subscription-registry.test.js.map +1 -1
  80. package/dist/tests/unit/sample-data/contracts.js +2 -2
  81. package/dist/tests/unit/sample-data/orders.d.ts +2 -0
  82. package/dist/tests/unit/sample-data/orders.js +16 -0
  83. package/dist/tests/unit/sample-data/orders.js.map +1 -0
  84. package/package.json +4 -4
  85. package/dist/tests/unit/api/order/issue203.test.d.ts +0 -1
  86. package/dist/tests/unit/api/order/issue203.test.js +0 -137
  87. package/dist/tests/unit/api/order/issue203.test.js.map +0 -1
@@ -156,7 +156,7 @@ class Encoder {
156
156
  * @param data Additional error data (optional).
157
157
  */
158
158
  emitError(errMsg, code, reqId) {
159
- this.callback.emitError(`Server Version ${this.serverVersion}: ${errMsg}`, code, reqId);
159
+ this.callback.emitError(`Server Version ${this.serverVersion}: ${errMsg}`, code, reqId ?? errorCode_1.ErrorCode.NO_VALID_ID);
160
160
  }
161
161
  /**
162
162
  * Encode a [[Contract]] to an array of tokens.
@@ -337,32 +337,32 @@ class Encoder {
337
337
  /**
338
338
  * Encode a CANCEL_HISTORICAL_DATA message to an array of tokens.
339
339
  */
340
- cancelHistoricalData(tickerId) {
340
+ cancelHistoricalData(reqId) {
341
341
  if (this.serverVersion < 24) {
342
- return this.emitError("It does not support historical data query cancellation.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
342
+ return this.emitError("It does not support historical data query cancellation.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
343
343
  }
344
344
  const version = 1;
345
- this.sendMsg(OUT_MSG_ID.CANCEL_HISTORICAL_DATA, version, tickerId);
345
+ this.sendMsg(OUT_MSG_ID.CANCEL_HISTORICAL_DATA, version, reqId);
346
346
  }
347
347
  /**
348
348
  * Encode a CANCEL_MKT_DATA message to an array of tokens.
349
349
  */
350
- cancelMktData(tickerId) {
350
+ cancelMktData(reqId) {
351
351
  const version = 1;
352
- this.sendMsg(OUT_MSG_ID.CANCEL_MKT_DATA, version, tickerId);
352
+ this.sendMsg(OUT_MSG_ID.CANCEL_MKT_DATA, version, reqId);
353
353
  }
354
354
  /**
355
355
  * Encode a CANCEL_MKT_DEPTH message to an array of tokens.
356
356
  */
357
- cancelMktDepth(tickerId, isSmartDepth) {
357
+ cancelMktDepth(reqId, isSmartDepth) {
358
358
  if (this.serverVersion < 6) {
359
- return this.emitError("This feature is only available for versions of TWS >=6.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
359
+ return this.emitError("This feature is only available for versions of TWS >=6.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
360
360
  }
361
361
  if (this.serverVersion < min_server_version_1.default.SMART_DEPTH && isSmartDepth) {
362
- return this.emitError("It does not support SMART depth cancel.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
362
+ return this.emitError("It does not support SMART depth cancel.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
363
363
  }
364
364
  const version = 1;
365
- const tokens = [OUT_MSG_ID.CANCEL_MKT_DEPTH, version, tickerId];
365
+ const tokens = [OUT_MSG_ID.CANCEL_MKT_DEPTH, version, reqId];
366
366
  if (this.serverVersion >= min_server_version_1.default.SMART_DEPTH) {
367
367
  tokens.push(isSmartDepth);
368
368
  }
@@ -380,12 +380,12 @@ class Encoder {
380
380
  */
381
381
  cancelOrder(orderId, orderCancel) {
382
382
  if (this.serverVersion < min_server_version_1.default.MANUAL_ORDER_TIME &&
383
- orderCancel?.manualOrderCancelTime.length) {
383
+ orderCancel.manualOrderCancelTime?.length) {
384
384
  return this.emitError("It does not support manual order cancel time attribute", errorCode_1.ErrorCode.UPDATE_TWS, orderId);
385
385
  }
386
386
  if (this.serverVersion < min_server_version_1.default.CME_TAGGING_FIELDS) {
387
- if ((orderCancel?.extOperator && orderCancel?.extOperator != "") ||
388
- orderCancel?.manualOrderIndicator) {
387
+ if (orderCancel.extOperator?.length ||
388
+ orderCancel.manualOrderIndicator != undefined) {
389
389
  return this.emitError("It does not support ext operator and manual order indicator parameters", errorCode_1.ErrorCode.UPDATE_TWS, orderId);
390
390
  }
391
391
  }
@@ -396,7 +396,7 @@ class Encoder {
396
396
  tokens.push(version);
397
397
  tokens.push(orderId);
398
398
  if (this.serverVersion >= min_server_version_1.default.MANUAL_ORDER_TIME)
399
- tokens.push(orderCancel?.manualOrderCancelTime);
399
+ tokens.push(orderCancel.manualOrderCancelTime);
400
400
  if (this.serverVersion >= min_server_version_1.default.RFQ_FIELDS &&
401
401
  this.serverVersion < min_server_version_1.default.UNDO_RFQ_FIELDS) {
402
402
  tokens.push("");
@@ -405,7 +405,7 @@ class Encoder {
405
405
  }
406
406
  if (this.serverVersion >= min_server_version_1.default.CME_TAGGING_FIELDS) {
407
407
  tokens.push(orderCancel.extOperator);
408
- tokens.push(orderCancel.manualOrderIndicator);
408
+ tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE);
409
409
  }
410
410
  this.sendMsg(tokens);
411
411
  }
@@ -414,7 +414,7 @@ class Encoder {
414
414
  */
415
415
  cancelPositions() {
416
416
  if (this.serverVersion < min_server_version_1.default.ACCT_SUMMARY) {
417
- return this.emitError("It does not support position cancellation.", errorCode_1.ErrorCode.UPDATE_TWS, -1);
417
+ return this.emitError("It does not support position cancellation.", errorCode_1.ErrorCode.UPDATE_TWS);
418
418
  }
419
419
  const version = 1;
420
420
  this.sendMsg(OUT_MSG_ID.CANCEL_POSITIONS, version);
@@ -422,51 +422,51 @@ class Encoder {
422
422
  /**
423
423
  * Encode a CANCEL_REAL_TIME_BARS message to an array of tokens.
424
424
  */
425
- cancelRealTimeBars(tickerId) {
425
+ cancelRealTimeBars(reqId) {
426
426
  if (this.serverVersion < min_server_version_1.default.REAL_TIME_BARS) {
427
- return this.emitError("It does not support realtime bar data query cancellation.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
427
+ return this.emitError("It does not support realtime bar data query cancellation.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
428
428
  }
429
429
  const version = 1;
430
- this.sendMsg(OUT_MSG_ID.CANCEL_REAL_TIME_BARS, version, tickerId);
430
+ this.sendMsg(OUT_MSG_ID.CANCEL_REAL_TIME_BARS, version, reqId);
431
431
  }
432
432
  /**
433
433
  * Encode a CANCEL_SCANNER_SUBSCRIPTION message to an array of tokens.
434
434
  */
435
- cancelScannerSubscription(tickerId) {
435
+ cancelScannerSubscription(reqId) {
436
436
  if (this.serverVersion < 24) {
437
- return this.emitError("It does not support API scanner subscription.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
437
+ return this.emitError("It does not support API scanner subscription.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
438
438
  }
439
439
  const version = 1;
440
- this.sendMsg(OUT_MSG_ID.CANCEL_SCANNER_SUBSCRIPTION, version, tickerId);
440
+ this.sendMsg(OUT_MSG_ID.CANCEL_SCANNER_SUBSCRIPTION, version, reqId);
441
441
  }
442
442
  /**
443
443
  * Encode a EXERCISE_OPTIONS message to an array of tokens.
444
444
  */
445
- exerciseOptions(tickerId, contract, exerciseAction, exerciseQuantity, account, override, manualOrderTime = "", customerAccount = "", professionalCustomer = false) {
445
+ exerciseOptions(reqId, contract, exerciseAction, exerciseQuantity, account, override, manualOrderTime = "", customerAccount = "", professionalCustomer = false) {
446
446
  const version = 2;
447
447
  if (this.serverVersion < 21) {
448
- return this.emitError("It does not support options exercise from the API.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
448
+ return this.emitError("It does not support options exercise from the API.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
449
449
  }
450
450
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
451
451
  if (!!contract.tradingClass || contract.conId != undefined) {
452
- return this.emitError("It does not support conId and tradingClass parameters in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
452
+ return this.emitError("It does not support conId and tradingClass parameters in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
453
453
  }
454
454
  }
455
455
  if (this.serverVersion < min_server_version_1.default.MANUAL_ORDER_TIME_EXERCISE_OPTIONS &&
456
456
  manualOrderTime) {
457
- return this.emitError("It does not support manual order time parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
457
+ return this.emitError("It does not support manual order time parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
458
458
  }
459
459
  if (this.serverVersion < min_server_version_1.default.CUSTOMER_ACCOUNT) {
460
460
  if (customerAccount) {
461
- return this.emitError("It does not support customer account parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
461
+ return this.emitError("It does not support customer account parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
462
462
  }
463
463
  }
464
464
  if (this.serverVersion < min_server_version_1.default.PROFESSIONAL_CUSTOMER) {
465
465
  if (professionalCustomer) {
466
- return this.emitError("It does not support professional customer parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
466
+ return this.emitError("It does not support professional customer parameter in exerciseOptions.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
467
467
  }
468
468
  }
469
- const tokens = [OUT_MSG_ID.EXERCISE_OPTIONS, version, tickerId];
469
+ const tokens = [OUT_MSG_ID.EXERCISE_OPTIONS, version, reqId];
470
470
  // send contract fields
471
471
  if (this.serverVersion >= min_server_version_1.default.TRADING_CLASS) {
472
472
  tokens.push(contract.conId);
@@ -1402,7 +1402,7 @@ class Encoder {
1402
1402
  */
1403
1403
  reqCurrentTime() {
1404
1404
  if (this.serverVersion < 33) {
1405
- return this.emitError("It does not support current time requests.", errorCode_1.ErrorCode.UPDATE_TWS, -1);
1405
+ return this.emitError("It does not support current time requests.", errorCode_1.ErrorCode.UPDATE_TWS);
1406
1406
  }
1407
1407
  const version = 1;
1408
1408
  this.sendMsg(OUT_MSG_ID.REQ_CURRENT_TIME, version);
@@ -1467,12 +1467,12 @@ class Encoder {
1467
1467
  */
1468
1468
  reqGlobalCancel(orderCancel) {
1469
1469
  if (this.serverVersion < min_server_version_1.default.REQ_GLOBAL_CANCEL) {
1470
- return this.emitError("It does not support globalCancel requests.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1470
+ return this.emitError("It does not support globalCancel requests.", errorCode_1.ErrorCode.UPDATE_TWS);
1471
1471
  }
1472
1472
  if (this.serverVersion < min_server_version_1.default.CME_TAGGING_FIELDS) {
1473
- if ((orderCancel?.extOperator && orderCancel?.extOperator != "") ||
1474
- orderCancel?.manualOrderIndicator) {
1475
- return this.emitError("It does not support ext operator and manual order indicator parameters", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1473
+ if (orderCancel.extOperator?.length ||
1474
+ orderCancel.manualOrderIndicator != undefined) {
1475
+ return this.emitError("It does not support ext operator and manual order indicator parameters", errorCode_1.ErrorCode.UPDATE_TWS);
1476
1476
  }
1477
1477
  }
1478
1478
  const version = 1;
@@ -1482,35 +1482,35 @@ class Encoder {
1482
1482
  tokens.push(version);
1483
1483
  }
1484
1484
  if (this.serverVersion >= min_server_version_1.default.CME_TAGGING_FIELDS) {
1485
- tokens.push(orderCancel?.extOperator);
1486
- tokens.push(orderCancel?.manualOrderIndicator);
1485
+ tokens.push(orderCancel.extOperator);
1486
+ tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE);
1487
1487
  }
1488
1488
  this.sendMsg(tokens);
1489
1489
  }
1490
1490
  /**
1491
1491
  * Encode a REQ_HISTORICAL_DATA message.
1492
1492
  */
1493
- reqHistoricalData(tickerId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate, chartOptions) {
1493
+ reqHistoricalData(reqId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate, chartOptions) {
1494
1494
  const version = 6;
1495
1495
  if (this.serverVersion < 16) {
1496
- return this.emitError("It does not support historical data backfill.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1496
+ return this.emitError("It does not support historical data backfill.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1497
1497
  }
1498
1498
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
1499
1499
  if (!!contract.tradingClass || contract.conId != undefined) {
1500
- return this.emitError("It does not support conId and tradingClass parameters in reqHistoricalData.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1500
+ return this.emitError("It does not support conId and tradingClass parameters in reqHistoricalData.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1501
1501
  }
1502
1502
  }
1503
1503
  if (this.serverVersion < min_server_version_1.default.HISTORICAL_SCHEDULE) {
1504
1504
  if (typeof whatToShow === "string" &&
1505
1505
  whatToShow.toUpperCase() === "SCHEDULE") {
1506
- return this.emitError("It does not support requesting of historical schedule.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1506
+ return this.emitError("It does not support requesting of historical schedule.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1507
1507
  }
1508
1508
  }
1509
1509
  const tokens = [OUT_MSG_ID.REQ_HISTORICAL_DATA];
1510
1510
  if (this.serverVersion < min_server_version_1.default.SYNT_REALTIME_BARS) {
1511
1511
  tokens.push(version);
1512
1512
  }
1513
- tokens.push(tickerId);
1513
+ tokens.push(reqId);
1514
1514
  // send contract fields
1515
1515
  if (this.serverVersion >= min_server_version_1.default.TRADING_CLASS) {
1516
1516
  tokens.push(contract.conId);
@@ -1566,13 +1566,13 @@ class Encoder {
1566
1566
  /**
1567
1567
  * Encode a REQ_HISTORICAL_TICKS message.
1568
1568
  */
1569
- reqHistoricalTicks(tickerId, contract, startDateTime, endDateTime, numberOfTicks, whatToShow, useRth, ignoreSize, miscOptions) {
1569
+ reqHistoricalTicks(reqId, contract, startDateTime, endDateTime, numberOfTicks, whatToShow, useRth, ignoreSize, miscOptions) {
1570
1570
  if (this.serverVersion < min_server_version_1.default.HISTORICAL_TICKS) {
1571
- return this.emitError("It does not support historical ticks request.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1571
+ return this.emitError("It does not support historical ticks request.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1572
1572
  }
1573
1573
  const args = [
1574
1574
  OUT_MSG_ID.REQ_HISTORICAL_TICKS,
1575
- tickerId,
1575
+ reqId,
1576
1576
  ...this.encodeContract(contract),
1577
1577
  ];
1578
1578
  args.push(startDateTime);
@@ -1649,7 +1649,7 @@ class Encoder {
1649
1649
  */
1650
1650
  reqMarketDataType(marketDataType) {
1651
1651
  if (this.serverVersion < min_server_version_1.default.REQ_MARKET_DATA_TYPE) {
1652
- return this.emitError("It does not support marketDataType requests.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1652
+ return this.emitError("It does not support marketDataType requests.", errorCode_1.ErrorCode.UPDATE_TWS);
1653
1653
  }
1654
1654
  const version = 1;
1655
1655
  this.sendMsg(OUT_MSG_ID.REQ_MARKET_DATA_TYPE, version, marketDataType);
@@ -1657,23 +1657,23 @@ class Encoder {
1657
1657
  /**
1658
1658
  * Encode a REQ_MKT_DATA message.
1659
1659
  */
1660
- reqMktData(tickerId, contract, genericTickList, snapshot, regulatorySnapshot) {
1660
+ reqMktData(reqId, contract, genericTickList, snapshot, regulatorySnapshot) {
1661
1661
  if (this.serverVersion < min_server_version_1.default.SNAPSHOT_MKT_DATA && snapshot) {
1662
- return this.emitError("It does not support snapshot market data requests.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1662
+ return this.emitError("It does not support snapshot market data requests.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1663
1663
  }
1664
1664
  if (this.serverVersion < min_server_version_1.default.DELTA_NEUTRAL) {
1665
- return this.emitError("It does not support delta-neutral orders.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1665
+ return this.emitError("It does not support delta-neutral orders.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1666
1666
  }
1667
1667
  if (this.serverVersion < min_server_version_1.default.REQ_MKT_DATA_CONID) {
1668
- return this.emitError("It does not support conId parameter.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1668
+ return this.emitError("It does not support conId parameter.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1669
1669
  }
1670
1670
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
1671
1671
  if (!!contract.tradingClass) {
1672
- return this.emitError("It does not support tradingClass parameter in reqMarketData.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1672
+ return this.emitError("It does not support tradingClass parameter in reqMarketData.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1673
1673
  }
1674
1674
  }
1675
1675
  const version = 11;
1676
- const args = [OUT_MSG_ID.REQ_MKT_DATA, version, tickerId];
1676
+ const args = [OUT_MSG_ID.REQ_MKT_DATA, version, reqId];
1677
1677
  // send contract fields
1678
1678
  if (this.serverVersion >= min_server_version_1.default.REQ_MKT_DATA_CONID) {
1679
1679
  args.push(contract.conId);
@@ -1747,25 +1747,25 @@ class Encoder {
1747
1747
  /**
1748
1748
  * Encode a REQ_MKT_DEPTH message.
1749
1749
  */
1750
- reqMktDepth(tickerId, contract, numRows, isSmartDepth, mktDepthOptions) {
1750
+ reqMktDepth(reqId, contract, numRows, isSmartDepth, mktDepthOptions) {
1751
1751
  if (this.serverVersion < 6) {
1752
- return this.emitError("This feature is only available for versions of TWS >=6", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1752
+ return this.emitError("This feature is only available for versions of TWS >=6", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1753
1753
  }
1754
1754
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
1755
1755
  if (!!contract.tradingClass || contract.conId != undefined) {
1756
- return this.emitError("It does not support conId and tradingClass parameters in reqMktDepth.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1756
+ return this.emitError("It does not support conId and tradingClass parameters in reqMktDepth.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1757
1757
  }
1758
1758
  }
1759
1759
  if (this.serverVersion < min_server_version_1.default.SMART_DEPTH && isSmartDepth) {
1760
- return this.emitError("It does not support SMART depth request.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1760
+ return this.emitError("It does not support SMART depth request.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1761
1761
  }
1762
1762
  if (this.serverVersion < min_server_version_1.default.MKT_DEPTH_PRIM_EXCHANGE &&
1763
1763
  !!contract.primaryExch) {
1764
- return this.emitError("It does not support primaryExch parameter in reqMktDepth.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1764
+ return this.emitError("It does not support primaryExch parameter in reqMktDepth.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1765
1765
  }
1766
1766
  const version = 5;
1767
1767
  // send req mkt data msg
1768
- const tokens = [OUT_MSG_ID.REQ_MKT_DEPTH, version, tickerId];
1768
+ const tokens = [OUT_MSG_ID.REQ_MKT_DEPTH, version, reqId];
1769
1769
  // send contract fields
1770
1770
  if (this.serverVersion >= min_server_version_1.default.TRADING_CLASS) {
1771
1771
  tokens.push(contract.conId);
@@ -1817,7 +1817,7 @@ class Encoder {
1817
1817
  */
1818
1818
  reqPositions() {
1819
1819
  if (this.serverVersion < min_server_version_1.default.ACCT_SUMMARY) {
1820
- return this.emitError("It does not support position requests.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1820
+ return this.emitError("It does not support position requests.", errorCode_1.ErrorCode.UPDATE_TWS);
1821
1821
  }
1822
1822
  const version = 1;
1823
1823
  this.sendMsg(OUT_MSG_ID.REQ_POSITIONS, version);
@@ -1845,22 +1845,18 @@ class Encoder {
1845
1845
  /**
1846
1846
  * Encode a REQ_REAL_TIME_BARS message.
1847
1847
  */
1848
- reqRealTimeBars(tickerId, contract, barSize, whatToShow, useRTH, realTimeBarsOptions) {
1848
+ reqRealTimeBars(reqId, contract, barSize, whatToShow, useRTH, realTimeBarsOptions) {
1849
1849
  if (this.serverVersion < min_server_version_1.default.REAL_TIME_BARS) {
1850
- return this.emitError("It does not support real time bars.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1850
+ return this.emitError("It does not support real time bars.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1851
1851
  }
1852
1852
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
1853
1853
  if (!!contract.tradingClass || contract.conId != undefined) {
1854
- return this.emitError("It does not support conId and tradingClass parameters in reqRealTimeBars.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1854
+ return this.emitError("It does not support conId and tradingClass parameters in reqRealTimeBars.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1855
1855
  }
1856
1856
  }
1857
1857
  const version = 3;
1858
1858
  // send req mkt data msg
1859
- const tokens = [
1860
- OUT_MSG_ID.REQ_REAL_TIME_BARS,
1861
- version,
1862
- tickerId,
1863
- ];
1859
+ const tokens = [OUT_MSG_ID.REQ_REAL_TIME_BARS, version, reqId];
1864
1860
  // send contract fields
1865
1861
  if (this.serverVersion >= min_server_version_1.default.TRADING_CLASS) {
1866
1862
  tokens.push(contract.conId);
@@ -1892,7 +1888,7 @@ class Encoder {
1892
1888
  */
1893
1889
  reqScannerParameters() {
1894
1890
  if (this.serverVersion < 24) {
1895
- return this.emitError("It does not support API scanner subscription.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1891
+ return this.emitError("It does not support API scanner subscription.", errorCode_1.ErrorCode.UPDATE_TWS);
1896
1892
  }
1897
1893
  const version = 1;
1898
1894
  this.sendMsg(OUT_MSG_ID.REQ_SCANNER_PARAMETERS, version);
@@ -1954,7 +1950,7 @@ class Encoder {
1954
1950
  requestFA(faDataType) {
1955
1951
  if (this.serverVersion >= min_server_version_1.default.FA_PROFILE_DESUPPORT &&
1956
1952
  faDataType == fa_data_type_1.default.PROFILES) {
1957
- return this.emitError("FA Profile is not supported anymore, use FA Group instead.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
1953
+ return this.emitError("FA Profile is not supported anymore, use FA Group instead.", errorCode_1.ErrorCode.UPDATE_TWS);
1958
1954
  }
1959
1955
  const version = 1;
1960
1956
  this.sendMsg(OUT_MSG_ID.REQ_FA, version, faDataType);
@@ -2017,7 +2013,7 @@ class Encoder {
2017
2013
  */
2018
2014
  reqFamilyCodes() {
2019
2015
  if (this.serverVersion < min_server_version_1.default.REQ_FAMILY_CODES) {
2020
- return this.emitError("It does not support family codes request.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
2016
+ return this.emitError("It does not support family codes request.", errorCode_1.ErrorCode.UPDATE_TWS);
2021
2017
  }
2022
2018
  this.sendMsg(OUT_MSG_ID.REQ_FAMILY_CODES);
2023
2019
  }
@@ -2035,7 +2031,7 @@ class Encoder {
2035
2031
  */
2036
2032
  reqMktDepthExchanges() {
2037
2033
  if (this.serverVersion < min_server_version_1.default.REQ_MKT_DEPTH_EXCHANGES) {
2038
- return this.emitError("It does not support market depth exchanges request.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
2034
+ return this.emitError("It does not support market depth exchanges request.", errorCode_1.ErrorCode.UPDATE_TWS);
2039
2035
  }
2040
2036
  this.sendMsg(OUT_MSG_ID.REQ_MKT_DEPTH_EXCHANGES);
2041
2037
  }
@@ -2071,7 +2067,7 @@ class Encoder {
2071
2067
  */
2072
2068
  reqNewsProviders() {
2073
2069
  if (this.serverVersion < min_server_version_1.default.REQ_SMART_COMPONENTS) {
2074
- return this.emitError("It does not support smart components request.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
2070
+ return this.emitError("It does not support smart components request.", errorCode_1.ErrorCode.UPDATE_TWS);
2075
2071
  }
2076
2072
  this.sendMsg(OUT_MSG_ID.REQ_NEWS_PROVIDERS);
2077
2073
  }
@@ -2101,36 +2097,36 @@ class Encoder {
2101
2097
  /**
2102
2098
  * Encode a REQ_HISTOGRAM_DATA message.
2103
2099
  */
2104
- reqHistogramData(tickerId, contract, useRTH, timePeriod) {
2100
+ reqHistogramData(reqId, contract, useRTH, timePeriod) {
2105
2101
  if (this.serverVersion < min_server_version_1.default.REQ_HISTOGRAM) {
2106
- return this.emitError("It does not support histogram requests.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
2102
+ return this.emitError("It does not support histogram requests.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
2107
2103
  }
2108
- this.sendMsg(OUT_MSG_ID.REQ_HISTOGRAM_DATA, tickerId, this.encodeContract(contract), useRTH ? 1 : 0, timePeriod);
2104
+ this.sendMsg(OUT_MSG_ID.REQ_HISTOGRAM_DATA, reqId, this.encodeContract(contract), useRTH ? 1 : 0, timePeriod);
2109
2105
  }
2110
2106
  /**
2111
2107
  * Encode a CANCEL_HISTOGRAM_DATA message.
2112
2108
  */
2113
- cancelHistogramData(tickerId) {
2109
+ cancelHistogramData(reqId) {
2114
2110
  if (this.serverVersion < min_server_version_1.default.REQ_HISTOGRAM) {
2115
- return this.emitError("It does not support head time stamp requests.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
2111
+ return this.emitError("It does not support head time stamp requests.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
2116
2112
  }
2117
- this.sendMsg(OUT_MSG_ID.CANCEL_HISTOGRAM_DATA, tickerId);
2113
+ this.sendMsg(OUT_MSG_ID.CANCEL_HISTOGRAM_DATA, reqId);
2118
2114
  }
2119
2115
  /**
2120
2116
  * Encode a CANCEL_HISTOGRAM_DATA message.
2121
2117
  */
2122
- cancelHeadTimestamp(tickerId) {
2118
+ cancelHeadTimestamp(reqId) {
2123
2119
  if (this.serverVersion < min_server_version_1.default.CANCEL_HEADTIMESTAMP) {
2124
- return this.emitError("It does not support head time stamp requests canceling.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
2120
+ return this.emitError("It does not support head time stamp requests canceling.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
2125
2121
  }
2126
- this.sendMsg(OUT_MSG_ID.CANCEL_HEAD_TIMESTAMP, tickerId);
2122
+ this.sendMsg(OUT_MSG_ID.CANCEL_HEAD_TIMESTAMP, reqId);
2127
2123
  }
2128
2124
  /**
2129
2125
  * Encode a REQ_MARKET_RULE message.
2130
2126
  */
2131
2127
  reqMarketRule(marketRuleId) {
2132
2128
  if (this.serverVersion < min_server_version_1.default.MARKET_RULES) {
2133
- return this.emitError("It does not support market rule requests.", errorCode_1.ErrorCode.UPDATE_TWS, marketRuleId);
2129
+ return this.emitError("It does not support market rule requests.", errorCode_1.ErrorCode.UPDATE_TWS);
2134
2130
  }
2135
2131
  this.sendMsg(OUT_MSG_ID.REQ_MARKET_RULE, marketRuleId);
2136
2132
  }
@@ -2139,7 +2135,7 @@ class Encoder {
2139
2135
  */
2140
2136
  reqCompletedOrders(apiOnly) {
2141
2137
  if (this.serverVersion < min_server_version_1.default.REQ_COMPLETED_ORDERS) {
2142
- return this.emitError("It does not support completed orders requests.", errorCode_1.ErrorCode.UPDATE_TWS, errorCode_1.ErrorCode.NO_VALID_ID);
2138
+ return this.emitError("It does not support completed orders requests.", errorCode_1.ErrorCode.UPDATE_TWS);
2143
2139
  }
2144
2140
  this.sendMsg(OUT_MSG_ID.REQ_COMPLETED_ORDERS, apiOnly);
2145
2141
  }