@stoqey/ib 1.3.30 → 1.4.1

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 (96) hide show
  1. package/dist/api/api.js +2 -2
  2. package/dist/api/api.js.map +1 -1
  3. package/dist/api/contract/contractDetails.d.ts +1 -1
  4. package/dist/api/contract/forex.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/data/enum/min-server-version.d.ts +1 -2
  9. package/dist/api/data/enum/min-server-version.js +0 -1
  10. package/dist/api/data/enum/min-server-version.js.map +1 -1
  11. package/dist/api/order/enum/orderType.d.ts +1 -0
  12. package/dist/api/order/enum/orderType.js +1 -0
  13. package/dist/api/order/enum/orderType.js.map +1 -1
  14. package/dist/api-next/api-next.d.ts +22 -2
  15. package/dist/api-next/api-next.js +80 -57
  16. package/dist/api-next/api-next.js.map +1 -1
  17. package/dist/api-next/common/error.d.ts +6 -5
  18. package/dist/api-next/common/error.js +17 -0
  19. package/dist/api-next/common/error.js.map +1 -1
  20. package/dist/api-next/index.d.ts +3 -4
  21. package/dist/api-next/index.js +9 -3
  22. package/dist/api-next/index.js.map +1 -1
  23. package/dist/api-next/market-scanner/market-scanner.d.ts +2 -2
  24. package/dist/api-next/order/open-order.d.ts +2 -2
  25. package/dist/common/configuration.js +22 -8
  26. package/dist/common/configuration.js.map +1 -1
  27. package/dist/common/errorCode.d.ts +9 -3
  28. package/dist/common/errorCode.js +26 -5
  29. package/dist/common/errorCode.js.map +1 -1
  30. package/dist/common/logger.js +20 -9
  31. package/dist/common/logger.js.map +1 -1
  32. package/dist/core/api-next/auto-connection.js +18 -8
  33. package/dist/core/api-next/auto-connection.js.map +1 -1
  34. package/dist/core/api-next/console-logger.js +17 -7
  35. package/dist/core/api-next/console-logger.js.map +1 -1
  36. package/dist/core/api-next/subscription-registry.d.ts +5 -5
  37. package/dist/core/api-next/subscription-registry.js +9 -9
  38. package/dist/core/api-next/subscription-registry.js.map +1 -1
  39. package/dist/core/api-next/subscription.js +5 -5
  40. package/dist/core/api-next/subscription.js.map +1 -1
  41. package/dist/core/io/controller.d.ts +1 -1
  42. package/dist/core/io/controller.js +3 -4
  43. package/dist/core/io/controller.js.map +1 -1
  44. package/dist/core/io/decoder.d.ts +1 -1
  45. package/dist/core/io/decoder.js +17 -15
  46. package/dist/core/io/decoder.js.map +1 -1
  47. package/dist/core/io/encoder.d.ts +14 -14
  48. package/dist/core/io/encoder.js +79 -83
  49. package/dist/core/io/encoder.js.map +1 -1
  50. package/dist/core/io/enum/in-msg-id.js.map +1 -1
  51. package/dist/core/io/socket.js +17 -29
  52. package/dist/core/io/socket.js.map +1 -1
  53. package/dist/index.d.ts +2 -1
  54. package/dist/index.js +2 -1
  55. package/dist/index.js.map +1 -1
  56. package/dist/tests/nodb-test-environment.js +1 -1
  57. package/dist/tests/nodb-test-environment.js.map +1 -1
  58. package/dist/tests/unit/api/historical-data.test.js +34 -42
  59. package/dist/tests/unit/api/historical-data.test.js.map +1 -1
  60. package/dist/tests/unit/api/market-scanner.test.js +19 -27
  61. package/dist/tests/unit/api/market-scanner.test.js.map +1 -1
  62. package/dist/tests/unit/api/order/cancelOrder.test.js +86 -67
  63. package/dist/tests/unit/api/order/cancelOrder.test.js.map +1 -1
  64. package/dist/tests/unit/api/pnl.test.js +12 -4
  65. package/dist/tests/unit/api/pnl.test.js.map +1 -1
  66. package/dist/tests/unit/api/positions.test.js +3 -6
  67. package/dist/tests/unit/api/positions.test.js.map +1 -1
  68. package/dist/tests/unit/api-next/get-account-summary.test.js +1 -1
  69. package/dist/tests/unit/api-next/get-account-updates.test.d.ts +4 -0
  70. package/dist/tests/unit/api-next/get-account-updates.test.js +86 -0
  71. package/dist/tests/unit/api-next/get-account-updates.test.js.map +1 -0
  72. package/dist/tests/unit/api-next/get-historical-data.test.js +1 -1
  73. package/dist/tests/unit/api-next/get-historical-data.test.js.map +1 -1
  74. package/dist/tests/unit/api-next/next-valid-order-id.test.js +1 -1
  75. package/dist/tests/unit/api-next/next-valid-order-id.test.js.map +1 -1
  76. package/dist/tests/unit/api-next-live/get-contract-details.test.js +7 -17
  77. package/dist/tests/unit/api-next-live/get-contract-details.test.js.map +1 -1
  78. package/dist/tests/unit/api-next-live/get-current-time.test.d.ts +4 -0
  79. package/dist/tests/unit/api-next-live/get-current-time.test.js +64 -0
  80. package/dist/tests/unit/api-next-live/get-current-time.test.js.map +1 -0
  81. package/dist/tests/unit/api-next-live/get-historical-ticks.test.js +7 -3
  82. package/dist/tests/unit/api-next-live/get-historical-ticks.test.js.map +1 -1
  83. package/dist/tests/unit/api-next-live/get-managed-accounts.test.d.ts +4 -0
  84. package/dist/tests/unit/api-next-live/get-managed-accounts.test.js +48 -0
  85. package/dist/tests/unit/api-next-live/get-managed-accounts.test.js.map +1 -0
  86. package/dist/tests/unit/api-next-live/get-market-rule.test.d.ts +4 -0
  87. package/dist/tests/unit/api-next-live/get-market-rule.test.js +64 -0
  88. package/dist/tests/unit/api-next-live/get-market-rule.test.js.map +1 -0
  89. package/dist/tests/unit/api-next-live/get-user-info.test.d.ts +4 -0
  90. package/dist/tests/unit/api-next-live/get-user-info.test.js +50 -0
  91. package/dist/tests/unit/api-next-live/get-user-info.test.js.map +1 -0
  92. package/dist/tests/unit/api-next-live/subscription-registry.test.js +11 -7
  93. package/dist/tests/unit/api-next-live/subscription-registry.test.js.map +1 -1
  94. package/dist/tools/common/ib-api-next-app.js +3 -2
  95. package/dist/tools/common/ib-api-next-app.js.map +1 -1
  96. package/package.json +14 -11
