ccxt 4.1.62 → 4.1.63

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.
@@ -2550,7 +2550,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2550
2550
  'createOrder': true,
2551
2551
  'fetchBalance': true,
2552
2552
  'fetchBidsAsks': false,
2553
- 'fetchClosedOrders': false,
2553
+ 'fetchClosedOrders': true,
2554
2554
  'fetchCurrencies': false,
2555
2555
  'fetchDepositAddress': false,
2556
2556
  'fetchDepositAddressesByNetwork': false,
@@ -2568,12 +2568,12 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2568
2568
  'fetchOpenOrders': true,
2569
2569
  'fetchOrder': true,
2570
2570
  'fetchOrderBook': true,
2571
- 'fetchOrders': false,
2571
+ 'fetchOrders': true,
2572
2572
  'fetchPositions': false,
2573
2573
  'fetchStatus': false,
2574
2574
  'fetchTicker': false,
2575
2575
  'fetchTickers': false,
2576
- 'fetchTime': false,
2576
+ 'fetchTime': true,
2577
2577
  'fetchTrades': true,
2578
2578
  'fetchTradingFee': false,
2579
2579
  'fetchTradingFees': false,
@@ -2761,42 +2761,90 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2761
2761
  },
2762
2762
  });
2763
2763
  }
2764
+ async fetchTime(params = {}) {
2765
+ /**
2766
+ * @method
2767
+ * @name alpaca#fetchTime
2768
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
2769
+ * @param {object} [params] extra parameters specific to the alpaca api endpoint
2770
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
2771
+ */
2772
+ const response = await this.traderPrivateGetV2Clock(params);
2773
+ //
2774
+ // {
2775
+ // timestamp: '2023-11-22T08:07:57.654738097-05:00',
2776
+ // is_open: false,
2777
+ // next_open: '2023-11-22T09:30:00-05:00',
2778
+ // next_close: '2023-11-22T16:00:00-05:00'
2779
+ // }
2780
+ //
2781
+ const timestamp = this.safeString(response, 'timestamp');
2782
+ const localTime = timestamp.slice(0, 23);
2783
+ const jetlagStrStart = timestamp.length - 6;
2784
+ const jetlagStrEnd = timestamp.length - 3;
2785
+ const jetlag = timestamp.slice(jetlagStrStart, jetlagStrEnd);
2786
+ const iso = this.parse8601(localTime) - this.parseToNumeric(jetlag) * 3600 * 1000;
2787
+ return iso;
2788
+ }
2764
2789
  async fetchMarkets(params = {}) {
2765
2790
  /**
2766
2791
  * @method
2767
2792
  * @name alpaca#fetchMarkets
2768
2793
  * @description retrieves data on all markets for alpaca
2794
+ * @see https://docs.alpaca.markets/reference/get-v2-assets
2769
2795
  * @param {object} [params] extra parameters specific to the exchange api endpoint
2770
2796
  * @returns {object[]} an array of objects representing market data
2771
2797
  */
2772
2798
  const request = {
2773
2799
  'asset_class': 'crypto',
2774
- 'tradeable': true,
2800
+ 'status': 'active',
2775
2801
  };
2776
2802
  const assets = await this.traderPrivateGetV2Assets(this.extend(request, params));
2777
2803
  //
2778
- // [
2779
- // {
2780
- // "id":"a3ba8ac0-166d-460b-b17a-1f035622dd47",
2781
- // "class":"crypto",
2782
- // "exchange":"FTXU",
2783
- // "symbol":"DOGEUSD",
2784
- // "name":"Dogecoin",
2785
- // "status":"active",
2786
- // "tradable":true,
2787
- // "marginable":false,
2788
- // "shortable":false,
2789
- // "easy_to_borrow":false,
2790
- // "fractionable":true,
2791
- // "min_order_size":"1",
2792
- // "min_trade_increment":"1",
2793
- // "price_increment":"0.0000005"
2794
- // }
2795
- // ]
2804
+ // [
2805
+ // {
2806
+ // "id": "c150e086-1e75-44e6-9c2c-093bb1e93139",
2807
+ // "class": "crypto",
2808
+ // "exchange": "CRYPTO",
2809
+ // "symbol": "BTC/USDT",
2810
+ // "name": "Bitcoin / USD Tether",
2811
+ // "status": "active",
2812
+ // "tradable": true,
2813
+ // "marginable": false,
2814
+ // "maintenance_margin_requirement": 100,
2815
+ // "shortable": false,
2816
+ // "easy_to_borrow": false,
2817
+ // "fractionable": true,
2818
+ // "attributes": [],
2819
+ // "min_order_size": "0.000026873",
2820
+ // "min_trade_increment": "0.000000001",
2821
+ // "price_increment": "1"
2822
+ // }
2823
+ // ]
2796
2824
  //
2797
2825
  return this.parseMarkets(assets);
2798
2826
  }
