ccxt 4.3.5 → 4.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 (211) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ace.js +5 -0
  4. package/dist/cjs/src/alpaca.js +6 -0
  5. package/dist/cjs/src/base/Exchange.js +37 -0
  6. package/dist/cjs/src/binance.js +4 -0
  7. package/dist/cjs/src/bingx.js +47 -0
  8. package/dist/cjs/src/bitbank.js +3 -0
  9. package/dist/cjs/src/bitget.js +74 -1
  10. package/dist/cjs/src/bithumb.js +4 -0
  11. package/dist/cjs/src/bitmex.js +26 -0
  12. package/dist/cjs/src/bitopro.js +5 -0
  13. package/dist/cjs/src/bitso.js +3 -0
  14. package/dist/cjs/src/bitstamp.js +3 -0
  15. package/dist/cjs/src/bitteam.js +4 -0
  16. package/dist/cjs/src/bitvavo.js +3 -0
  17. package/dist/cjs/src/bl3p.js +3 -0
  18. package/dist/cjs/src/btcalpha.js +3 -0
  19. package/dist/cjs/src/btcbox.js +3 -0
  20. package/dist/cjs/src/btcmarkets.js +3 -0
  21. package/dist/cjs/src/btcturk.js +3 -0
  22. package/dist/cjs/src/bybit.js +209 -12
  23. package/dist/cjs/src/cex.js +6 -0
  24. package/dist/cjs/src/coinbase.js +100 -21
  25. package/dist/cjs/src/coinbaseinternational.js +2 -0
  26. package/dist/cjs/src/coinbasepro.js +6 -0
  27. package/dist/cjs/src/coincheck.js +3 -0
  28. package/dist/cjs/src/coinex.js +180 -75
  29. package/dist/cjs/src/coinlist.js +4 -0
  30. package/dist/cjs/src/coinmate.js +3 -0
  31. package/dist/cjs/src/coinone.js +3 -0
  32. package/dist/cjs/src/coinsph.js +4 -0
  33. package/dist/cjs/src/coinspot.js +3 -0
  34. package/dist/cjs/src/cryptocom.js +34 -0
  35. package/dist/cjs/src/exmo.js +5 -0
  36. package/dist/cjs/src/gate.js +124 -22
  37. package/dist/cjs/src/hitbtc.js +4 -3
  38. package/dist/cjs/src/htx.js +30 -0
  39. package/dist/cjs/src/hyperliquid.js +40 -0
  40. package/dist/cjs/src/idex.js +3 -0
  41. package/dist/cjs/src/independentreserve.js +3 -0
  42. package/dist/cjs/src/indodax.js +3 -0
  43. package/dist/cjs/src/kraken.js +30 -0
  44. package/dist/cjs/src/krakenfutures.js +28 -0
  45. package/dist/cjs/src/kucoin.js +2 -0
  46. package/dist/cjs/src/kucoinfutures.js +4 -2
  47. package/dist/cjs/src/latoken.js +6 -0
  48. package/dist/cjs/src/luno.js +3 -0
  49. package/dist/cjs/src/lykke.js +5 -0
  50. package/dist/cjs/src/mercado.js +3 -0
  51. package/dist/cjs/src/mexc.js +111 -0
  52. package/dist/cjs/src/ndax.js +4 -0
  53. package/dist/cjs/src/novadax.js +4 -0
  54. package/dist/cjs/src/okx.js +196 -0
  55. package/dist/cjs/src/onetrading.js +3 -0
  56. package/dist/cjs/src/p2b.js +3 -0
  57. package/dist/cjs/src/pro/bitget.js +1 -1
  58. package/dist/cjs/src/pro/bybit.js +1 -1
  59. package/dist/cjs/src/pro/coinbase.js +30 -29
  60. package/dist/cjs/src/probit.js +3 -0
  61. package/dist/cjs/src/timex.js +3 -0
  62. package/dist/cjs/src/tradeogre.js +3 -0
  63. package/dist/cjs/src/wavesexchange.js +3 -0
  64. package/dist/cjs/src/wazirx.js +3 -0
  65. package/dist/cjs/src/whitebit.js +42 -0
  66. package/dist/cjs/src/woo.js +31 -0
  67. package/dist/cjs/src/yobit.js +3 -0
  68. package/js/ccxt.d.ts +1 -1
  69. package/js/ccxt.js +1 -1
  70. package/js/src/abstract/binance.d.ts +1 -0
  71. package/js/src/abstract/binancecoinm.d.ts +1 -0
  72. package/js/src/abstract/binanceus.d.ts +1 -0
  73. package/js/src/abstract/binanceusdm.d.ts +1 -0
  74. package/js/src/abstract/bingx.d.ts +1 -0
  75. package/js/src/abstract/coinbase.d.ts +5 -0
  76. package/js/src/abstract/woo.d.ts +1 -0
  77. package/js/src/ace.js +5 -0
  78. package/js/src/alpaca.js +6 -0
  79. package/js/src/ascendex.d.ts +2 -2
  80. package/js/src/base/Exchange.d.ts +5 -0
  81. package/js/src/base/Exchange.js +37 -0
  82. package/js/src/bigone.d.ts +1 -1
  83. package/js/src/binance.d.ts +3 -3
  84. package/js/src/binance.js +4 -0
  85. package/js/src/bingx.d.ts +2 -1
  86. package/js/src/bingx.js +47 -0
  87. package/js/src/bitbank.d.ts +1 -1
  88. package/js/src/bitbank.js +3 -0
  89. package/js/src/bitfinex.d.ts +1 -1
  90. package/js/src/bitfinex2.d.ts +1 -1
  91. package/js/src/bitflyer.d.ts +1 -1
  92. package/js/src/bitget.d.ts +4 -3
  93. package/js/src/bitget.js +74 -1
  94. package/js/src/bithumb.d.ts +1 -1
  95. package/js/src/bithumb.js +4 -0
  96. package/js/src/bitmart.d.ts +1 -1
  97. package/js/src/bitmex.d.ts +2 -1
  98. package/js/src/bitmex.js +26 -0
  99. package/js/src/bitopro.d.ts +1 -1
  100. package/js/src/bitopro.js +5 -0
  101. package/js/src/bitrue.d.ts +1 -1
  102. package/js/src/bitso.d.ts +1 -1
  103. package/js/src/bitso.js +3 -0
  104. package/js/src/bitstamp.d.ts +1 -1
  105. package/js/src/bitstamp.js +3 -0
  106. package/js/src/bitteam.js +4 -0
  107. package/js/src/bitvavo.d.ts +1 -1
  108. package/js/src/bitvavo.js +3 -0
  109. package/js/src/bl3p.js +3 -0
  110. package/js/src/blockchaincom.d.ts +1 -1
  111. package/js/src/btcalpha.js +3 -0
  112. package/js/src/btcbox.js +3 -0
  113. package/js/src/btcmarkets.d.ts +1 -1
  114. package/js/src/btcmarkets.js +3 -0
  115. package/js/src/btcturk.js +3 -0
  116. package/js/src/bybit.d.ts +8 -6
  117. package/js/src/bybit.js +209 -12
  118. package/js/src/cex.js +6 -0
  119. package/js/src/coinbase.d.ts +1 -1
  120. package/js/src/coinbase.js +100 -21
  121. package/js/src/coinbaseinternational.d.ts +1 -1
  122. package/js/src/coinbaseinternational.js +2 -0
  123. package/js/src/coinbasepro.d.ts +1 -1
  124. package/js/src/coinbasepro.js +6 -0
  125. package/js/src/coincheck.js +3 -0
  126. package/js/src/coinex.d.ts +8 -7
  127. package/js/src/coinex.js +180 -75
  128. package/js/src/coinlist.d.ts +1 -1
  129. package/js/src/coinlist.js +4 -0
  130. package/js/src/coinmate.d.ts +1 -1
  131. package/js/src/coinmate.js +3 -0
  132. package/js/src/coinone.js +3 -0
  133. package/js/src/coinsph.d.ts +1 -1
  134. package/js/src/coinsph.js +4 -0
  135. package/js/src/coinspot.js +3 -0
  136. package/js/src/cryptocom.d.ts +3 -2
  137. package/js/src/cryptocom.js +34 -0
  138. package/js/src/delta.d.ts +2 -2
  139. package/js/src/deribit.d.ts +1 -1
  140. package/js/src/digifinex.d.ts +3 -3
  141. package/js/src/exmo.d.ts +3 -3
  142. package/js/src/exmo.js +5 -0
  143. package/js/src/gate.d.ts +8 -7
  144. package/js/src/gate.js +124 -22
  145. package/js/src/gemini.d.ts +1 -1
  146. package/js/src/hitbtc.d.ts +3 -3
  147. package/js/src/hitbtc.js +4 -3
  148. package/js/src/hollaex.d.ts +1 -1
  149. package/js/src/htx.d.ts +2 -1
  150. package/js/src/htx.js +30 -0
  151. package/js/src/huobijp.d.ts +1 -1
  152. package/js/src/hyperliquid.d.ts +3 -2
  153. package/js/src/hyperliquid.js +40 -0
  154. package/js/src/idex.d.ts +1 -1
  155. package/js/src/idex.js +3 -0
  156. package/js/src/independentreserve.js +3 -0
  157. package/js/src/indodax.d.ts +1 -1
  158. package/js/src/indodax.js +3 -0
  159. package/js/src/kraken.d.ts +2 -1
  160. package/js/src/kraken.js +30 -0
  161. package/js/src/krakenfutures.d.ts +1 -0
  162. package/js/src/krakenfutures.js +28 -0
  163. package/js/src/kucoin.d.ts +1 -1
  164. package/js/src/kucoin.js +2 -0
  165. package/js/src/kucoinfutures.d.ts +1 -1
  166. package/js/src/kucoinfutures.js +4 -2
  167. package/js/src/kuna.d.ts +1 -1
  168. package/js/src/latoken.js +6 -0
  169. package/js/src/lbank.d.ts +1 -1
  170. package/js/src/luno.js +3 -0
  171. package/js/src/lykke.d.ts +1 -1
  172. package/js/src/lykke.js +5 -0
  173. package/js/src/mercado.d.ts +1 -1
  174. package/js/src/mercado.js +3 -0
  175. package/js/src/mexc.d.ts +4 -3
  176. package/js/src/mexc.js +111 -0
  177. package/js/src/ndax.d.ts +1 -1
  178. package/js/src/ndax.js +4 -0
  179. package/js/src/novadax.d.ts +1 -1
  180. package/js/src/novadax.js +4 -0
  181. package/js/src/okcoin.d.ts +1 -1
  182. package/js/src/okx.d.ts +11 -8
  183. package/js/src/okx.js +196 -0
  184. package/js/src/onetrading.d.ts +1 -1
  185. package/js/src/onetrading.js +3 -0
  186. package/js/src/p2b.js +3 -0
  187. package/js/src/phemex.d.ts +1 -1
  188. package/js/src/poloniex.d.ts +1 -1
  189. package/js/src/pro/bitget.d.ts +1 -1
  190. package/js/src/pro/bitget.js +1 -1
  191. package/js/src/pro/bybit.js +1 -1
  192. package/js/src/pro/coinbase.d.ts +2 -2
  193. package/js/src/pro/coinbase.js +30 -29
  194. package/js/src/probit.d.ts +1 -1
  195. package/js/src/probit.js +3 -0
  196. package/js/src/timex.js +3 -0
  197. package/js/src/tokocrypto.d.ts +1 -1
  198. package/js/src/tradeogre.js +3 -0
  199. package/js/src/upbit.d.ts +1 -1
  200. package/js/src/wavesexchange.d.ts +1 -1
  201. package/js/src/wavesexchange.js +3 -0
  202. package/js/src/wazirx.js +3 -0
  203. package/js/src/whitebit.d.ts +2 -1
  204. package/js/src/whitebit.js +42 -0
  205. package/js/src/woo.d.ts +3 -2
  206. package/js/src/woo.js +31 -0
  207. package/js/src/yobit.d.ts +1 -1
  208. package/js/src/yobit.js +3 -0
  209. package/js/src/zaif.d.ts +1 -1
  210. package/js/src/zonda.d.ts +1 -1
  211. package/package.json +1 -1