@@ -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.
@@ -255,7 +255,7 @@ class Encoder {
255
255
  return this.emitError("It does not support calculate option price requests.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
256
256
  }
257
257
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
258
- if (!!contract.tradingClass) {
258
+ if (contract.tradingClass) {
259
259
  return this.emitError("It does not support tradingClass parameter in calculateOptionPrice.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
260
260
  }
261
261
  }
@@ -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
  }
@@ -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);
@@ -531,7 +531,7 @@ class Encoder {
531
531
  }
532
532
  }
533
533
  if (this.serverVersion < min_server_version_1.default.ALGO_ORDERS) {
534
- if (!!order.algoStrategy) {
534
+ if (order.algoStrategy) {
535
535
  return this.emitError("It does not support algo orders.", errorCode_1.ErrorCode.UPDATE_TWS, id);
536
536
  }
537
537
  }
@@ -563,7 +563,7 @@ class Encoder {
563
563
  });
564
564
  }
565
565
  if (this.serverVersion < min_server_version_1.default.HEDGE_ORDERS) {
566
- if (!!order.hedgeType) {
566
+ if (order.hedgeType) {
567
567
  return this.emitError("It does not support hedge orders.", errorCode_1.ErrorCode.UPDATE_TWS, id);
568
568
  }
569
569
  }
@@ -616,7 +616,7 @@ class Encoder {
616
616
  }
617
617
  }
618
618
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
619
- if (!!contract.tradingClass) {
619
+ if (contract.tradingClass) {
620
620
  return this.emitError("It does not support tradingClass parameters in placeOrder.", errorCode_1.ErrorCode.UPDATE_TWS, id);
621
621
  }
622
622
  }
@@ -643,7 +643,7 @@ class Encoder {
643
643
  }
644
644
  }
645
645
  if (this.serverVersion < min_server_version_1.default.MODELS_SUPPORT) {
646
- if (!!order.modelCode) {
646
+ if (order.modelCode) {
647
647
  return this.emitError("It does not support model code parameter.", errorCode_1.ErrorCode.UPDATE_TWS, id);
648
648
  }
649
649
  }
@@ -1001,7 +1001,7 @@ class Encoder {
1001
1001
  }
1002
1002
  if (this.serverVersion >= min_server_version_1.default.HEDGE_ORDERS) {
1003
1003
  tokens.push(order.hedgeType);
1004
- if (!!order.hedgeType) {
1004
+ if (order.hedgeType) {
1005
1005
  tokens.push(order.hedgeParam);
1006
1006
  }
1007
1007
  }
@@ -1028,7 +1028,7 @@ class Encoder {
1028
1028
  }
1029
1029
  if (this.serverVersion >= min_server_version_1.default.ALGO_ORDERS) {
1030
1030
  tokens.push(order.algoStrategy);
1031
- if (!!order.algoStrategy) {
1031
+ if (order.algoStrategy) {
1032
1032
  const algoParamsCount = order.algoParams?.length
1033
1033
  ? order.algoParams.length
1034
1034
  : 0;
@@ -1336,12 +1336,12 @@ class Encoder {
1336
1336
  }
1337
1337
  }
1338
1338
  if (this.serverVersion < min_server_version_1.default.TRADING_CLASS) {
1339
- if (!!contract.tradingClass) {
1339
+ if (contract.tradingClass) {
1340
1340
  return this.emitError("It does not support tradingClass parameter in reqContractDetails.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1341
1341
  }
1342
1342
  }
1343
1343
  if (this.serverVersion < min_server_version_1.default.LINKING) {
1344
- if (!!contract.primaryExch) {
1344
+ if (contract.primaryExch) {
1345
1345
  return this.emitError("It does not support primaryExchange parameter in reqContractDetails.", errorCode_1.ErrorCode.UPDATE_TWS, reqId);
1346
1346
  }
1347
1347
  }
@@ -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
1473
  if (orderCancel.extOperator?.length ||
1474
1474
  orderCancel.manualOrderIndicator != undefined) {
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);
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;
@@ -1490,27 +1490,27 @@ class Encoder {
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
- if (!!contract.tradingClass) {
1672
- return this.emitError("It does not support tradingClass parameter in reqMarketData.", errorCode_1.ErrorCode.UPDATE_TWS, tickerId);
1671
+ if (contract.tradingClass) {
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
  }