2799
2827
  parseMarket(asset) {
2828
+ //
2829
+ // {
2830
+ // "id": "c150e086-1e75-44e6-9c2c-093bb1e93139",
2831
+ // "class": "crypto",
2832
+ // "exchange": "CRYPTO",
2833
+ // "symbol": "BTC/USDT",
2834
+ // "name": "Bitcoin / USD Tether",
2835
+ // "status": "active",
2836
+ // "tradable": true,
2837
+ // "marginable": false,
2838
+ // "maintenance_margin_requirement": 100,
2839
+ // "shortable": false,
2840
+ // "easy_to_borrow": false,
2841
+ // "fractionable": true,
2842
+ // "attributes": [],
2843
+ // "min_order_size": "0.000026873",
2844
+ // "min_trade_increment": "0.000000001",
2845
+ // "price_increment": "1"
2846
+ // }
2847
+ //
2800
2848
  const marketId = this.safeString(asset, 'symbol');
2801
2849
  const parts = marketId.split('/');
2802
2850
  const baseId = this.safeString(parts, 0);
@@ -2936,21 +2984,17 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2936
2984
  return this.parseTrades(symbolTrades, market, since, limit);
2937
2985
  }
2938
2986
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2939
- //
2940
- // @method
2941
- // @name alpaca#fetchOrderBook
2942
- // @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
2943
- // @see https://docs.alpaca.markets/reference/cryptolatestorderbooks
2944
- // @param {string} symbol unified symbol of the market to fetch the order book for
2945
- // @param {int} [limit] the maximum amount of order book entries to return
2946
- // @param {object} [params] extra parameters specific to the alpaca api endpoint
2947
- // <<<<<<< HEAD
2948
- // @param {string} [params.loc] crypto location, default: us
2949
- // @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
2950
- // =======
2951
- // @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
2952
- // >>>>>>> f68b1b599ee41469fefa424f0efc9b6891549278
2953
- //
2987
+ /**
2988
+ * @method
2989
+ * @name alpaca#fetchOrderBook
2990
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
2991
+ * @see https://docs.alpaca.markets/reference/cryptolatestorderbooks
2992
+ * @param {string} symbol unified symbol of the market to fetch the order book for
2993
+ * @param {int} [limit] the maximum amount of order book entries to return
2994
+ * @param {object} [params] extra parameters specific to the alpaca api endpoint
2995
+ * @param {string} [params.loc] crypto location, default: us
2996
+ * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
2997
+ */
2954
2998
  await this.loadMarkets();
2955
2999
  const market = this.market(symbol);
2956
3000
  const id = market['id'];
@@ -3125,6 +3169,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3125
3169
  * @method
3126
3170
  * @name alpaca#createOrder
3127
3171
  * @description create a trade order
3172
+ * @see https://docs.alpaca.markets/reference/postorder
3128
3173
  * @param {string} symbol unified symbol of the market to create an order in
3129
3174
  * @param {string} type 'market', 'limit' or 'stop_limit'
3130
3175
  * @param {string} side 'buy' or 'sell'
@@ -3213,6 +3258,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3213
3258
  * @method
3214
3259
  * @name alpaca#cancelOrder
3215
3260
  * @description cancels an open order
3261
+ * @see https://docs.alpaca.markets/reference/deleteorderbyorderid
3216
3262
  * @param {string} id order id
3217
3263
  * @param {string} symbol unified symbol of the market the order was made in
3218
3264
  * @param {object} [params] extra parameters specific to the alpaca api endpoint
@@ -3230,11 +3276,31 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3230
3276
  //
3231
3277
  return this.safeValue(response, 'message', {});
3232
3278
  }