package/js/src/okx.js CHANGED
@@ -34,8 +34,10 @@ export default class okx extends Exchange {
34
34
  'option': true,
35
35
  'addMargin': true,
36
36
  'cancelAllOrders': false,
37
+ 'cancelAllOrdersAfter': true,
37
38
  'cancelOrder': true,
38
39
  'cancelOrders': true,
40
+ 'cancelOrdersForSymbols': true,
39
41
  'closeAllPositions': false,
40
42
  'closePosition': true,
41
43
  'createConvertTrade': true,
@@ -112,8 +114,10 @@ export default class okx extends Exchange {
112
114
  'fetchOrderTrades': true,
113
115
  'fetchPermissions': undefined,
114
116
  'fetchPosition': true,
117
+ 'fetchPositionHistory': 'emulated',
115
118
  'fetchPositions': true,
116
119
  'fetchPositionsForSymbol': true,
120
+ 'fetchPositionsHistory': true,
117
121
  'fetchPositionsRisk': false,
118
122
  'fetchPremiumIndexOHLCV': false,
119
123
  'fetchSettlementHistory': true,
@@ -3285,6 +3289,117 @@ export default class okx extends Exchange {
3285
3289
  const ordersData = this.safeList(response, 'data', []);
3286
3290
  return this.parseOrders(ordersData, market, undefined, undefined, params);
3287
3291
  }
3292
+ async cancelOrdersForSymbols(orders, params = {}) {
3293
+ /**
3294
+ * @method
3295
+ * @name okx#cancelOrdersForSymbols
3296
+ * @description cancel multiple orders for multiple symbols
3297
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
3298
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
3299
+ * @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol
3300
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3301
+ * @param {boolean} [params.trigger] whether the order is a stop/trigger order
3302
+ * @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
3303
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3304
+ */
3305
+ await this.loadMarkets();
3306
+ const request = [];
3307
+ const options = this.safeDict(this.options, 'cancelOrders', {});
3308
+ const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
3309
+ let method = this.safeString(params, 'method', defaultMethod);
3310
+ const stop = this.safeBool2(params, 'stop', 'trigger');
3311
+ const trailing = this.safeBool(params, 'trailing', false);
3312
+ const isStopOrTrailing = stop || trailing;
3313
+ if (isStopOrTrailing) {
3314
+ method = 'privatePostTradeCancelAlgos';
3315
+ }
3316
+ for (let i = 0; i < orders.length; i++) {
3317
+ const order = orders[i];
3318
+ const id = this.safeString(order, 'id');
3319
+ const clientOrderId = this.safeString2(order, 'clOrdId', 'clientOrderId');
3320
+ const symbol = this.safeString(order, 'symbol');
3321
+ const market = this.market(symbol);
3322
+ let idKey = 'ordId';
3323
+ if (isStopOrTrailing) {
3324
+ idKey = 'algoId';
3325
+ }
3326
+ else if (clientOrderId !== undefined) {
3327
+ idKey = 'clOrdId';
3328
+ }
3329
+ const requestItem = {
3330
+ 'instId': market['id'],
3331
+ };
3332
+ requestItem[idKey] = (clientOrderId !== undefined) ? clientOrderId : id;
3333
+ request.push(requestItem);
3334
+ }
3335
+ let response = undefined;
3336
+ if (method === 'privatePostTradeCancelAlgos') {
3337
+ response = await this.privatePostTradeCancelAlgos(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
3338
+ }
3339
+ else {
3340
+ response = await this.privatePostTradeCancelBatchOrders(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
3341
+ }
3342
+ //
3343
+ // {
3344
+ // "code": "0",
3345
+ // "data": [
3346
+ // {
3347
+ // "clOrdId": "e123456789ec4dBC1123456ba123b45e",
3348
+ // "ordId": "405071912345641543",
3349
+ // "sCode": "0",
3350
+ // "sMsg": ""
3351
+ // },
3352
+ // ...
3353
+ // ],
3354
+ // "msg": ""
3355
+ // }
3356
+ //
3357
+ // Algo order
3358
+ //
3359
+ // {
3360
+ // "code": "0",
3361
+ // "data": [
3362
+ // {
3363
+ // "algoId": "431375349042380800",
3364
+ // "sCode": "0",
3365
+ // "sMsg": ""
3366
+ // }
3367
+ // ],
3368
+ // "msg": ""
3369
+ // }
3370
+ //
3371
+ const ordersData = this.safeList(response, 'data', []);
3372
+ return this.parseOrders(ordersData, undefined, undefined, undefined, params);
3373
+ }
3374
+ async cancelAllOrdersAfter(timeout, params = {}) {
3375
+ /**
3376
+ * @method
3377
+ * @name okx#cancelAllOrdersAfter
3378
+ * @description dead man's switch, cancel all orders after the given timeout
3379
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
3380
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
3381
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3382
+ * @returns {object} the api result
3383
+ */
3384
+ await this.loadMarkets();
3385
+ const request = {
3386
+ 'timeOut': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
3387
+ };
3388
+ const response = await this.privatePostTradeCancelAllAfter(this.extend(request, params));
3389
+ //
3390
+ // {
3391
+ // "code":"0",
3392
+ // "msg":"",
3393
+ // "data":[
3394
+ // {
3395
+ // "triggerTime":"1587971460",
3396
+ // "ts":"1587971400"
3397
+ // }
3398
+ // ]
3399
+ // }
3400
+ //
3401
+ return response;
3402
+ }
3288
3403
  parseOrderStatus(status) {
3289
3404
  const statuses = {
3290
3405
  'canceled': 'canceled',
@@ -8089,4 +8204,85 @@ export default class okx extends Exchange {
8089
8204
  const modifications = this.parseMarginModifications(data);
8090
8205
  return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
8091
8206
  }
8207
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
8208
+ /**
8209
+ * @method
8210
+ * @name okx#fetchPositionsHistory
8211
+ * @description fetches historical positions
8212
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
8213
+ * @param {string} [symbols] unified market symbols
8214
+ * @param {int} [since] timestamp in ms of the earliest position to fetch
8215
+ * @param {int} [limit] the maximum amount of records to fetch, default=100, max=100
8216
+ * @param {object} params extra parameters specific to the exchange api endpoint
8217
+ * @param {string} [params.marginMode] "cross" or "isolated"
8218
+ *
8219
+ * EXCHANGE SPECIFIC PARAMETERS
8220
+ * @param {string} [params.instType] margin, swap, futures or option
8221
+ * @param {string} [params.type] the type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
8222
+ * @param {string} [params.posId] position id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
8223
+ * @param {string} [params.before] timestamp in ms of the earliest position to fetch based on the last update time of the position
8224
+ * @param {string} [params.after] timestamp in ms of the latest position to fetch based on the last update time of the position
8225
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8226
+ */
8227
+ await this.loadMarkets();
8228
+ const marginMode = this.safeString(params, 'marginMode');
8229
+ const instType = this.safeStringUpper(params, 'instType');
8230
+ params = this.omit(params, ['until', 'marginMode', 'instType']);
8231
+ if (limit === undefined) {
8232
+ limit = 100;
8233
+ }
8234
+ const request = {
8235
+ 'limit': limit,
8236
+ };
8237
+ if (symbols !== undefined) {
8238
+ const symbolsLength = symbols.length;
8239
+ if (symbolsLength === 1) {
8240
+ const market = this.market(symbols[0]);
8241
+ request['instId'] = market['id'];
8242
+ }
8243
+ }
8244
+ if (marginMode !== undefined) {
8245
+ request['mgnMode'] = marginMode;
8246
+ }
8247
+ if (instType !== undefined) {
8248
+ request['instType'] = instType;
8249
+ }
8250
+ const response = await this.privateGetAccountPositionsHistory(this.extend(request, params));
8251
+ //
8252
+ // {
8253
+ // code: '0',
8254
+ // data: [
8255
+ // {
8256
+ // cTime: '1708735940395',
8257
+ // ccy: 'USDT',
8258
+ // closeAvgPx: '0.6330444444444444',
8259
+ // closeTotalPos: '27',
8260
+ // direction: 'long',
8261
+ // fee: '-1.69566',
8262
+ // fundingFee: '-11.870404179341788',
8263
+ // instId: 'XRP-USDT-SWAP',
8264
+ // instType: 'SWAP',
8265
+ // lever: '3.0',
8266
+ // liqPenalty: '0',
8267
+ // mgnMode: 'cross',
8268
+ // openAvgPx: '0.623',
8269
+ // openMaxPos: '15',
8270
+ // pnl: '27.11999999999988',
8271
+ // pnlRatio: '0.0241732402722634',
8272
+ // posId: '681423155054862336',
8273
+ // realizedPnl: '13.553935820658092',
8274
+ // triggerPx: '',
8275
+ // type: '2',
8276
+ // uTime: '1711088748170',
8277
+ // uly: 'XRP-USDT'
8278
+ // },
8279
+ // ...
8280
+ // ],
8281
+ // msg: ''
8282
+ // }
8283
+ //
8284
+ const data = this.safeList(response, 'data');
8285
+ const positions = this.parsePositions(data, symbols, params);
8286
+ return this.filterBySinceLimit(positions, since, limit);
8287
+ }
8092
8288
  }
@@ -50,7 +50,7 @@ export default class onetrading extends Exchange {
50
50
  }>;
51
51
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
52
52
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
53
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
53
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
54
54
  parseTransaction(transaction: any, currency?: Currency): Transaction;
55
55
  parseOrderStatus(status: any): string;
56
56
  parseOrder(order: any, market?: Market): Order;
@@ -77,8 +77,11 @@ export default class onetrading extends Exchange {
77
77
  'fetchOrders': false,
78
78
  'fetchOrderTrades': true,
79
79
  'fetchPosition': false,
80
+ 'fetchPositionHistory': false,
80
81
  'fetchPositionMode': false,
81
82
  'fetchPositions': false,
83
+ 'fetchPositionsForSymbol': false,
84
+ 'fetchPositionsHistory': false,
82
85
  'fetchPositionsRisk': false,
83
86
  'fetchPremiumIndexOHLCV': false,
84
87
  'fetchTicker': true,
package/js/src/p2b.js CHANGED
@@ -82,8 +82,11 @@ export default class p2b extends Exchange {
82
82
  'fetchOrderTrades': true,
83
83
  'fetchPermissions': false,
84
84
  'fetchPosition': false,
85
+ 'fetchPositionHistory': false,
86
+ 'fetchPositionMode': false,
85
87
  'fetchPositions': false,
86
88
  'fetchPositionsForSymbol': false,
89
+ 'fetchPositionsHistory': false,
87
90
  'fetchPositionsRisk': false,
88
91
  'fetchPremiumIndexOHLCV': false,
89
92
  'fetchTicker': true,
@@ -128,6 +128,6 @@ export default class phemex extends Exchange {
128
128
  };
129
129
  parseTransferStatus(status: any): string;
130
130
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
131
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
131
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
132
132
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
133
133
  }
@@ -62,7 +62,7 @@ export default class poloniex extends Exchange {
62
62
  toAccount: any;
63
63
  status: any;
64
64
  };
65
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
65
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
66
66
  fetchTransactionsHelper(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
67
67
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
68
68
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -29,7 +29,7 @@ export default class bitget extends bitgetRest {
29
29
  handlePositions(client: Client, message: any): void;
30
30
  parseWsPosition(position: any, market?: any): Position;
31
31
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
32
- handleOrder(client: Client, message: any, subscription?: any): void;
32
+ handleOrder(client: Client, message: any): void;
33
33
  parseWsOrder(order: any, market?: any): Order;
34
34
  parseWsOrderStatus(status: any): string;
35
35
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -1007,7 +1007,7 @@ export default class bitget extends bitgetRest {
1007
1007
  }
1008
1008
  return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
1009
1009
  }
1010
- handleOrder(client, message, subscription = undefined) {
1010
+ handleOrder(client, message) {
1011
1011
  //
1012
1012
  // spot
1013
1013
  //
@@ -120,7 +120,7 @@ export default class bybit extends bybitRest {
120
120
  },
121
121
  'streaming': {
122
122
  'ping': this.ping,
123
- 'keepAlive': 20000,
123
+ 'keepAlive': 19000,
124
124
  },
125
125
  });
126
126
  }
@@ -2,7 +2,7 @@ import coinbaseRest from '../coinbase.js';
2
2
  import { Strings, Tickers, Ticker, Int, Trade, OrderBook, Order, Str } from '../base/types.js';
3
3
  export default class coinbase extends coinbaseRest {
4
4
  describe(): any;
5
- subscribe(name: any, symbol?: any, params?: {}): Promise<any>;
5
+ subscribe(name: string, isPrivate: boolean, symbol?: any, params?: {}): Promise<any>;
6
6
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
7
7
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
8
8
  handleTickers(client: any, message: any): any;
@@ -14,7 +14,7 @@ export default class coinbase extends coinbaseRest {
14
14
  handleOrder(client: any, message: any): any;
15
15
  parseWsOrder(order: any, market?: any): Order;
16
16
  handleOrderBookHelper(orderbook: any, updates: any): void;
17
- handleOrderBook(client: any, message: any): any;
17
+ handleOrderBook(client: any, message: any): void;
18
18
  handleSubscriptionStatus(client: any, message: any): any;
19
19
  handleMessage(client: any, message: any): void;
20
20
  }
@@ -49,7 +49,7 @@ export default class coinbase extends coinbaseRest {
49
49
  },
50
50
  });
51
51
  }
52
- async subscribe(name, symbol = undefined, params = {}) {
52
+ async subscribe(name, isPrivate, symbol = undefined, params = {}) {
53
53
  /**
54
54
  * @ignore
55
55
  * @method
@@ -61,7 +61,6 @@ export default class coinbase extends coinbaseRest {
61
61
  * @returns {object} subscription to a websocket channel
62
62
  */
63
63
  await this.loadMarkets();
64
- this.checkRequiredCredentials();
65
64
  let market = undefined;
66
65
  let messageHash = name;
67
66
  let productIds = [];
@@ -78,8 +77,6 @@ export default class coinbase extends coinbaseRest {
78
77
  }
79
78
  const url = this.urls['api']['ws'];
80
79
  const timestamp = this.numberToString(this.seconds());
81
- const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
82
- const auth = timestamp + name + productIds.join(',');
83
80
  const subscribe = {
84
81
  'type': 'subscribe',
85
82
  'product_ids': productIds,
@@ -88,25 +85,30 @@ export default class coinbase extends coinbaseRest {
88
85
  // 'timestamp': timestamp,
89
86
  // 'signature': this.hmac (this.encode (auth), this.encode (this.secret), sha256),
90
87
  };
91
- if (!isCloudAPiKey) {
92
- subscribe['api_key'] = this.apiKey;
93
- subscribe['timestamp'] = timestamp;
94
- subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
95
- }
96
- else {
97
- if (this.apiKey.startsWith('-----BEGIN')) {
98
- throw new ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
88
+ if (isPrivate) {
89
+ this.checkRequiredCredentials();
90
+ const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
91
+ const auth = timestamp + name + productIds.join(',');
92
+ if (!isCloudAPiKey) {
93
+ subscribe['api_key'] = this.apiKey;
94
+ subscribe['timestamp'] = timestamp;
95
+ subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
99
96
  }
100
- const currentToken = this.safeString(this.options, 'wsToken');
101
- const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
102
- const seconds = this.seconds();
103
- if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
104
- // we should generate new token
105
- const token = this.createAuthToken(seconds);
106
- this.options['wsToken'] = token;
107
- this.options['wsTokenTimestamp'] = seconds;
97
+ else {
98
+ if (this.apiKey.startsWith('-----BEGIN')) {
99
+ throw new ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
100
+ }
101
+ const currentToken = this.safeString(this.options, 'wsToken');
102
+ const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
103
+ const seconds = this.seconds();
104
+ if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
105
+ // we should generate new token
106
+ const token = this.createAuthToken(seconds);
107
+ this.options['wsToken'] = token;
108
+ this.options['wsTokenTimestamp'] = seconds;
109
+ }
110
+ subscribe['jwt'] = this.safeString(this.options, 'wsToken');
108
111
  }
109
- subscribe['jwt'] = this.safeString(this.options, 'wsToken');
110
112
  }
111
113
  return await this.watch(url, messageHash, subscribe, messageHash);
112
114
  }
@@ -121,7 +123,7 @@ export default class coinbase extends coinbaseRest {
121
123
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
122
124
  */
123
125
  const name = 'ticker';
124
- return await this.subscribe(name, symbol, params);
126
+ return await this.subscribe(name, false, symbol, params);
125
127
  }
126
128
  async watchTickers(symbols = undefined, params = {}) {
127
129
  /**
@@ -137,7 +139,7 @@ export default class coinbase extends coinbaseRest {
137
139
  symbols = this.symbols;
138
140
  }
139
141
  const name = 'ticker_batch';
140
- const tickers = await this.subscribe(name, symbols, params);
142
+ const tickers = await this.subscribe(name, false, symbols, params);
141
143
  if (this.newUpdates) {
142
144
  return tickers;
143
145
  }
@@ -301,7 +303,7 @@ export default class coinbase extends coinbaseRest {
301
303
  await this.loadMarkets();
302
304
  symbol = this.symbol(symbol);
303
305
  const name = 'market_trades';
304
- const trades = await this.subscribe(name, symbol, params);
306
+ const trades = await this.subscribe(name, false, symbol, params);
305
307
  if (this.newUpdates) {
306
308
  limit = trades.getLimit(symbol, limit);
307
309
  }
@@ -321,7 +323,7 @@ export default class coinbase extends coinbaseRest {
321
323
  */
322
324
  await this.loadMarkets();
323
325
  const name = 'user';
324
- const orders = await this.subscribe(name, symbol, params);
326
+ const orders = await this.subscribe(name, true, symbol, params);
325
327
  if (this.newUpdates) {
326
328
  limit = orders.getLimit(symbol, limit);
327
329
  }
@@ -342,7 +344,7 @@ export default class coinbase extends coinbaseRest {
342
344
  const name = 'level2';
343
345
  const market = this.market(symbol);
344
346
  symbol = market['symbol'];
345
- const orderbook = await this.subscribe(name, symbol, params);
347
+ const orderbook = await this.subscribe(name, false, symbol, params);
346
348
  return orderbook.limit();
347
349
  }
348
350
  handleTrade(client, message) {
@@ -560,8 +562,8 @@ export default class coinbase extends coinbaseRest {
560
562
  this.orderbooks[symbol] = this.orderBook({}, limit);
561
563
  const orderbook = this.orderbooks[symbol];
562
564
  this.handleOrderBookHelper(orderbook, updates);
563
- orderbook['timestamp'] = undefined;
564
- orderbook['datetime'] = undefined;
565
+ orderbook['timestamp'] = this.parse8601(datetime);
566
+ orderbook['datetime'] = datetime;
565
567
  orderbook['symbol'] = symbol;
566
568
  client.resolve(orderbook, messageHash);
567
569
  if (messageHash.endsWith('USD')) {
@@ -580,7 +582,6 @@ export default class coinbase extends coinbaseRest {
580
582
  }
581
583
  }
582
584
  }
583
- return message;
584
585
  }
585
586
  handleSubscriptionStatus(client, message) {
586
587
  //
@@ -45,7 +45,7 @@ export default class probit extends Exchange {
45
45
  info: any;
46
46
  }>;
47
47
  fetchDepositAddresses(codes?: string[], params?: {}): Promise<{}>;
48
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
48
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
49
49
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
50
50
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
51
51
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/probit.js CHANGED
@@ -70,8 +70,11 @@ export default class probit extends Exchange {
70
70
  'fetchOrder': true,
71
71
  'fetchOrderBook': true,
72
72
  'fetchPosition': false,
73
+ 'fetchPositionHistory': false,
73
74
  'fetchPositionMode': false,
74
75
  'fetchPositions': false,
76
+ 'fetchPositionsForSymbol': false,
77
+ 'fetchPositionsHistory': false,
75
78
  'fetchPositionsRisk': false,
76
79
  'fetchPremiumIndexOHLCV': false,
77
80
  'fetchTicker': true,
package/js/src/timex.js CHANGED
@@ -67,8 +67,11 @@ export default class timex extends Exchange {
67
67
  'fetchOrder': true,
68
68
  'fetchOrderBook': true,
69
69
  'fetchPosition': false,
70
+ 'fetchPositionHistory': false,
70
71
  'fetchPositionMode': false,
71
72
  'fetchPositions': false,
73
+ 'fetchPositionsForSymbol': false,
74
+ 'fetchPositionsHistory': false,
72
75
  'fetchPositionsRisk': false,
73
76
  'fetchPremiumIndexOHLCV': false,
74
77
  'fetchTicker': true,
@@ -42,7 +42,7 @@ export default class tokocrypto extends Exchange {
42
42
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
43
43
  parseTransactionStatusByType(status: any, type?: any): string;
44
44
  parseTransaction(transaction: any, currency?: Currency): Transaction;
45
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
45
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
46
46
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
47
47
  url: any;
48
48
  method: string;
@@ -82,8 +82,11 @@ export default class tradeogre extends Exchange {
82
82
  'fetchOrderTrades': false,
83
83
  'fetchPermissions': false,
84
84
  'fetchPosition': false,
85
+ 'fetchPositionHistory': false,
86
+ 'fetchPositionMode': false,
85
87
  'fetchPositions': false,
86
88
  'fetchPositionsForSymbol': false,
89
+ 'fetchPositionsHistory': false,
87
90
  'fetchPositionsRisk': false,
88
91
  'fetchPremiumIndexOHLCV': false,
89
92
  'fetchTicker': true,
package/js/src/upbit.d.ts CHANGED
@@ -89,7 +89,7 @@ export default class upbit extends Exchange {
89
89
  network: string;
90
90
  info: any;
91
91
  }>;
92
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
92
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
93
93
  nonce(): number;
94
94
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
95
95
  url: any;
@@ -88,6 +88,6 @@ export default class wavesexchange extends Exchange {
88
88
  parseDepositWithdrawFees(response: any, codes?: Strings, currencyIdKey?: any): any;
89
89
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
90
90
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
91
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
91
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
92
92
  parseTransaction(transaction: any, currency?: Currency): Transaction;
93
93
  }
@@ -69,8 +69,11 @@ export default class wavesexchange extends Exchange {
69
69
  'fetchOrderBook': true,
70
70
  'fetchOrders': true,
71
71
  'fetchPosition': false,
72
+ 'fetchPositionHistory': false,
72
73
  'fetchPositionMode': false,
73
74
  'fetchPositions': false,
75
+ 'fetchPositionsForSymbol': false,
76
+ 'fetchPositionsHistory': false,
74
77
  'fetchPositionsRisk': false,
75
78
  'fetchPremiumIndexOHLCV': false,
76
79
  'fetchTicker': true,
package/js/src/wazirx.js CHANGED
@@ -74,8 +74,11 @@ export default class wazirx extends Exchange {
74
74
  'fetchOrderBook': true,
75
75
  'fetchOrders': true,
76
76
  'fetchPosition': false,
77
+ 'fetchPositionHistory': false,
77
78
  'fetchPositionMode': false,
78
79
  'fetchPositions': false,
80
+ 'fetchPositionsForSymbol': false,
81
+ 'fetchPositionsHistory': false,
79
82
  'fetchPositionsRisk': false,
80
83
  'fetchPremiumIndexOHLCV': false,
81
84
  'fetchStatus': true,
@@ -38,6 +38,7 @@ export default class whitebit extends Exchange {
38
38
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
39
39
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
40
40
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
41
+ cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
41
42
  parseBalance(response: any): Balances;
42
43
  fetchBalance(params?: {}): Promise<Balances>;
43
44
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -65,7 +66,7 @@ export default class whitebit extends Exchange {
65
66
  toAccount: any;
66
67
  status: any;
67
68
  };
68
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<any>;
69
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<any>;
69
70
  parseTransaction(transaction: any, currency?: Currency): Transaction;
70
71
  parseTransactionStatus(status: any): string;
71
72
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
@@ -32,6 +32,7 @@ export default class whitebit extends Exchange {
32
32
  'future': false,
33
33
  'option': false,
34
34
  'cancelAllOrders': true,
35
+ 'cancelAllOrdersAfter': true,
35
36
  'cancelOrder': true,
36
37
  'cancelOrders': false,
37
38
  'createOrder': true,
@@ -1412,6 +1413,47 @@ export default class whitebit extends Exchange {
1412
1413
  //
1413
1414
  return response;
1414
1415
  }
1416
+ async cancelAllOrdersAfter(timeout, params = {}) {
1417
+ /**
1418
+ * @method
1419
+ * @name whitebit#cancelAllOrdersAfter
1420
+ * @description dead man's switch, cancel all orders after the given timeout
1421
+ * @see https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
1422
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1423
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1424
+ * @param {string} [params.types] Order types value. Example: "spot", "margin", "futures" or null
1425
+ * @param {string} [params.symbol] symbol unified symbol of the market the order was made in
1426
+ * @returns {object} the api result
1427
+ */
1428
+ await this.loadMarkets();
1429
+ const symbol = this.safeString(params, 'symbol');
1430
+ if (symbol === undefined) {
1431
+ throw new ArgumentsRequired(this.id + ' cancelAllOrdersAfter() requires a symbol argument in params');
1432
+ }
1433
+ const market = this.market(symbol);
1434
+ params = this.omit(params, 'symbol');
1435
+ const isBiggerThanZero = (timeout > 0);
1436
+ const request = {
1437
+ 'market': market['id'],
1438
+ // 'timeout': (timeout > 0) ? this.numberToString (timeout / 1000) : null,
1439
+ };
1440
+ if (isBiggerThanZero) {
1441
+ request['timeout'] = this.numberToString(timeout / 1000);
1442
+ }
1443
+ else {
1444
+ request['timeout'] = 'null';
1445
+ }
1446
+ const response = await this.v4PrivatePostOrderKillSwitch(this.extend(request, params));
1447
+ //
1448
+ // {
1449
+ // "market": "BTC_USDT", // currency market,
1450
+ // "startTime": 1662478154, // now timestamp,
1451
+ // "cancellationTime": 1662478154, // now + timer_value,
1452
+ // "types": ["spot", "margin"]
1453
+ // }
1454
+ //
1455
+ return response;
1456
+ }
1415
1457
  parseBalance(response) {
1416
1458
  const balanceKeys = Object.keys(response);
1417
1459
  const result = {};