ccxt 4.1.29 → 4.1.31

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 (61) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +474 -135
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +89 -12
  7. package/dist/cjs/src/base/Exchange.js +6 -0
  8. package/dist/cjs/src/base/ws/Future.js +6 -2
  9. package/dist/cjs/src/bitget.js +187 -44
  10. package/dist/cjs/src/bitopro.js +5 -4
  11. package/dist/cjs/src/bitrue.js +33 -18
  12. package/dist/cjs/src/bitvavo.js +43 -7
  13. package/dist/cjs/src/bybit.js +0 -3
  14. package/dist/cjs/src/coinex.js +2 -1
  15. package/dist/cjs/src/gate.js +58 -10
  16. package/dist/cjs/src/gemini.js +1 -2
  17. package/dist/cjs/src/hitbtc.js +32 -22
  18. package/dist/cjs/src/huobi.js +0 -1
  19. package/dist/cjs/src/huobijp.js +0 -1
  20. package/dist/cjs/src/krakenfutures.js +1 -1
  21. package/dist/cjs/src/mexc.js +2 -6
  22. package/dist/cjs/src/okx.js +1 -0
  23. package/dist/cjs/src/phemex.js +3 -0
  24. package/dist/cjs/src/pro/huobi.js +4 -0
  25. package/js/ccxt.d.ts +3 -3
  26. package/js/ccxt.js +1 -1
  27. package/js/src/ascendex.d.ts +11 -1
  28. package/js/src/ascendex.js +89 -12
  29. package/js/src/base/Exchange.d.ts +5 -3
  30. package/js/src/base/Exchange.js +6 -0
  31. package/js/src/base/types.d.ts +9 -0
  32. package/js/src/base/ws/Future.js +6 -2
  33. package/js/src/binance.d.ts +1 -1
  34. package/js/src/bitget.d.ts +3 -3
  35. package/js/src/bitget.js +187 -44
  36. package/js/src/bitopro.js +5 -4
  37. package/js/src/bitrue.js +33 -18
  38. package/js/src/bitvavo.d.ts +13 -13
  39. package/js/src/bitvavo.js +43 -7
  40. package/js/src/bybit.js +0 -3
  41. package/js/src/coinex.d.ts +2 -2
  42. package/js/src/coinex.js +2 -1
  43. package/js/src/gate.d.ts +3 -3
  44. package/js/src/gate.js +58 -10
  45. package/js/src/gemini.js +1 -2
  46. package/js/src/hitbtc.js +33 -23
  47. package/js/src/huobi.d.ts +1 -1
  48. package/js/src/huobi.js +0 -1
  49. package/js/src/huobijp.js +0 -1
  50. package/js/src/krakenfutures.js +1 -1
  51. package/js/src/kucoinfutures.d.ts +2 -2
  52. package/js/src/mexc.d.ts +2 -2
  53. package/js/src/mexc.js +2 -6
  54. package/js/src/okx.d.ts +2 -2
  55. package/js/src/okx.js +1 -0
  56. package/js/src/phemex.d.ts +2 -2
  57. package/js/src/phemex.js +3 -0
  58. package/js/src/poloniexfutures.d.ts +2 -2
  59. package/js/src/pro/huobi.js +4 -0
  60. package/js/src/woo.d.ts +1 -1
  61. package/package.json +2 -2
@@ -796,6 +796,16 @@ class bitrue extends bitrue$1 {
796
796
  return orderbook;
797
797
  }