3279
+ async cancelAllOrders(symbol = undefined, params = {}) {
3280
+ /**
3281
+ * @method
3282
+ * @name alpaca#cancelAllOrders
3283
+ * @description cancel all open orders in a market
3284
+ * @see https://docs.alpaca.markets/reference/deleteallorders
3285
+ * @param {string} symbol alpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
3286
+ * @param {object} [params] extra parameters specific to the alpaca api endpoint
3287
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3288
+ */
3289
+ await this.loadMarkets();
3290
+ const response = await this.traderPrivateDeleteV2Orders(params);
3291
+ if (Array.isArray(response)) {
3292
+ return this.parseOrders(response, undefined);
3293
+ }
3294
+ else {
3295
+ return response;
3296
+ }
3297
+ }
3233
3298
  async fetchOrder(id, symbol = undefined, params = {}) {
3234
3299
  /**
3235
3300
  * @method
3236
3301
  * @name alpaca#fetchOrder
3237
3302
  * @description fetches information on an order made by the user
3303
+ * @see https://docs.alpaca.markets/reference/getorderbyorderid
3238
3304
  * @param {string} symbol unified symbol of the market the order was made in
3239
3305
  * @param {object} [params] extra parameters specific to the alpaca api endpoint
3240
3306
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -3248,24 +3314,117 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3248
3314
  const market = this.safeMarket(marketId);
3249
3315
  return this.parseOrder(order, market);
3250
3316
  }
3251
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3317
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3252
3318
  /**
3253
3319
  * @method
3254
- * @name alpaca#fetchOpenOrders
3255
- * @description fetch all unfilled currently open orders
3256
- * @param {string} symbol unified market symbol
3257
- * @param {int} [since] the earliest time in ms to fetch open orders for
3258
- * @param {int} [limit] the maximum number of open orders structures to retrieve
3320
+ * @name alpaca#fetchOrders
3321
+ * @description fetches information on multiple orders made by the user
3322
+ * @see https://docs.alpaca.markets/reference/getallorders
3323
+ * @param {string} symbol unified market symbol of the market orders were made in
3324
+ * @param {int} [since] the earliest time in ms to fetch orders for
3325
+ * @param {int} [limit] the maximum number of order structures to retrieve
3259
3326
  * @param {object} [params] extra parameters specific to the alpaca api endpoint
3327
+ * @param {int} [params.until] the latest time in ms to fetch orders for
3260
3328
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3261
3329
  */
3262
3330
  await this.loadMarkets();
3331
+ const request = {
3332
+ 'status': 'all',
3333
+ };
3263
3334
  let market = undefined;
3264
3335
  if (symbol !== undefined) {
3265
3336
  market = this.market(symbol);
3337
+ request['symbols'] = market['id'];
3266
3338
  }
3267
- const orders = await this.traderPrivateGetV2Orders(params);
3268
- return this.parseOrders(orders, market, since, limit);
3339
+ const until = this.safeInteger(params, 'until');
3340
+ if (until !== undefined) {
3341
+ params = this.omit(params, 'until');
3342
+ request['endTime'] = until;
3343
+ }
3344
+ if (since !== undefined) {
3345
+ request['after'] = since;
3346
+ }
3347
+ if (limit !== undefined) {
3348
+ request['limit'] = limit;
3349
+ }
3350
+ const response = await this.traderPrivateGetV2Orders(this.extend(request, params));
3351
+ //
3352
+ // [
3353
+ // {
3354
+ // "id": "cbaf12d7-69b8-49c0-a31b-b46af35c755c",
3355
+ // "client_order_id": "ccxt_b36156ae6fd44d098ac9c179bab33efd",
3356
+ // "created_at": "2023-11-17T04:21:42.234579Z",
3357
+ // "updated_at": "2023-11-17T04:22:34.442765Z",
3358
+ // "submitted_at": "2023-11-17T04:21:42.233357Z",
3359
+ // "filled_at": null,
3360
+ // "expired_at": null,
3361
+ // "canceled_at": "2023-11-17T04:22:34.399019Z",
3362
+ // "failed_at": null,
3363
+ // "replaced_at": null,
3364
+ // "replaced_by": null,
3365
+ // "replaces": null,
3366
+ // "asset_id": "77c6f47f-0939-4b23-b41e-47b4469c4bc8",
3367
+ // "symbol": "LTC/USDT",
3368
+ // "asset_class": "crypto",
3369
+ // "notional": null,
3370
+ // "qty": "0.001",
3371
+ // "filled_qty": "0",
3372
+ // "filled_avg_price": null,
3373
+ // "order_class": "",
3374
+ // "order_type": "limit",
3375
+ // "type": "limit",
3376
+ // "side": "sell",
3377
+ // "time_in_force": "gtc",
3378
+ // "limit_price": "1000",
3379
+ // "stop_price": null,
3380
+ // "status": "canceled",
3381
+ // "extended_hours": false,
3382
+ // "legs": null,
3383
+ // "trail_percent": null,
3384
+ // "trail_price": null,
3385
+ // "hwm": null,
3386
+ // "subtag": null,
3387
+ // "source": "access_key"
3388
+ // }
3389
+ // ]
3390
+ //
3391
+ return this.parseOrders(response, market, since, limit);
3392
+ }
3393
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3394
+ /**
3395
+ * @method
3396
+ * @name alpaca#fetchOpenOrders
3397
+ * @description fetch all unfilled currently open orders
3398
+ * @see https://docs.alpaca.markets/reference/getallorders
3399
+ * @param {string} symbol unified market symbol of the market orders were made in
3400
+ * @param {int} [since] the earliest time in ms to fetch orders for
3401
+ * @param {int} [limit] the maximum number of order structures to retrieve
3402
+ * @param {object} [params] extra parameters specific to the alpaca api endpoint
3403
+ * @param {int} [params.until] the latest time in ms to fetch orders for
3404
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3405
+ */
3406
+ const request = {
3407
+ 'status': 'open',
3408
+ };
3409
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
3410
+ }
3411
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3412
+ /**
3413
+ * @method
3414
+ * @name alpaca#fetchClosedOrders
3415
+ * @description fetches information on multiple closed orders made by the user
3416
+ * @see https://docs.alpaca.markets/reference/getallorders
3417
+ * @param {string} symbol unified market symbol of the market orders were made in
3418
+ * @param {int} [since] the earliest time in ms to fetch orders for
3419
+ * @param {int} [limit] the maximum number of order structures to retrieve
3420
+ * @param {object} [params] extra parameters specific to the alpaca api endpoint
3421
+ * @param {int} [params.until] the latest time in ms to fetch orders for
3422
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3423
+ */
3424
+ const request = {
3425
+ 'status': 'closed',
3426
+ };
3427
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
3269
3428
  }
3270
3429
  parseOrder(order, market = undefined) {
3271
3430
  //
@@ -3320,9 +3479,11 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3320
3479
  };
3321
3480
  }
3322
3481
  let orderType = this.safeString(order, 'order_type');
3323
- if (orderType.indexOf('limit') >= 0) {
3324
- // might be limit or stop-limit
3325
- orderType = 'limit';
3482
+ if (orderType !== undefined) {
3483
+ if (orderType.indexOf('limit') >= 0) {
3484
+ // might be limit or stop-limit
3485
+ orderType = 'limit';
3486
+ }
3326
3487
  }
3327
3488
  const datetime = this.safeString(order, 'submitted_at');
3328
3489
  const timestamp = this.parse8601(datetime);
@@ -17543,7 +17704,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17543
17704
  'cm/income': 30,
17544
17705
  'um/account': 5,
17545
17706
  'cm/account': 5,
17546
- 'portfolio/repay-futures-switch': 3,
17707
+ 'repay-futures-switch': 3,
17547
17708
  'um/adlQuantile': 5,
17548
17709
  'cm/adlQuantile': 5,
17549
17710
  },
@@ -17562,8 +17723,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17562
17723
  'cm/positionSide/dual': 1,
17563
17724
  'auto-collection': 0.6667,
17564
17725
  'bnb-transfer': 0.6667,
17565
- 'portfolio/repay-futures-switch': 150,
17566
- 'portfolio/repay-futures-negative-balance': 150,
17726
+ 'repay-futures-switch': 150,
17727
+ 'repay-futures-negative-balance': 150,
17567
17728
  'listenKey': 1,
17568
17729
  'asset-collection': 3,
17569
17730
  },
@@ -158667,12 +158828,6 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
158667
158828
  'futuresPublic': 'https://api-futures.kucoin.com',
158668
158829
  'webExchange': 'https://futures.kucoin.com/_api/web-front',
158669
158830
  },
158670
- 'test': {
158671
- 'public': 'https://openapi-sandbox.kucoin.com',
158672
- 'private': 'https://openapi-sandbox.kucoin.com',
158673
- 'futuresPrivate': 'https://api-sandbox-futures.kucoin.com',
158674
- 'futuresPublic': 'https://api-sandbox-futures.kucoin.com',
158675
- },
158676
158831
  },
158677
158832
  'requiredCredentials': {
158678
158833
  'apiKey': true,
@@ -158897,6 +159052,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
158897
159052
  * @method
158898
159053
  * @name kucoinfutures#fetchStatus
158899
159054
  * @description the latest known information on the availability of the exchange API
159055
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-service-status
158900
159056
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
158901
159057
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
158902
159058
  */
@@ -158925,6 +159081,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
158925
159081
  * @method
158926
159082
  * @name kucoinfutures#fetchMarkets
158927
159083
  * @description retrieves data on all markets for kucoinfutures
159084
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
158928
159085
  * @param {object} [params] extra parameters specific to the exchange api endpoint
158929
159086
  * @returns {object[]} an array of objects representing market data
158930
159087
  */
@@ -159089,6 +159246,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159089
159246
  * @method
159090
159247
  * @name kucoinfutures#fetchTime
159091
159248
  * @description fetches the current integer timestamp in milliseconds from the exchange server
159249
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-server-time
159092
159250
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
159093
159251
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
159094
159252
  */
@@ -159106,6 +159264,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159106
159264
  * @method
159107
159265
  * @name kucoinfutures#fetchOHLCV
159108
159266
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
159267
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-klines
159109
159268
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
159110
159269
  * @param {string} timeframe the length of time each candle represents
159111
159270
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -159186,6 +159345,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159186
159345
  * @method
159187
159346
  * @name kucoinfutures#fetchDepositAddress
159188
159347
  * @description fetch the deposit address for a currency associated with this account
159348
+ * @see https://www.kucoin.com/docs/rest/funding/deposit/get-deposit-address
159189
159349
  * @param {string} code unified currency code
159190
159350
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
159191
159351
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -159225,6 +159385,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159225
159385
  * @method
159226
159386
  * @name kucoinfutures#fetchOrderBook
159227
159387
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
159388
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-part-order-book-level-2
159228
159389
  * @param {string} symbol unified symbol of the market to fetch the order book for
159229
159390
  * @param {int} [limit] the maximum amount of order book entries to return
159230
159391
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -159283,6 +159444,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159283
159444
  * @method
159284
159445
  * @name kucoinfutures#fetchTicker
159285
159446
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
159447
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-ticker
159286
159448
  * @param {string} symbol unified symbol of the market to fetch the ticker for
159287
159449
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
159288
159450
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -159364,6 +159526,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159364
159526
  * @method
159365
159527
  * @name kucoinfutures#fetchFundingHistory
159366
159528
  * @description fetch the history of funding payments paid and received on this account
159529
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-funding-history
159367
159530
  * @param {string} symbol unified market symbol
159368
159531
  * @param {int} [since] the earliest time in ms to fetch funding history for
159369
159532
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -159800,6 +159963,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159800
159963
  * @method
159801
159964
  * @name kucoinfutures#cancelOrder
159802
159965
  * @description cancels an open order
159966
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-futures-order-by-orderid
159803
159967
  * @param {string} id order id
159804
159968
  * @param {string} symbol unified symbol of the market the order was made in
159805
159969
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -159827,6 +159991,8 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159827
159991
  * @method
159828
159992
  * @name kucoinfutures#cancelAllOrders
159829
159993
  * @description cancel all open orders
159994
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-limit-orders
159995
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders
159830
159996
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
159831
159997
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
159832
159998
  * @param {object} [params.stop] When true, all the trigger orders will be cancelled
@@ -159838,8 +160004,14 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159838
160004
  request['symbol'] = this.marketId(symbol);
159839
160005
  }
159840
160006
  const stop = this.safeValue(params, 'stop');