798
798
  parseTicker(ticker, market = undefined) {
799
+ //
800
+ // fetchBidsAsks
801
+ //
802
+ // {
803
+ // "symbol": "LTCBTC",
804
+ // "bidPrice": "4.00000000",
805
+ // "bidQty": "431.00000000",
806
+ // "askPrice": "4.00000200",
807
+ // "askQty": "9.00000000"
808
+ // }
799
809
  //
800
810
  // fetchTicker
801
811
  //
@@ -820,10 +830,10 @@ class bitrue extends bitrue$1 {
820
830
  'datetime': undefined,
821
831
  'high': this.safeString(ticker, 'high24hr'),
822
832
  'low': this.safeString(ticker, 'low24hr'),
823
- 'bid': this.safeString(ticker, 'highestBid'),
824
- 'bidVolume': undefined,
825
- 'ask': this.safeString(ticker, 'lowestAsk'),
826
- 'askVolume': undefined,
833
+ 'bid': this.safeString2(ticker, 'highestBid', 'bidPrice'),
834
+ 'bidVolume': this.safeString(ticker, 'bidQty'),
835
+ 'ask': this.safeString2(ticker, 'lowestAsk', 'askPrice'),
836
+ 'askVolume': this.safeString(ticker, 'askQty'),
827
837
  'vwap': undefined,
828
838
  'open': undefined,
829
839
  'close': last,
@@ -951,26 +961,31 @@ class bitrue extends bitrue$1 {
951
961
  * @method
952
962
  * @name bitrue#fetchBidsAsks
953
963
  * @description fetches the bid and ask price and volume for multiple markets
964
+ * @see https://github.com/Bitrue-exchange/Spot-official-api-docs#symbol-order-book-ticker
954
965
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
955
966
  * @param {object} [params] extra parameters specific to the bitrue api endpoint
956
967
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
957
968
  */
958
969
  await this.loadMarkets();
959
- const defaultType = this.safeString2(this.options, 'fetchBidsAsks', 'defaultType', 'spot');
960
- const type = this.safeString(params, 'type', defaultType);
961
- const query = this.omit(params, 'type');
962
- let method = undefined;
963
- if (type === 'future') {
964
- method = 'fapiPublicGetTickerBookTicker';
965
- }
966
- else if (type === 'delivery') {
967
- method = 'dapiPublicGetTickerBookTicker';
968
- }
969
- else {
970
- method = 'publicGetTickerBookTicker';
970
+ symbols = this.marketSymbols(symbols);
971
+ let market = undefined;
972
+ const request = {};
973
+ if (symbols !== undefined) {
974
+ const first = this.safeString(symbols, 0);
975
+ market = this.market(first);
976
+ request['symbol'] = market['id'];
971
977
  }
972
- const response = await this[method](query);
973
- return this.parseTickers(response, symbols);
978
+ const response = await this.v1PublicGetTickerBookTicker(this.extend(request, params));
979
+ // {
980
+ // "symbol": "LTCBTC",
981
+ // "bidPrice": "4.00000000",
982
+ // "bidQty": "431.00000000",
983
+ // "askPrice": "4.00000200",
984
+ // "askQty": "9.00000000"
985
+ // }
986
+ const data = {};
987
+ data[market['id']] = response;
988
+ return this.parseTickers(data, symbols);
974
989
  }
975
990
  async fetchTickers(symbols = undefined, params = {}) {
976
991
  /**
@@ -501,6 +501,7 @@ class bitvavo extends bitvavo$1 {
501
501
  /**
502
502
  * @method
503
503
  * @name bitvavo#fetchTicker
504
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1ticker~124h/get
504
505
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
505
506
  * @param {string} symbol unified symbol of the market to fetch the ticker for
506
507
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
@@ -614,16 +615,24 @@ class bitvavo extends bitvavo$1 {
614
615
  /**
615
616
  * @method
616
617
  * @name bitvavo#fetchTrades
618
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1trades/get
617
619
  * @description get the list of most recent trades for a particular symbol
618
620
  * @param {string} symbol unified symbol of the market to fetch trades for
619
621
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
620
622
  * @param {int} [limit] the maximum amount of trades to fetch
621
623
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
624
+ * @param {int} [params.until] the latest time in ms to fetch entries for
625
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
622
626
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
623
627
  */
624
628
  await this.loadMarkets();
625
629
  const market = this.market(symbol);
626
- const request = {
630
+ let paginate = false;
631
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
632
+ if (paginate) {
633
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
634
+ }
635
+ let request = {
627
636
  'market': market['id'],
628
637
  // 'limit': 500, // default 500, max 1000
629
638
  // 'start': since,
@@ -637,6 +646,7 @@ class bitvavo extends bitvavo$1 {
637
646
  if (since !== undefined) {
638
647
  request['start'] = since;
639
648
  }
649
+ [request, params] = this.handleUntilOption('end', request, params);
640
650
  const response = await this.publicGetMarketTrades(this.extend(request, params));
641
651
  //
642
652
  // [
@@ -787,6 +797,7 @@ class bitvavo extends bitvavo$1 {
787
797
  /**
788
798
  * @method
789
799
  * @name bitvavo#fetchOrderBook
800
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1book/get
790
801
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
791
802
  * @param {string} symbol unified symbol of the market to fetch the order book for
792
803
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -846,17 +857,25 @@ class bitvavo extends bitvavo$1 {
846
857
  /**
847
858
  * @method
848
859
  * @name bitvavo#fetchOHLCV
860
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1candles/get
849
861
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
850
862
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
851
863
  * @param {string} timeframe the length of time each candle represents
852
864
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
853
865
  * @param {int} [limit] the maximum amount of candles to fetch
854
866
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
867
+ * @param {int} [params.until] the latest time in ms to fetch entries for
868
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
855
869
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
856
870
  */
857
871
  await this.loadMarkets();
858
872
  const market = this.market(symbol);
859
- const request = {
873
+ let paginate = false;
874
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
875
+ if (paginate) {
876
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1440);
877
+ }
878
+ let request = {
860
879
  'market': market['id'],
861
880
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
862
881
  // 'limit': 1440, // default 1440, max 1440
@@ -872,6 +891,7 @@ class bitvavo extends bitvavo$1 {
872
891
  }
873
892
  request['end'] = this.sum(since, limit * duration * 1000);
874
893
  }
894
+ [request, params] = this.handleUntilOption('end', request, params);
875
895
  if (limit !== undefined) {
876
896
  request['limit'] = limit; // default 1440, max 1440
877
897
  }
@@ -1225,19 +1245,25 @@ class bitvavo extends bitvavo$1 {
1225
1245
  /**
1226
1246
  * @method
1227
1247
  * @name bitvavo#fetchOrders
1248
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1orders/get
1228
1249
  * @description fetches information on multiple orders made by the user
1229
1250
  * @param {string} symbol unified market symbol of the market orders were made in
1230
1251
  * @param {int} [since] the earliest time in ms to fetch orders for
1231
1252
  * @param {int} [limit] the maximum number of orde structures to retrieve
1232
1253
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
1254
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1255
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1233
1256
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1234
1257
  */
1235
- if (symbol === undefined) {
1236
- throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
1237
- }
1258
+ this.checkRequiredSymbol('fetchOrders', symbol);
1238
1259
  await this.loadMarkets();
1260
+ let paginate = false;
1261
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
1262
+ if (paginate) {
1263
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
1264
+ }
1239
1265
  const market = this.market(symbol);
1240
- const request = {
1266
+ let request = {
1241
1267
  'market': market['id'],
1242
1268
  // 'limit': 500,
1243
1269
  // 'start': since,
@@ -1251,6 +1277,7 @@ class bitvavo extends bitvavo$1 {
1251
1277
  if (limit !== undefined) {
1252
1278
  request['limit'] = limit; // default 500, max 1000
1253
1279
  }
1280
+ [request, params] = this.handleUntilOption('end', request, params);
1254
1281
  const response = await this.privateGetOrders(this.extend(request, params));
1255
1282
  //
1256
1283
  // [
@@ -1475,19 +1502,27 @@ class bitvavo extends bitvavo$1 {
1475
1502
  /**
1476
1503
  * @method
1477
1504
  * @name bitvavo#fetchMyTrades
1505
+ * @see https://docs.bitvavo.com/#tag/Trades/paths/~1trades/get
1478
1506
  * @description fetch all trades made by the user
1479
1507
  * @param {string} symbol unified market symbol
1480
1508
  * @param {int} [since] the earliest time in ms to fetch trades for
1481
1509
  * @param {int} [limit] the maximum number of trades structures to retrieve
1482
1510
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
1511
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1512
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1483
1513
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1484
1514
  */
1485
1515
  if (symbol === undefined) {
1486
1516
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1487
1517
  }
1488
1518
  await this.loadMarkets();
1519
+ let paginate = false;
1520
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1521
+ if (paginate) {
1522
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1523
+ }
1489
1524
  const market = this.market(symbol);
1490
- const request = {
1525
+ let request = {
1491
1526
  'market': market['id'],
1492
1527
  // 'limit': 500,
1493
1528
  // 'start': since,
@@ -1501,6 +1536,7 @@ class bitvavo extends bitvavo$1 {
1501
1536
  if (limit !== undefined) {
1502
1537
  request['limit'] = limit; // default 500, max 1000
1503
1538
  }
1539
+ [request, params] = this.handleUntilOption('end', request, params);
1504
1540
  const response = await this.privateGetTrades(this.extend(request, params));
1505
1541
  //
1506
1542
  // [
@@ -1198,9 +1198,6 @@ class bybit extends bybit$1 {
1198
1198
  'deposit': {},
1199
1199
  },
1200
1200
  },
1201
- 'commonCurrencies': {
1202
- 'GAS': 'GASDAO',
1203
- },
1204
1201
  });
1205
1202
  }
1206
1203
  nonce() {
@@ -1751,7 +1751,8 @@ class coinex extends coinex$1 {
1751
1751
  const remainingString = this.safeString(order, 'left');
1752
1752
  const marketId = this.safeString(order, 'market');
1753
1753
  const defaultType = this.safeString(this.options, 'defaultType');
1754
- market = this.safeMarket(marketId, market, undefined, defaultType);
1754
+ const orderType = ('source' in order) ? 'swap' : defaultType;
1755
+ market = this.safeMarket(marketId, market, undefined, orderType);
1755
1756
  const feeCurrencyId = this.safeString(order, 'fee_asset');
1756
1757
  let feeCurrency = this.safeCurrencyCode(feeCurrencyId);
1757
1758
  if (feeCurrency === undefined) {
@@ -1564,6 +1564,7 @@ class gate extends gate$1 {
1564
1564
  * @method
1565
1565
  * @name gate#fetchCurrencies
1566
1566
  * @description fetches all available currencies on an exchange
1567
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-currencies-details
1567
1568
  * @param {object} [params] extra parameters specific to the gate api endpoint
1568
1569
  * @returns {object} an associative dictionary of currencies
1569
1570
  */
@@ -1674,6 +1675,7 @@ class gate extends gate$1 {
1674
1675
  * @method
1675
1676
  * @name gate#fetchFundingRate
1676
1677
  * @description fetch the current funding rate
1678
+ * @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
1677
1679
  * @param {string} symbol unified market symbol
1678
1680
  * @param {object} [params] extra parameters specific to the gate api endpoint
1679
1681
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
@@ -1736,6 +1738,7 @@ class gate extends gate$1 {
1736
1738
  * @method
1737
1739
  * @name gate#fetchFundingRates
1738
1740
  * @description fetch the funding rate for multiple markets
1741
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1739
1742
  * @param {string[]|undefined} symbols list of unified market symbols
1740
1743
  * @param {object} [params] extra parameters specific to the gate api endpoint
1741
1744
  * @returns {object} a dictionary of [funding rates structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rates-structure}, indexe by market symbols
@@ -2202,6 +2205,8 @@ class gate extends gate$1 {
2202
2205
  * @method
2203
2206
  * @name gate#fetchFundingHistory
2204
2207
  * @description fetch the history of funding payments paid and received on this account
2208
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-account-book-2
2209
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-account-book-3
2205
2210
  * @param {string} symbol unified market symbol
2206
2211
  * @param {int} [since] the earliest time in ms to fetch funding history for
2207
2212
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -2902,6 +2907,7 @@ class gate extends gate$1 {
2902
2907
  * @method
2903
2908
  * @name gate#fetchFundingRateHistory
2904
2909
  * @description fetches historical funding rate prices
2910
+ * @see https://www.gate.io/docs/developers/apiv4/en/#funding-rate-history
2905
2911
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2906
2912
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2907
2913
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
@@ -2995,6 +3001,10 @@ class gate extends gate$1 {
2995
3001
  * @method
2996
3002
  * @name gate#fetchTrades
2997
3003
  * @description get the list of most recent trades for a particular symbol
3004
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-market-trades
3005
+ * @see https://www.gate.io/docs/developers/apiv4/en/#futures-trading-history
3006
+ * @see https://www.gate.io/docs/developers/apiv4/en/#futures-trading-history-2
3007
+ * @see https://www.gate.io/docs/developers/apiv4/en/#options-trade-history
2998
3008
  * @param {string} symbol unified symbol of the market to fetch trades for
2999
3009
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
3000
3010
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -3098,6 +3108,10 @@ class gate extends gate$1 {
3098
3108
  * @method
3099
3109
  * @name gate#fetchOrderTrades
3100
3110
  * @description fetch all the trades made from a single order
3111
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history
3112
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-2
3113
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-3
3114
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-4
3101
3115
  * @param {string} id order id
3102
3116
  * @param {string} symbol unified market symbol
3103
3117
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3415,6 +3429,7 @@ class gate extends gate$1 {
3415
3429
  * @method
3416
3430
  * @name gate#fetchDeposits
3417
3431
  * @description fetch all deposits made to an account
3432
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-deposit-records
3418
3433
  * @param {string} code unified currency code
3419
3434
  * @param {int} [since] the earliest time in ms to fetch deposits for
3420
3435
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -3452,6 +3467,7 @@ class gate extends gate$1 {
3452
3467
  * @method
3453
3468
  * @name gate#fetchWithdrawals
3454
3469
  * @description fetch all withdrawals made from an account
3470
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-withdrawal-records
3455
3471
  * @param {string} code unified currency code
3456
3472
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
3457
3473
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -3489,6 +3505,7 @@ class gate extends gate$1 {
3489
3505
  * @method
3490
3506
  * @name gate#withdraw
3491
3507
  * @description make a withdrawal
3508
+ * @see https://www.gate.io/docs/developers/apiv4/en/#withdraw
3492
3509
  * @param {string} code unified currency code
3493
3510
  * @param {float} amount the amount to withdraw
3494
3511
  * @param {string} address the address to withdraw to
@@ -3635,6 +3652,13 @@ class gate extends gate$1 {
3635
3652
  * @method
3636
3653
  * @name gate#createOrder
3637
3654
  * @description Create an order on the exchange
3655
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-an-order
3656
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order
3657
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order
3658
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order-2
3659
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order-2
3660
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order-3
3661
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-an-options-order
3638
3662
  * @param {string} symbol Unified CCXT market symbol
3639
3663
  * @param {string} type 'limit' or 'market' *"market" is contract only*
3640
3664
  * @param {string} side 'buy' or 'sell'
@@ -4447,6 +4471,7 @@ class gate extends gate$1 {
4447
4471
  * @method
4448
4472
  * @name gate#fetchOpenOrders
4449
4473
  * @description fetch all unfilled currently open orders
4474
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-open-orders
4450
4475
  * @param {string} symbol unified market symbol
4451
4476
  * @param {int} [since] the earliest time in ms to fetch open orders for
4452
4477
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -4463,6 +4488,13 @@ class gate extends gate$1 {
4463
4488
  * @method
4464
4489
  * @name gate#fetchClosedOrders
4465
4490
  * @description fetches information on multiple closed orders made by the user
4491
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-orders
4492
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-running-auto-order-list
4493
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders
4494
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders
4495
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
4496
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
4497
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
4466
4498
  * @param {string} symbol unified market symbol of the market orders were made in
4467
4499
  * @param {int} [since] the earliest time in ms to fetch orders for
4468
4500
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -4671,6 +4703,10 @@ class gate extends gate$1 {
4671
4703
  * @method
4672
4704
  * @name gate#cancelOrder
4673
4705
  * @description Cancels an open order
4706
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order
4707
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-2
4708
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-3
4709
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-4
4674
4710
  * @param {string} id Order id
4675
4711
  * @param {string} symbol Unified market symbol
4676
4712
  * @param {object} [params] Parameters specified by the exchange api
@@ -4781,6 +4817,10 @@ class gate extends gate$1 {
4781
4817
  * @method
4782
4818
  * @name gate#cancelAllOrders
4783
4819
  * @description cancel all open orders
4820
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-in-specified-currency-pair
4821
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched
4822
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-2
4823
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
4784
4824
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
4785
4825
  * @param {object} [params] extra parameters specific to the gate api endpoint
4786
4826
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -4912,6 +4952,8 @@ class gate extends gate$1 {
4912
4952
  * @method
4913
4953
  * @name gate#setLeverage
4914
4954
  * @description set the level of leverage for a market
4955
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-leverage
4956
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-leverage-2
4915
4957
  * @param {float} leverage the rate of leverage
4916
4958
  * @param {string} symbol unified market symbol
4917
4959
  * @param {object} [params] extra parameters specific to the gate api endpoint
@@ -5276,6 +5318,8 @@ class gate extends gate$1 {
5276
5318
  * @method
5277
5319
  * @name gate#fetchLeverageTiers
5278
5320
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
5321
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
5322
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts-2
5279
5323
  * @param {string[]|undefined} symbols list of unified market symbols
5280
5324
  * @param {object} [params] extra parameters specific to the gate api endpoint
5281
5325
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#leverage-tiers-structure}, indexed by market symbols
@@ -5531,12 +5575,12 @@ class gate extends gate$1 {
5531
5575
  'currency': currency['id'],
5532
5576
  'amount': this.currencyToPrecision(code, amount),
5533
5577
  };
5534
- let method = undefined;
5578
+ let response = undefined;
5579
+ params = this.omit(params, ['marginMode']);
5535
5580
  if (symbol === undefined) {
5536
- method = 'privateMarginPostCrossRepayments';
5581
+ response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
5537
5582
  }
5538
5583
  else {
5539
- method = 'privateMarginPostLoansLoanIdRepayment';
5540
5584
  const market = this.market(symbol);
5541
5585
  request['currency_pair'] = market['id'];
5542
5586
  request['mode'] = 'partial';
@@ -5545,9 +5589,9 @@ class gate extends gate$1 {
5545
5589
  throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires loan_id param for isolated margin');
5546
5590
  }
5547
5591
  request['loan_id'] = loanId;
5592
+ params = this.omit(params, ['loan_id', 'id']);
5593
+ response = await this.privateMarginPostLoansLoanIdRepayment(this.extend(request, params));
5548
5594
  }
5549
- params = this.omit(params, ['marginMode', 'loan_id', 'id']);
5550
- let response = await this[method](this.extend(request, params));
5551
5595
  //
5552
5596
  // Cross
5553
5597
  //
@@ -5614,9 +5658,9 @@ class gate extends gate$1 {
5614
5658
  'currency': currency['id'],
5615
5659
  'amount': this.currencyToPrecision(code, amount),
5616
5660
  };
5617
- let method = undefined;
5661
+ let response = undefined;
5618
5662
  if (symbol === undefined) {
5619
- method = 'privateMarginPostCrossLoans';
5663
+ response = await this.privateMarginPostCrossLoans(this.extend(request, params));
5620
5664
  }
5621
5665
  else {
5622
5666
  const market = this.market(symbol);
@@ -5626,10 +5670,9 @@ class gate extends gate$1 {
5626
5670
  // as it is the smallest tick size currently offered by gateio
5627
5671
  request['rate'] = this.safeString(params, 'rate', '0.0001');
5628
5672
  request['auto_renew'] = true;
5629
- method = 'privateMarginPostLoans';
5673
+ params = this.omit(params, ['rate']);
5674
+ response = await this.privateMarginPostLoans(this.extend(request, params));
5630
5675
  }
5631
- params = this.omit(params, ['marginMode', 'rate']);
5632
- const response = await this[method](this.extend(request, params));
5633
5676
  //
5634
5677
  // Cross
5635
5678
  //
@@ -5853,6 +5896,8 @@ class gate extends gate$1 {
5853
5896
  * @method
5854
5897
  * @name gate#reduceMargin
5855
5898
  * @description remove margin from a position
5899
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
5900
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin-2
5856
5901
  * @param {string} symbol unified market symbol
5857
5902
  * @param {float} amount the amount of margin to remove
5858
5903
  * @param {object} [params] extra parameters specific to the exmo api endpoint
@@ -5865,6 +5910,8 @@ class gate extends gate$1 {
5865
5910
  * @method
5866
5911
  * @name gate#addMargin
5867
5912
  * @description add margin
5913
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
5914
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin-2
5868
5915
  * @param {string} symbol unified market symbol
5869
5916
  * @param {float} amount amount of margin to add
5870
5917
  * @param {object} [params] extra parameters specific to the exmo api endpoint
@@ -6402,6 +6449,7 @@ class gate extends gate$1 {
6402
6449
  * @method
6403
6450
  * @name gate#fetchUnderlyingAssets
6404
6451
  * @description fetches the market ids of underlying assets for a specific contract market type
6452
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-underlyings
6405
6453
  * @param {object} [params] exchange specific params
6406
6454
  * @param {string} [params.type] the contract market type, 'option', 'swap' or 'future', the default is 'option'
6407
6455
  * @returns {object[]} a list of [underlying assets]{@link https://github.com/ccxt/ccxt/wiki/Manual#underlying-assets-structure}
@@ -557,11 +557,10 @@ class gemini extends gemini$1 {
557
557
  }
558
558
  for (let i = 0; i < marketIds.length; i++) {
559
559
  const marketId = marketIds[i];
560
- const method = 'publicGetV1SymbolsDetailsSymbol';
561
560
  const request = {
562
561
  'symbol': marketId,
563
562
  };
564
- promises.push(this[method](this.extend(request, params)));
563
+ promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
565
564
  //
566
565
  // {
567
566
  // "symbol": "BTCUSD",
@@ -33,6 +33,7 @@ class hitbtc extends hitbtc$1 {
33
33
  'cancelOrder': true,
34
34
  'createDepositAddress': true,
35
35
  'createOrder': true,
36
+ 'createPostOnlyOrder': true,
36
37
  'createReduceOnlyOrder': true,
37
38
  'createStopLimitOrder': true,
38
39
  'createStopMarketOrder': true,
@@ -2047,14 +2048,24 @@ class hitbtc extends hitbtc$1 {
2047
2048
  * @param {float} amount how much of currency you want to trade in units of base currency
2048
2049
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2049
2050
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
2050
- * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
2051
+ * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported for spot-margin, swap supports both
2051
2052
  * @param {bool} [params.margin] true for creating a margin order
2052
2053
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2054
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2055
+ * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", "Day", "GTD"
2053
2056
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2054
2057
  */
2055
2058
  await this.loadMarkets();
2056
2059
  const market = this.market(symbol);
2057
2060
  const isLimit = (type === 'limit');
2061
+ const reduceOnly = this.safeValue(params, 'reduceOnly');
2062
+ const timeInForce = this.safeString(params, 'timeInForce');
2063
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
2064
+ let marketType = undefined;
2065
+ [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
2066
+ let marginMode = undefined;
2067
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
2068
+ const isPostOnly = this.isPostOnly(type === 'market', undefined, params);
2058
2069
  const request = {
2059
2070
  'type': type,
2060
2071
  'side': side,
@@ -2072,7 +2083,6 @@ class hitbtc extends hitbtc$1 {
2072
2083
  // 'take_rate': 0.001, // Optional
2073
2084
  // 'make_rate': 0.001, // Optional
2074
2085
  };
2075
- const reduceOnly = this.safeValue(params, 'reduceOnly');
2076
2086
  if (reduceOnly !== undefined) {
2077
2087
  if ((market['type'] !== 'swap') && (market['type'] !== 'margin')) {
2078
2088
  throw new errors.InvalidOrder(this.id + ' createOrder() does not support reduce_only for ' + market['type'] + ' orders, reduce_only orders are supported for swap and margin markets only');
@@ -2081,8 +2091,12 @@ class hitbtc extends hitbtc$1 {
2081
2091
  if (reduceOnly === true) {
2082
2092
  request['reduce_only'] = reduceOnly;
2083
2093
  }
2084
- const timeInForce = this.safeString2(params, 'timeInForce', 'time_in_force');
2085
- const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
2094
+ if (isPostOnly) {
2095
+ request['post_only'] = true;
2096
+ }
2097
+ if (timeInForce !== undefined) {
2098
+ request['time_in_force'] = timeInForce;
2099
+ }
2086
2100
  if (isLimit || (type === 'stopLimit') || (type === 'takeProfitLimit')) {
2087
2101
  if (price === undefined) {
2088
2102
  throw new errors.ExchangeError(this.id + ' createOrder() requires a price argument for limit orders');
@@ -2107,19 +2121,20 @@ class hitbtc extends hitbtc$1 {
2107
2121
  else if ((type === 'stopLimit') || (type === 'stopMarket') || (type === 'takeProfitLimit') || (type === 'takeProfitMarket')) {
2108
2122
  throw new errors.ExchangeError(this.id + ' createOrder() requires a stopPrice parameter for stop-loss and take-profit orders');
2109
2123
  }
2110
- let marketType = undefined;
2111
- [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
2112
- let method = this.getSupportedMapping(marketType, {
2113
- 'spot': 'privatePostSpotOrder',
2114
- 'swap': 'privatePostFuturesOrder',
2115
- 'margin': 'privatePostMarginOrder',
2116
- });
2117
- const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
2118
- if (marginMode !== undefined) {
2119
- method = 'privatePostMarginOrder';
2124
+ params = this.omit(params, ['triggerPrice', 'timeInForce', 'stopPrice', 'stop_price', 'reduceOnly', 'postOnly']);
2125
+ if ((marketType === 'swap') && (marginMode !== undefined)) {
2126
+ request['margin_mode'] = marginMode;
2127
+ }
2128
+ let response = undefined;
2129
+ if (marketType === 'swap') {
2130
+ response = await this.privatePostFuturesOrder(this.extend(request, params));
2131
+ }
2132
+ else if ((marketType === 'margin') || (marginMode !== undefined)) {
2133
+ response = await this.privatePostMarginOrder(this.extend(request, params));
2134
+ }
2135
+ else {
2136
+ response = await this.privatePostSpotOrder(this.extend(request, params));
2120
2137
  }
2121
- params = this.omit(params, ['triggerPrice', 'timeInForce', 'time_in_force', 'stopPrice', 'stop_price', 'reduceOnly']);
2122
- const response = await this[method](this.extend(request, query));
2123
2138
  return this.parseOrder(response, market);
2124
2139
  }
2125
2140
  parseOrderStatus(status) {
@@ -3042,12 +3057,7 @@ class hitbtc extends hitbtc$1 {
3042
3057
  const isMargin = this.safeValue(params, 'margin', false);
3043
3058
  let marginMode = undefined;
3044
3059
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3045
- if (marginMode !== undefined) {
3046
- if (marginMode !== 'isolated') {
3047
- throw new errors.NotSupported(this.id + ' only isolated margin is supported');
3048
- }
3049
- }
3050
- else {
3060
+ if (marginMode === undefined) {
3051
3061
  if ((defaultType === 'margin') || (isMargin === true)) {
3052
3062
  marginMode = 'isolated';
3053
3063
  }
@@ -1048,7 +1048,6 @@ class huobi extends huobi$1 {
1048
1048
  'GET': 'Themis',
1049
1049
  'GTC': 'Game.com',
1050
1050
  'HIT': 'HitChain',
1051
- 'HOT': 'Hydro Protocol',
1052
1051
  // https://github.com/ccxt/ccxt/issues/7399
1053
1052
  // https://coinmarketcap.com/currencies/pnetwork/
1054
1053
  // https://coinmarketcap.com/currencies/penta/markets/
@@ -316,7 +316,6 @@ class huobijp extends huobijp$1 {
316
316
  'GET': 'Themis',
317
317
  'GTC': 'Game.com',
318
318
  'HIT': 'HitChain',
319
- 'HOT': 'Hydro Protocol',
320
319
  // https://github.com/ccxt/ccxt/issues/7399
321
320
  // https://coinmarketcap.com/currencies/pnetwork/
322
321
  // https://coinmarketcap.com/currencies/penta/markets/
@@ -1917,7 +1917,7 @@ class krakenfutures extends krakenfutures$1 {
1917
1917
  result.push({
1918
1918
  'info': item,
1919
1919
  'symbol': symbol,
1920
- 'fundingRate': this.safeNumber(item, 'fundingRate'),
1920
+ 'fundingRate': this.safeNumber(item, 'relativeFundingRate'),
1921
1921
  'timestamp': this.parse8601(datetime),
1922
1922
  'datetime': datetime,
1923
1923
  });