159841
- const method = stop ? 'futuresPrivateDeleteStopOrders' : 'futuresPrivateDeleteOrders';
159842
- const response = await this[method](this.extend(request, params));
160007
+ params = this.omit(params, 'stop');
160008
+ let response = undefined;
160009
+ if (stop) {
160010
+ response = await this.futuresPrivateDeleteStopOrders(this.extend(request, params));
160011
+ }
160012
+ else {
160013
+ response = await this.futuresPrivateDeleteOrders(this.extend(request, params));
160014
+ }
159843
160015
  //
159844
160016
  // {
159845
160017
  // "code": "200000",
@@ -159857,6 +160029,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159857
160029
  * @method
159858
160030
  * @name kucoinfutures#addMargin
159859
160031
  * @description add margin
160032
+ * @see https://www.kucoin.com/docs/rest/futures-trading/positions/add-margin-manually
159860
160033
  * @param {string} symbol unified market symbol
159861
160034
  * @param {float} amount amount of margin to add
159862
160035
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -160040,8 +160213,13 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160040
160213
  if (until !== undefined) {
160041
160214
  request['endAt'] = until;
160042
160215
  }
160043
- const method = stop ? 'futuresPrivateGetStopOrders' : 'futuresPrivateGetOrders';
160044
- const response = await this[method](this.extend(request, params));
160216
+ let response = undefined;
160217
+ if (stop) {
160218
+ response = await this.futuresPrivateGetStopOrders(this.extend(request, params));
160219
+ }
160220
+ else {
160221
+ response = await this.futuresPrivateGetOrders(this.extend(request, params));
160222
+ }
160045
160223
  //
160046
160224
  // {
160047
160225
  // "code": "200000",
@@ -160133,20 +160311,20 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160133
160311
  */
160134
160312
  await this.loadMarkets();
160135
160313
  const request = {};
160136
- let method = 'futuresPrivateGetOrdersOrderId';
160314
+ let response = undefined;
160137
160315
  if (id === undefined) {
160138
160316
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
160139
160317
  if (clientOrderId === undefined) {
160140
160318
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' fetchOrder() requires parameter id or params.clientOid');
160141
160319
  }
160142
160320
  request['clientOid'] = clientOrderId;
160143
- method = 'futuresPrivateGetOrdersByClientOid';
160144
160321
  params = this.omit(params, ['clientOid', 'clientOrderId']);
160322
+ response = await this.futuresPrivateGetOrdersByClientOid(this.extend(request, params));
160145
160323
  }
160146
160324
  else {
160147
160325
  request['orderId'] = id;
160326
+ response = await this.futuresPrivateGetOrdersOrderId(this.extend(request, params));
160148
160327
  }
160149
- const response = await this[method](this.extend(request, params));
160150
160328
  //
160151
160329
  // {
160152
160330
  // "code": "200000",
@@ -160311,6 +160489,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160311
160489
  * @method
160312
160490
  * @name kucoinfutures#fetchFundingRate
160313
160491
  * @description fetch the current funding rate
160492
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-funding-rate
160314
160493
  * @param {string} symbol unified market symbol
160315
160494
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
160316
160495
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -160376,6 +160555,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160376
160555
  * @method
160377
160556
  * @name kucoinfutures#fetchBalance
160378
160557
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
160558
+ * @see https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-futures
160379
160559
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
160380
160560
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
160381
160561
  */
@@ -160553,6 +160733,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160553
160733
  * @method
160554
160734
  * @name kucoinfutures#fetchTrades
160555
160735
  * @description get the list of most recent trades for a particular symbol
160736
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-transaction-history
160556
160737
  * @param {string} symbol unified symbol of the market to fetch trades for
160557
160738
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
160558
160739
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -160835,6 +161016,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160835
161016
  * @method
160836
161017
  * @name kucoinfutures#fetchMarketLeverageTiers
160837
161018
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
161019
+ * @see https://www.kucoin.com/docs/rest/futures-trading/risk-limit/get-futures-risk-limit-level
160838
161020
  * @param {string} symbol unified market symbol
160839
161021
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
160840
161022
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
@@ -245842,8 +246024,8 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
245842
246024
  /* harmony export */ });
245843
246025
  /* harmony import */ var _poloniex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8891);
245844
246026
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
245845
- /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3020);
245846
- /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2194);
246027
+ /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3020);
246028
+ /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
245847
246029
  /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1372);
245848
246030
  // ---------------------------------------------------------------------------
245849
246031
 
@@ -245866,6 +246048,15 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
245866
246048
  'watchStatus': false,
245867
246049
  'watchOrders': true,
245868
246050
  'watchMyTrades': true,
246051
+ 'createOrderWs': true,
246052
+ 'editOrderWs': false,
246053
+ 'fetchOpenOrdersWs': false,
246054
+ 'fetchOrderWs': false,
246055
+ 'cancelOrderWs': true,
246056
+ 'cancelOrdersWs': true,
246057
+ 'cancelAllOrdersWs': true,
246058
+ 'fetchTradesWs': false,
246059
+ 'fetchBalanceWs': false,
245869
246060
  },
245870
246061
  'urls': {
245871
246062
  'api': {
@@ -245876,6 +246067,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
245876
246067
  },
245877
246068
  },
245878
246069
  'options': {
246070
+ 'createMarketBuyOrderRequiresPrice': true,
245879
246071
  'tradesLimit': 1000,
245880
246072
  'ordersLimit': 1000,
245881
246073
  'OHLCVLimit': 1000,
@@ -245995,6 +246187,164 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
245995
246187
  const request = this.extend(subscribe, params);
245996
246188
  return await this.watch(url, messageHash, request, messageHash);
245997
246189
  }
246190
+ async tradeRequest(name, params = {}) {
246191
+ /**
246192
+ * @ignore
246193
+ * @method
246194
+ * @description Connects to a websocket channel
246195
+ * @param {string} name name of the channel
246196
+ * @param {string[]|undefined} symbols CCXT market symbols
246197
+ * @param {object} [params] extra parameters specific to the poloniex api
246198
+ * @returns {object} data from the websocket stream
246199
+ */
246200
+ const url = this.urls['api']['ws']['private'];
246201
+ const messageHash = this.nonce();
246202
+ const subscribe = {
246203
+ 'id': messageHash,
246204
+ 'event': name,
246205
+ 'params': params,
246206
+ };
246207
+ return await this.watch(url, messageHash, subscribe, messageHash);
246208
+ }
246209
+ async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
246210
+ /**
246211
+ * @method
246212
+ * @name poloniex#createOrderWs
246213
+ * @see https://docs.poloniex.com/#authenticated-channels-trade-requests-create-order
246214
+ * @description create a trade order
246215
+ * @param {string} symbol unified symbol of the market to create an order in
246216
+ * @param {string} type 'market' or 'limit'
246217
+ * @param {string} side 'buy' or 'sell'
246218
+ * @param {float} amount how much of currency you want to trade in units of base currency
246219
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
246220
+ * @param {object} [params] extra parameters specific to the poloniex api endpoint
246221
+ * @param {string} [params.timeInForce] GTC (default), IOC, FOK
246222
+ * @param {string} [params.clientOrderId] Maximum 64-character length.*
246223
+ *
246224
+ * EXCHANGE SPECIFIC PARAMETERS
246225
+ * @param {string} [params.amount] quote units for the order
246226
+ * @param {boolean} [params.allowBorrow] allow order to be placed by borrowing funds (Default: false)
246227
+ * @param {string} [params.stpMode] self-trade prevention, defaults to expire_taker, none: enable self-trade; expire_taker: taker order will be canceled when self-trade happens
246228
+ * @param {string} [params.slippageTolerance] used to control the maximum slippage ratio, the value range is greater than 0 and less than 1
246229
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
246230
+ */
246231
+ await this.loadMarkets();
246232
+ await this.authenticate();
246233
+ const market = this.market(symbol);
246234
+ let uppercaseType = type.toUpperCase();
246235
+ const uppercaseSide = side.toUpperCase();
246236
+ const isPostOnly = this.isPostOnly(uppercaseType === 'MARKET', uppercaseType === 'LIMIT_MAKER', params);
246237
+ if (isPostOnly) {
246238
+ uppercaseType = 'LIMIT_MAKER';
246239
+ }
246240
+ const request = {
246241
+ 'symbol': market['id'],
246242
+ 'side': side.toUpperCase(),
246243
+ 'type': type.toUpperCase(),
246244
+ };
246245
+ if ((uppercaseType === 'MARKET') && (uppercaseSide === 'BUY')) {
246246
+ let quoteAmount = this.safeString(params, 'amount');
246247
+ if ((quoteAmount === undefined) && (this.options['createMarketBuyOrderRequiresPrice'])) {
246248
+ const cost = this.safeNumber(params, 'cost');
246249
+ params = this.omit(params, 'cost');
246250
+ if (price === undefined && cost === undefined) {
246251
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');
246252
+ }
246253
+ else {
246254
+ const amountString = this.numberToString(amount);
246255
+ const priceString = this.numberToString(price);
246256
+ const quote = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString);
246257
+ amount = (cost !== undefined) ? cost : this.parseNumber(quote);
246258
+ quoteAmount = this.costToPrecision(symbol, amount);
246259
+ }
246260
+ }
246261
+ else {
246262
+ quoteAmount = this.costToPrecision(symbol, amount);
246263
+ }
246264
+ request['amount'] = this.amountToPrecision(market['symbol'], quoteAmount);
246265
+ }
246266
+ else {
246267
+ request['quantity'] = this.amountToPrecision(market['symbol'], amount);
246268
+ if (price !== undefined) {
246269
+ request['price'] = this.priceToPrecision(symbol, price);
246270
+ }
246271
+ }
246272
+ return await this.tradeRequest('createOrder', this.extend(request, params));
246273
+ }
246274
+ async cancelOrderWs(id, symbol = undefined, params = {}) {
246275
+ /**
246276
+ * @method
246277
+ * @name poloniex#cancelOrderWs
246278
+ * @see https://docs.poloniex.com/#authenticated-channels-trade-requests-cancel-multiple-orders
246279
+ * @description cancel multiple orders
246280
+ * @param {string} id order id
246281
+ * @param {string} [symbol] unified market symbol
246282
+ * @param {object} [params] extra parameters specific to the poloniex api endpoint
246283
+ * @param {string} [params.clientOrderId] client order id
246284
+ * @returns {object} an list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
246285
+ */
246286
+ const clientOrderId = this.safeString(params, 'clientOrderId');
246287
+ if (clientOrderId !== undefined) {
246288
+ const clientOrderIds = this.safeValue(params, 'clientOrderId', []);
246289
+ params['clientOrderIds'] = this.arrayConcat(clientOrderIds, [clientOrderId]);
246290
+ }
246291
+ return await this.cancelOrdersWs([id], symbol, params);
246292
+ }
246293
+ async cancelOrdersWs(ids, symbol = undefined, params = {}) {
246294
+ /**
246295
+ * @method
246296
+ * @name poloniex#cancelOrdersWs
246297
+ * @see https://docs.poloniex.com/#authenticated-channels-trade-requests-cancel-multiple-orders
246298
+ * @description cancel multiple orders
246299
+ * @param {string[]} ids order ids
246300
+ * @param {string} symbol unified market symbol, default is undefined
246301
+ * @param {object} [params] extra parameters specific to the poloniex api endpoint
246302
+ * @param {string[]} [params.clientOrderIds] client order ids
246303
+ * @returns {object} an list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
246304
+ */
246305
+ await this.loadMarkets();
246306
+ await this.authenticate();
246307
+ const request = {
246308
+ 'orderIds': ids,
246309
+ };
246310
+ return await this.tradeRequest('cancelOrders', this.extend(request, params));
246311
+ }
246312
+ async cancelAllOrdersWs(symbol = undefined, params = {}) {
246313
+ /**
246314
+ * @method
246315
+ * @name poloniex#cancelAllOrdersWs
246316
+ * @see https://docs.poloniex.com/#authenticated-channels-trade-requests-cancel-all-orders
246317
+ * @description cancel all open orders of a type. Only applicable to Option in Portfolio Margin mode, and MMP privilege is required.
246318
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
246319
+ * @param {object} [params] extra parameters specific to the poloniex api endpoint
246320
+ * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
246321
+ */
246322
+ await this.loadMarkets();
246323
+ await this.authenticate();
246324
+ return await this.tradeRequest('cancelAllOrders', params);
246325
+ }
246326
+ handleOrderRequest(client, message) {
246327
+ //
246328
+ // {
246329
+ // "id": "1234567",
246330
+ // "data": [{
246331
+ // "orderId": 205343650954092544,
246332
+ // "clientOrderId": "",
246333
+ // "message": "",
246334
+ // "code": 200
246335
+ // }]
246336
+ // }
246337
+ //
246338
+ const messageHash = this.safeInteger(message, 'id');
246339
+ const data = this.safeValue(message, 'data', []);
246340
+ const orders = [];
246341
+ for (let i = 0; i < data.length; i++) {
246342
+ const order = data[i];
246343
+ const parsedOrder = this.parseWsOrder(order);
246344
+ orders.push(parsedOrder);
246345
+ }
246346
+ client.resolve(orders, messageHash);
246347
+ }
245998
246348
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
245999
246349
  /**
246000
246350
  * @method
@@ -246218,7 +246568,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246218
246568
  if (symbol !== undefined) {
246219
246569
  if (stored === undefined) {
246220
246570
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
246221
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheByTimestamp */ .Py(limit);
246571
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheByTimestamp */ .Py(limit);
246222
246572
  this.ohlcvs[symbol][timeframe] = stored;
246223
246573
  }
246224
246574
  stored.append(parsed);
@@ -246256,7 +246606,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246256
246606
  let tradesArray = this.safeValue(this.trades, symbol);
246257
246607
  if (tradesArray === undefined) {
246258
246608
  const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
246259
- tradesArray = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCache */ .ZL(tradesLimit);
246609
+ tradesArray = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCache */ .ZL(tradesLimit);
246260
246610
  this.trades[symbol] = tradesArray;
246261
246611
  }
246262
246612
  tradesArray.append(trade);
@@ -246435,7 +246785,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246435
246785
  let orders = this.orders;
246436
246786
  if (orders === undefined) {
246437
246787
  const limit = this.safeInteger(this.options, 'ordersLimit');
246438
- orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(limit);
246788
+ orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheBySymbolById */ .hl(limit);
246439
246789
  this.orders = orders;
246440
246790
  }
246441
246791
  const marketIds = [];
@@ -246468,21 +246818,21 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246468
246818
  const previousOrderTrade = previousOrderTrades[j];
246469
246819
  const cost = this.numberToString(previousOrderTrade['cost']);
246470
246820
  const amount = this.numberToString(previousOrderTrade['amount']);
246471
- totalCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringAdd(totalCost, cost);
246472
- totalAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringAdd(totalAmount, amount);
246821
+ totalCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(totalCost, cost);
246822
+ totalAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(totalAmount, amount);
246473
246823
  }
246474
- if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringGt(totalAmount, '0')) {
246475
- previousOrder['average'] = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringDiv(totalCost, totalAmount));
246824
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringGt(totalAmount, '0')) {
246825
+ previousOrder['average'] = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(totalCost, totalAmount));
246476
246826
  }
246477
246827
  previousOrder['cost'] = this.parseNumber(totalCost);
246478
246828
  if (previousOrder['filled'] !== undefined) {
246479
246829
  const tradeAmount = this.numberToString(trade['amount']);
246480
246830
  let previousOrderFilled = this.numberToString(previousOrder['filled']);
246481
- previousOrderFilled = _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringAdd(previousOrderFilled, tradeAmount);
246831
+ previousOrderFilled = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(previousOrderFilled, tradeAmount);
246482
246832
  previousOrder['filled'] = previousOrderFilled;
246483
246833
  if (previousOrder['amount'] !== undefined) {
246484
246834
  const previousOrderAmount = this.numberToString(previousOrder['amount']);
246485
- previousOrder['remaining'] = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringSub(previousOrderAmount, previousOrderFilled));
246835
+ previousOrder['remaining'] = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringSub(previousOrderAmount, previousOrderFilled));
246486
246836
  }
246487
246837
  }
246488
246838
  if (previousOrder['fee'] === undefined) {
@@ -246495,7 +246845,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246495
246845
  if ((previousOrder['fee']['cost'] !== undefined) && (trade['fee']['cost'] !== undefined)) {
246496
246846
  const stringOrderCost = this.numberToString(previousOrder['fee']['cost']);
246497
246847
  const stringTradeCost = this.numberToString(trade['fee']['cost']);
246498
- previousOrder['fee']['cost'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringAdd(stringOrderCost, stringTradeCost);
246848
+ previousOrder['fee']['cost'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(stringOrderCost, stringTradeCost);
246499
246849
  }
246500
246850
  const rawState = this.safeString(order, 'state');
246501
246851
  const state = this.parseStatus(rawState);
@@ -246552,7 +246902,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246552
246902
  const filledAmount = this.safeString(order, 'filledAmount');
246553
246903
  const status = this.safeString(order, 'state');
246554
246904
  let trades = undefined;
246555
- if (!_base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise */ .O.stringEq(filledAmount, '0')) {
246905
+ if (!_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringEq(filledAmount, '0')) {
246556
246906
  trades = [];
246557
246907
  const trade = this.parseWsOrderTrade(order);
246558
246908
  trades.push(trade);
@@ -246793,7 +247143,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246793
247143
  const symbol = parsedTrade['symbol'];
246794
247144
  if (this.myTrades === undefined) {
246795
247145
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
246796
- this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(limit);
247146
+ this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheBySymbolById */ .hl(limit);
246797
247147
  }
246798
247148
  const trades = this.myTrades;
246799
247149
  trades.append(parsedTrade);
@@ -246801,6 +247151,9 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246801
247151
  const symbolMessageHash = messageHash + ':' + symbol;
246802
247152
  client.resolve(trades, symbolMessageHash);
246803
247153
  }
247154
+ handlePong(client) {
247155
+ client.lastPong = this.milliseconds();
247156
+ }
246804
247157
  handleMessage(client, message) {
246805
247158
  if (this.handleErrorMessage(client, message)) {
246806
247159
  return;
@@ -246831,11 +247184,26 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246831
247184
  'trades': this.handleTrade,
246832
247185
  'orders': this.handleOrder,
246833
247186
  'balances': this.handleBalance,
247187
+ 'createOrder': this.handleOrderRequest,
247188
+ 'cancelOrder': this.handleOrderRequest,
247189
+ 'cancelAllOrders': this.handleOrderRequest,
247190
+ 'auth': this.handleAuthenticate,
246834
247191
  };
246835
247192
  const method = this.safeValue(methods, type);
246836
247193
  if (type === 'auth') {
246837
247194
  this.handleAuthenticate(client, message);
246838
247195
  }
247196
+ else if (type === undefined) {
247197
+ const data = this.safeValue(message, 'data');
247198
+ const item = this.safeValue(data, 0);
247199
+ const orderId = this.safeString(item, 'orderId');
247200
+ if (orderId === '0') {
247201
+ this.handleErrorMessage(client, item);
247202
+ }
247203
+ else {
247204
+ return this.handleOrderRequest(client, message);
247205
+ }
247206
+ }
246839
247207
  else {
246840
247208
  const data = this.safeValue(message, 'data', []);
246841
247209
  const dataLength = data.length;
@@ -246846,9 +247214,26 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
246846
247214
  }
246847
247215
  handleErrorMessage(client, message) {
246848
247216
  //
246849
- // { message: 'Invalid channel value ["ordersss"]', event: 'error' }
247217
+ // {
247218
+ // message: 'Invalid channel value ["ordersss"]',
247219
+ // event: 'error'
247220
+ // }
247221
+ //
247222
+ // {
247223
+ // "orderId": 0,
247224
+ // "clientOrderId": null,
247225
+ // "message": "Currency trade disabled",
247226
+ // "code": 21352
247227
+ // }
247228
+ //
247229
+ // {
247230
+ // "event": "error",
247231
+ // "message": "Platform in maintenance mode"
247232
+ // }
247233
+ //
246850
247234
  const event = this.safeString(message, 'event');
246851
- if (event === 'error') {
247235
+ const orderId = this.safeString(message, 'orderId');
247236
+ if ((event === 'error') || (orderId === '0')) {
246852
247237
  const error = this.safeString(message, 'message');
246853
247238
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' error: ' + this.json(error));
246854
247239
  }
@@ -287082,7 +287467,7 @@ SOFTWARE.
287082
287467
 
287083
287468
  //-----------------------------------------------------------------------------
287084
287469
  // this is updated by vss.js when building
287085
- const version = '4.1.62';
287470
+ const version = '4.1.63';
287086
287471
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
287087
287472
  //-----------------------------------------------------------------------------
287088
287473