ccxt 4.1.77 → 4.1.78

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 (55) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +500 -176
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/bingx.js +3 -2
  6. package/dist/cjs/src/bitget.js +71 -0
  7. package/dist/cjs/src/bitmart.js +9 -13
  8. package/dist/cjs/src/bybit.js +2 -0
  9. package/dist/cjs/src/coinbase.js +12 -3
  10. package/dist/cjs/src/coinex.js +7 -11
  11. package/dist/cjs/src/gate.js +4 -0
  12. package/dist/cjs/src/hitbtc.js +326 -123
  13. package/dist/cjs/src/idex.js +10 -1
  14. package/dist/cjs/src/mexc.js +33 -5
  15. package/dist/cjs/src/okx.js +5 -9
  16. package/dist/cjs/src/pro/binance.js +10 -2
  17. package/dist/cjs/src/pro/binanceus.js +1 -0
  18. package/dist/cjs/src/pro/gate.js +1 -1
  19. package/dist/cjs/src/upbit.js +5 -5
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bybit.d.ts +2 -0
  23. package/js/src/abstract/gate.d.ts +3 -0
  24. package/js/src/abstract/gateio.d.ts +3 -0
  25. package/js/src/abstract/okx.d.ts +2 -0
  26. package/js/src/base/Exchange.d.ts +1 -1
  27. package/js/src/bingx.js +3 -2
  28. package/js/src/bitget.d.ts +5 -4
  29. package/js/src/bitget.js +71 -0
  30. package/js/src/bitmart.js +9 -13
  31. package/js/src/bybit.js +2 -0
  32. package/js/src/coinbase.js +12 -3
  33. package/js/src/coinex.js +7 -11
  34. package/js/src/gate.js +4 -0
  35. package/js/src/hitbtc.js +326 -123
  36. package/js/src/idex.js +10 -1
  37. package/js/src/mexc.d.ts +1 -0
  38. package/js/src/mexc.js +33 -5
  39. package/js/src/okx.js +5 -9
  40. package/js/src/pro/binance.js +10 -2
  41. package/js/src/pro/binanceus.js +1 -0
  42. package/js/src/pro/gate.js +1 -1
  43. package/js/src/upbit.js +5 -5
  44. package/package.json +1 -1
  45. package/skip-tests.json +2 -1
  46. package/js/src/huobipro.d.ts +0 -4
  47. package/js/src/huobipro.js +0 -20
  48. package/js/src/mexc3.d.ts +0 -4
  49. package/js/src/mexc3.js +0 -17
  50. package/js/src/okex.d.ts +0 -4
  51. package/js/src/okex.js +0 -17
  52. package/js/src/okex5.d.ts +0 -4
  53. package/js/src/okex5.js +0 -17
  54. package/js/src/tidex.d.ts +0 -36
  55. package/js/src/tidex.js +0 -1068
@@ -642,6 +642,7 @@ class hitbtc extends hitbtc$1 {
642
642
  * @method
643
643
  * @name hitbtc#fetchMarkets
644
644
  * @description retrieves data on all markets for hitbtc
645
+ * @see https://api.hitbtc.com/#symbols
645
646
  * @param {object} [params] extra parameters specific to the exchange API endpoint
646
647
  * @returns {object[]} an array of objects representing market data
647
648
  */
@@ -785,6 +786,7 @@ class hitbtc extends hitbtc$1 {
785
786
  * @method
786
787
  * @name hitbtc#fetchCurrencies
787
788
  * @description fetches all available currencies on an exchange
789
+ * @see https://api.hitbtc.com/#currencies
788
790
  * @param {object} [params] extra parameters specific to the exchange API endpoint
789
791
  * @returns {object} an associative dictionary of currencies
790
792
  */
@@ -905,6 +907,7 @@ class hitbtc extends hitbtc$1 {
905
907
  * @method
906
908
  * @name hitbtc#createDepositAddress
907
909
  * @description create a currency deposit address
910
+ * @see https://api.hitbtc.com/#generate-deposit-crypto-address
908
911
  * @param {string} code unified currency code of the currency for the deposit address
909
912
  * @param {object} [params] extra parameters specific to the exchange API endpoint
910
913
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -941,6 +944,7 @@ class hitbtc extends hitbtc$1 {
941
944
  * @method
942
945
  * @name hitbtc#fetchDepositAddress
943
946
  * @description fetch the deposit address for a currency associated with this account
947
+ * @see https://api.hitbtc.com/#get-deposit-crypto-address
944
948
  * @param {string} code unified currency code
945
949
  * @param {object} [params] extra parameters specific to the exchange API endpoint
946
950
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -995,6 +999,9 @@ class hitbtc extends hitbtc$1 {
995
999
  * @method
996
1000
  * @name hitbtc#fetchBalance
997
1001
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1002
+ * @see https://api.hitbtc.com/#wallet-balance
1003
+ * @see https://api.hitbtc.com/#get-spot-trading-balance
1004
+ * @see https://api.hitbtc.com/#get-trading-balance
998
1005
  * @param {object} [params] extra parameters specific to the exchange API endpoint
999
1006
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1000
1007
  */
@@ -1197,6 +1204,9 @@ class hitbtc extends hitbtc$1 {
1197
1204
  * @method
1198
1205
  * @name hitbtc#fetchMyTrades
1199
1206
  * @description fetch all trades made by the user
1207
+ * @see https://api.hitbtc.com/#spot-trades-history
1208
+ * @see https://api.hitbtc.com/#futures-trades-history
1209
+ * @see https://api.hitbtc.com/#margin-trades-history
1200
1210
  * @param {string} symbol unified market symbol
1201
1211
  * @param {int} [since] the earliest time in ms to fetch trades for
1202
1212
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1219,17 +1229,28 @@ class hitbtc extends hitbtc$1 {
1219
1229
  request['from'] = since;
1220
1230
  }
1221
1231
  let marketType = undefined;
1232
+ let marginMode = undefined;
1233
+ let response = undefined;
1222
1234
  [marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
1223
- let method = this.getSupportedMapping(marketType, {
1224
- 'spot': 'privateGetSpotHistoryTrade',
1225
- 'swap': 'privateGetFuturesHistoryTrade',
1226
- 'margin': 'privateGetMarginHistoryTrade',
1227
- });
1228
- const [marginMode, query] = this.handleMarginModeAndParams('fetchMyTrades', params);
1235
+ [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
1236
+ params = this.omit(params, ['marginMode', 'margin']);
1229
1237
  if (marginMode !== undefined) {
1230
- method = 'privateGetMarginHistoryTrade';
1238
+ response = await this.privateGetMarginHistoryTrade(this.extend(request, params));
1239
+ }
1240
+ else {
1241
+ if (marketType === 'spot') {
1242
+ response = await this.privateGetSpotHistoryTrade(this.extend(request, params));
1243
+ }
1244
+ else if (marketType === 'swap') {
1245
+ response = await this.privateGetFuturesHistoryTrade(this.extend(request, params));
1246
+ }
1247
+ else if (marketType === 'margin') {
1248
+ response = await this.privateGetMarginHistoryTrade(this.extend(request, params));
1249
+ }
1250
+ else {
1251
+ throw new errors.NotSupported(this.id + ' fetchMyTrades() not support this market type');
1252
+ }
1231
1253
  }
1232
- const response = await this[method](this.extend(request, query));
1233
1254
  return this.parseTrades(response, market, since, limit);
1234
1255
  }
1235
1256
  parseTrade(trade, market = undefined) {
@@ -1483,6 +1504,7 @@ class hitbtc extends hitbtc$1 {
1483
1504
  * @method
1484
1505
  * @name hitbtc#fetchDepositsWithdrawals
1485
1506
  * @description fetch history of deposits and withdrawals
1507
+ * @see https://api.hitbtc.com/#get-transactions-history
1486
1508
  * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1487
1509
  * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1488
1510
  * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
@@ -1496,6 +1518,7 @@ class hitbtc extends hitbtc$1 {
1496
1518
  * @method
1497
1519
  * @name hitbtc#fetchDeposits
1498
1520
  * @description fetch all deposits made to an account
1521
+ * @see https://api.hitbtc.com/#get-transactions-history
1499
1522
  * @param {string} code unified currency code
1500
1523
  * @param {int} [since] the earliest time in ms to fetch deposits for
1501
1524
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1509,6 +1532,7 @@ class hitbtc extends hitbtc$1 {
1509
1532
  * @method
1510
1533
  * @name hitbtc#fetchWithdrawals
1511
1534
  * @description fetch all withdrawals made from an account
1535
+ * @see https://api.hitbtc.com/#get-transactions-history
1512
1536
  * @param {string} code unified currency code
1513
1537
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
1514
1538
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -1596,6 +1620,8 @@ class hitbtc extends hitbtc$1 {
1596
1620
  * @method
1597
1621
  * @name hitbtc#fetchTradingFee
1598
1622
  * @description fetch the trading fees for a market
1623
+ * @see https://api.hitbtc.com/#get-trading-commission
1624
+ * @see https://api.hitbtc.com/#get-trading-commission-2
1599
1625
  * @param {string} symbol unified market symbol
1600
1626
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1601
1627
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -1605,11 +1631,16 @@ class hitbtc extends hitbtc$1 {
1605
1631
  const request = {
1606
1632
  'symbol': market['id'],
1607
1633
  };
1608
- const method = this.getSupportedMapping(market['type'], {
1609
- 'spot': 'privateGetSpotFeeSymbol',
1610
- 'swap': 'privateGetFuturesFeeSymbol',
1611
- });
1612
- const response = await this[method](this.extend(request, params));
1634
+ let response = undefined;
1635
+ if (market['type'] === 'spot') {
1636
+ response = await this.privateGetSpotFeeSymbol(this.extend(request, params));
1637
+ }
1638
+ else if (market['type'] === 'swap') {
1639
+ response = await this.privateGetFuturesFeeSymbol(this.extend(request, params));
1640
+ }
1641
+ else {
1642
+ throw new errors.NotSupported(this.id + ' fetchTradingFee() not support this market type');
1643
+ }
1613
1644
  //
1614
1645
  // {
1615
1646
  // "take_rate":"0.0009",
@@ -1623,16 +1654,23 @@ class hitbtc extends hitbtc$1 {
1623
1654
  * @method
1624
1655
  * @name hitbtc#fetchTradingFees
1625
1656
  * @description fetch the trading fees for multiple markets
1657
+ * @see https://api.hitbtc.com/#get-all-trading-commissions
1658
+ * @see https://api.hitbtc.com/#get-all-trading-commissions-2
1626
1659
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1627
1660
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1628
1661
  */
1629
1662
  await this.loadMarkets();
1630
1663
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
1631
- const method = this.getSupportedMapping(marketType, {
1632
- 'spot': 'privateGetSpotFee',
1633
- 'swap': 'privateGetFuturesFee',
1634
- });
1635
- const response = await this[method](query);
1664
+ let response = undefined;
1665
+ if (marketType === 'spot') {
1666
+ response = await this.privateGetSpotFee(query);
1667
+ }
1668
+ else if (marketType === 'swap') {
1669
+ response = await this.privateGetFuturesFee(query);
1670
+ }
1671
+ else {
1672
+ throw new errors.NotSupported(this.id + ' fetchTradingFees() not support this market type');
1673
+ }
1636
1674
  //
1637
1675
  // [
1638
1676
  // {
@@ -1768,6 +1806,9 @@ class hitbtc extends hitbtc$1 {
1768
1806
  * @method
1769
1807
  * @name hitbtc#fetchClosedOrders
1770
1808
  * @description fetches information on multiple closed orders made by the user
1809
+ * @see https://api.hitbtc.com/#spot-orders-history
1810
+ * @see https://api.hitbtc.com/#futures-orders-history
1811
+ * @see https://api.hitbtc.com/#margin-orders-history
1771
1812
  * @param {string} symbol unified market symbol of the market orders were made in
1772
1813
  * @param {int} [since] the earliest time in ms to fetch orders for
1773
1814
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -1790,17 +1831,28 @@ class hitbtc extends hitbtc$1 {
1790
1831
  request['limit'] = limit;
1791
1832
  }
1792
1833
  let marketType = undefined;
1834
+ let marginMode = undefined;
1793
1835
  [marketType, params] = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
1794
- let method = this.getSupportedMapping(marketType, {
1795
- 'spot': 'privateGetSpotHistoryOrder',
1796
- 'swap': 'privateGetFuturesHistoryOrder',
1797
- 'margin': 'privateGetMarginHistoryOrder',
1798
- });
1799
- const [marginMode, query] = this.handleMarginModeAndParams('fetchClosedOrders', params);
1836
+ [marginMode, params] = this.handleMarginModeAndParams('fetchClosedOrders', params);
1837
+ params = this.omit(params, ['marginMode', 'margin']);
1838
+ let response = undefined;
1800
1839
  if (marginMode !== undefined) {
1801
- method = 'privateGetMarginHistoryOrder';
1840
+ response = await this.privateGetMarginHistoryOrder(this.extend(request, params));
1841
+ }
1842
+ else {
1843
+ if (marketType === 'spot') {
1844
+ response = await this.privateGetSpotHistoryOrder(this.extend(request, params));
1845
+ }
1846
+ else if (marketType === 'swap') {
1847
+ response = await this.privateGetFuturesHistoryOrder(this.extend(request, params));
1848
+ }
1849
+ else if (marketType === 'margin') {
1850
+ response = await this.privateGetMarginHistoryOrder(this.extend(request, params));
1851
+ }
1852
+ else {
1853
+ throw new errors.NotSupported(this.id + ' fetchClosedOrders() not support this market type');
1854
+ }
1802
1855
  }
1803
- const response = await this[method](this.extend(request, query));
1804
1856
  const parsed = this.parseOrders(response, market, since, limit);
1805
1857
  return this.filterByArray(parsed, 'status', ['closed', 'canceled'], false);
1806
1858
  }
@@ -1809,6 +1861,9 @@ class hitbtc extends hitbtc$1 {
1809
1861
  * @method
1810
1862
  * @name hitbtc#fetchOrder
1811
1863
  * @description fetches information on an order made by the user
1864
+ * @see https://api.hitbtc.com/#spot-orders-history
1865
+ * @see https://api.hitbtc.com/#futures-orders-history
1866
+ * @see https://api.hitbtc.com/#margin-orders-history
1812
1867
  * @param {string} symbol unified symbol of the market the order was made in
1813
1868
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1814
1869
  * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
@@ -1820,21 +1875,32 @@ class hitbtc extends hitbtc$1 {
1820
1875
  if (symbol !== undefined) {
1821
1876
  market = this.market(symbol);
1822
1877
  }
1878
+ const request = {
1879
+ 'client_order_id': id,
1880
+ };
1823
1881
  let marketType = undefined;
1882
+ let marginMode = undefined;
1824
1883
  [marketType, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
1825
- let method = this.getSupportedMapping(marketType, {
1826
- 'spot': 'privateGetSpotHistoryOrder',
1827
- 'swap': 'privateGetFuturesHistoryOrder',
1828
- 'margin': 'privateGetMarginHistoryOrder',
1829
- });
1830
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
1884
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrder', params);
1885
+ params = this.omit(params, ['marginMode', 'margin']);
1886
+ let response = undefined;
1831
1887
  if (marginMode !== undefined) {
1832
- method = 'privateGetMarginHistoryOrder';
1888
+ response = await this.privateGetMarginHistoryOrder(this.extend(request, params));
1889
+ }
1890
+ else {
1891
+ if (marketType === 'spot') {
1892
+ response = await this.privateGetSpotHistoryOrder(this.extend(request, params));
1893
+ }
1894
+ else if (marketType === 'swap') {
1895
+ response = await this.privateGetFuturesHistoryOrder(this.extend(request, params));
1896
+ }
1897
+ else if (marketType === 'margin') {
1898
+ response = await this.privateGetMarginHistoryOrder(this.extend(request, params));
1899
+ }
1900
+ else {
1901
+ throw new errors.NotSupported(this.id + ' fetchOrder() not support this market type');
1902
+ }
1833
1903
  }
1834
- const request = {
1835
- 'client_order_id': id,
1836
- };
1837
- const response = await this[method](this.extend(request, query));
1838
1904
  //
1839
1905
  // [
1840
1906
  // {
@@ -1862,6 +1928,9 @@ class hitbtc extends hitbtc$1 {
1862
1928
  * @method
1863
1929
  * @name hitbtc#fetchOrderTrades
1864
1930
  * @description fetch all the trades made from a single order
1931
+ * @see https://api.hitbtc.com/#spot-trades-history
1932
+ * @see https://api.hitbtc.com/#futures-trades-history
1933
+ * @see https://api.hitbtc.com/#margin-trades-history
1865
1934
  * @param {string} id order id
1866
1935
  * @param {string} symbol unified market symbol
1867
1936
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -1880,17 +1949,28 @@ class hitbtc extends hitbtc$1 {
1880
1949
  'order_id': id, // exchange assigned order id as oppose to the client order id
1881
1950
  };
1882
1951
  let marketType = undefined;
1952
+ let marginMode = undefined;
1883
1953
  [marketType, params] = this.handleMarketTypeAndParams('fetchOrderTrades', market, params);
1884
- let method = this.getSupportedMapping(marketType, {
1885
- 'spot': 'privateGetSpotHistoryTrade',
1886
- 'swap': 'privateGetFuturesHistoryTrade',
1887
- 'margin': 'privateGetMarginHistoryTrade',
1888
- });
1889
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrderTrades', params);
1954
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrderTrades', params);
1955
+ params = this.omit(params, ['marginMode', 'margin']);
1956
+ let response = undefined;
1890
1957
  if (marginMode !== undefined) {
1891
- method = 'privateGetMarginHistoryTrade';
1958
+ response = await this.privateGetMarginHistoryTrade(this.extend(request, params));
1959
+ }
1960
+ else {
1961
+ if (marketType === 'spot') {
1962
+ response = await this.privateGetSpotHistoryTrade(this.extend(request, params));
1963
+ }
1964
+ else if (marketType === 'swap') {
1965
+ response = await this.privateGetFuturesHistoryTrade(this.extend(request, params));
1966
+ }
1967
+ else if (marketType === 'margin') {
1968
+ response = await this.privateGetMarginHistoryTrade(this.extend(request, params));
1969
+ }
1970
+ else {
1971
+ throw new errors.NotSupported(this.id + ' fetchOrderTrades() not support this market type');
1972
+ }
1892
1973
  }
1893
- const response = await this[method](this.extend(request, query));
1894
1974
  //
1895
1975
  // Spot
1896
1976
  //
@@ -1936,6 +2016,9 @@ class hitbtc extends hitbtc$1 {
1936
2016
  * @method
1937
2017
  * @name hitbtc#fetchOpenOrders
1938
2018
  * @description fetch all unfilled currently open orders
2019
+ * @see https://api.hitbtc.com/#get-all-active-spot-orders
2020
+ * @see https://api.hitbtc.com/#get-active-futures-orders
2021
+ * @see https://api.hitbtc.com/#get-active-margin-orders
1939
2022
  * @param {string} symbol unified market symbol
1940
2023
  * @param {int} [since] the earliest time in ms to fetch open orders for
1941
2024
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1952,17 +2035,28 @@ class hitbtc extends hitbtc$1 {
1952
2035
  request['symbol'] = market['id'];
1953
2036
  }
1954
2037
  let marketType = undefined;
2038
+ let marginMode = undefined;
1955
2039
  [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
1956
- let method = this.getSupportedMapping(marketType, {
1957
- 'spot': 'privateGetSpotOrder',
1958
- 'swap': 'privateGetFuturesOrder',
1959
- 'margin': 'privateGetMarginOrder',
1960
- });
1961
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOpenOrders', params);
2040
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
2041
+ params = this.omit(params, ['marginMode', 'margin']);
2042
+ let response = undefined;
1962
2043
  if (marginMode !== undefined) {
1963
- method = 'privateGetMarginOrder';
2044
+ response = await this.privateGetMarginOrder(this.extend(request, params));
2045
+ }
2046
+ else {
2047
+ if (marketType === 'spot') {
2048
+ response = await this.privateGetSpotOrder(this.extend(request, params));
2049
+ }
2050
+ else if (marketType === 'swap') {
2051
+ response = await this.privateGetFuturesOrder(this.extend(request, params));
2052
+ }
2053
+ else if (marketType === 'margin') {
2054
+ response = await this.privateGetMarginOrder(this.extend(request, params));
2055
+ }
2056
+ else {
2057
+ throw new errors.NotSupported(this.id + ' fetchOpenOrders() not support this market type');
2058
+ }
1964
2059
  }
1965
- const response = await this[method](this.extend(request, query));
1966
2060
  //
1967
2061
  // [
1968
2062
  // {
@@ -1989,6 +2083,9 @@ class hitbtc extends hitbtc$1 {
1989
2083
  * @method
1990
2084
  * @name hitbtc#fetchOpenOrder
1991
2085
  * @description fetch an open order by it's id
2086
+ * @see https://api.hitbtc.com/#get-active-spot-order
2087
+ * @see https://api.hitbtc.com/#get-active-futures-order
2088
+ * @see https://api.hitbtc.com/#get-active-margin-order
1992
2089
  * @param {string} id order id
1993
2090
  * @param {string} symbol unified market symbol, default is undefined
1994
2091
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2001,21 +2098,32 @@ class hitbtc extends hitbtc$1 {
2001
2098
  if (symbol !== undefined) {
2002
2099
  market = this.market(symbol);
2003
2100
  }
2101
+ const request = {
2102
+ 'client_order_id': id,
2103
+ };
2004
2104
  let marketType = undefined;
2105
+ let marginMode = undefined;
2005
2106
  [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrder', market, params);
2006
- let method = this.getSupportedMapping(marketType, {
2007
- 'spot': 'privateGetSpotOrderClientOrderId',
2008
- 'swap': 'privateGetFuturesOrderClientOrderId',
2009
- 'margin': 'privateGetMarginOrderClientOrderId',
2010
- });
2011
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOpenOrder', params);
2107
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrder', params);
2108
+ params = this.omit(params, ['marginMode', 'margin']);
2109
+ let response = undefined;
2012
2110
  if (marginMode !== undefined) {
2013
- method = 'privateGetMarginOrderClientOrderId';
2111
+ response = await this.privateGetMarginOrderClientOrderId(this.extend(request, params));
2112
+ }
2113
+ else {
2114
+ if (marketType === 'spot') {
2115
+ response = await this.privateGetSpotOrderClientOrderId(this.extend(request, params));
2116
+ }
2117
+ else if (marketType === 'swap') {
2118
+ response = await this.privateGetFuturesOrderClientOrderId(this.extend(request, params));
2119
+ }
2120
+ else if (marketType === 'margin') {
2121
+ response = await this.privateGetMarginOrderClientOrderId(this.extend(request, params));
2122
+ }
2123
+ else {
2124
+ throw new errors.NotSupported(this.id + ' fetchOpenOrder() not support this market type');
2125
+ }
2014
2126
  }
2015
- const request = {
2016
- 'client_order_id': id,
2017
- };
2018
- const response = await this[method](this.extend(request, query));
2019
2127
  return this.parseOrder(response, market);
2020
2128
  }
2021
2129
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -2023,6 +2131,9 @@ class hitbtc extends hitbtc$1 {
2023
2131
  * @method
2024
2132
  * @name hitbtc#cancelAllOrders
2025
2133
  * @description cancel all open orders
2134
+ * @see https://api.hitbtc.com/#cancel-all-spot-orders
2135
+ * @see https://api.hitbtc.com/#cancel-futures-orders
2136
+ * @see https://api.hitbtc.com/#cancel-all-margin-orders
2026
2137
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2027
2138
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2028
2139
  * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
@@ -2037,17 +2148,28 @@ class hitbtc extends hitbtc$1 {
2037
2148
  request['symbol'] = market['id'];
2038
2149
  }
2039
2150
  let marketType = undefined;
2151
+ let marginMode = undefined;
2040
2152
  [marketType, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
2041
- let method = this.getSupportedMapping(marketType, {
2042
- 'spot': 'privateDeleteSpotOrder',
2043
- 'swap': 'privateDeleteFuturesOrder',
2044
- 'margin': 'privateDeleteMarginOrder',
2045
- });
2046
- const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
2153
+ [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
2154
+ params = this.omit(params, ['marginMode', 'margin']);
2155
+ let response = undefined;
2047
2156
  if (marginMode !== undefined) {
2048
- method = 'privateDeleteMarginOrder';
2157
+ response = await this.privateDeleteMarginOrder(this.extend(request, params));
2158
+ }
2159
+ else {
2160
+ if (marketType === 'spot') {
2161
+ response = await this.privateDeleteSpotOrder(this.extend(request, params));
2162
+ }
2163
+ else if (marketType === 'swap') {
2164
+ response = await this.privateDeleteFuturesOrder(this.extend(request, params));
2165
+ }
2166
+ else if (marketType === 'margin') {
2167
+ response = await this.privateDeleteMarginOrder(this.extend(request, params));
2168
+ }
2169
+ else {
2170
+ throw new errors.NotSupported(this.id + ' cancelAllOrders() not support this market type');
2171
+ }
2049
2172
  }
2050
- const response = await this[method](this.extend(request, query));
2051
2173
  return this.parseOrders(response, market);
2052
2174
  }
2053
2175
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -2055,6 +2177,9 @@ class hitbtc extends hitbtc$1 {
2055
2177
  * @method
2056
2178
  * @name hitbtc#cancelOrder
2057
2179
  * @description cancels an open order
2180
+ * @see https://api.hitbtc.com/#cancel-spot-order
2181
+ * @see https://api.hitbtc.com/#cancel-futures-order
2182
+ * @see https://api.hitbtc.com/#cancel-margin-order
2058
2183
  * @param {string} id order id
2059
2184
  * @param {string} symbol unified symbol of the market the order was made in
2060
2185
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2071,17 +2196,28 @@ class hitbtc extends hitbtc$1 {
2071
2196
  market = this.market(symbol);
2072
2197
  }
2073
2198
  let marketType = undefined;
2199
+ let marginMode = undefined;
2074
2200
  [marketType, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
2075
- let method = this.getSupportedMapping(marketType, {
2076
- 'spot': 'privateDeleteSpotOrderClientOrderId',
2077
- 'swap': 'privateDeleteFuturesOrderClientOrderId',
2078
- 'margin': 'privateDeleteMarginOrderClientOrderId',
2079
- });
2080
- const [marginMode, query] = this.handleMarginModeAndParams('cancelOrder', params);
2201
+ [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
2202
+ params = this.omit(params, ['marginMode', 'margin']);
2203
+ let response = undefined;
2081
2204
  if (marginMode !== undefined) {
2082
- method = 'privateDeleteMarginOrderClientOrderId';
2205
+ response = await this.privateDeleteMarginOrderClientOrderId(this.extend(request, params));
2206
+ }
2207
+ else {
2208
+ if (marketType === 'spot') {
2209
+ response = await this.privateDeleteSpotOrderClientOrderId(this.extend(request, params));
2210
+ }
2211
+ else if (marketType === 'swap') {
2212
+ response = await this.privateDeleteFuturesOrderClientOrderId(this.extend(request, params));
2213
+ }
2214
+ else if (marketType === 'margin') {
2215
+ response = await this.privateDeleteMarginOrderClientOrderId(this.extend(request, params));
2216
+ }
2217
+ else {
2218
+ throw new errors.NotSupported(this.id + ' cancelOrder() not support this market type');
2219
+ }
2083
2220
  }
2084
- const response = await this[method](this.extend(request, query));
2085
2221
  return this.parseOrder(response, market);
2086
2222
  }
2087
2223
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -2101,17 +2237,28 @@ class hitbtc extends hitbtc$1 {
2101
2237
  market = this.market(symbol);
2102
2238
  }
2103
2239
  let marketType = undefined;
2240
+ let marginMode = undefined;
2104
2241
  [marketType, params] = this.handleMarketTypeAndParams('editOrder', market, params);
2105
- let method = this.getSupportedMapping(marketType, {
2106
- 'spot': 'privatePatchSpotOrderClientOrderId',
2107
- 'swap': 'privatePatchFuturesOrderClientOrderId',
2108
- 'margin': 'privatePatchMarginOrderClientOrderId',
2109
- });
2110
- const [marginMode, query] = this.handleMarginModeAndParams('editOrder', params);
2242
+ [marginMode, params] = this.handleMarginModeAndParams('editOrder', params);
2243
+ params = this.omit(params, ['marginMode', 'margin']);
2244
+ let response = undefined;
2111
2245
  if (marginMode !== undefined) {
2112
- method = 'privatePatchMarginOrderClientOrderId';
2246
+ response = await this.privatePatchMarginOrderClientOrderId(this.extend(request, params));
2247
+ }
2248
+ else {
2249
+ if (marketType === 'spot') {
2250
+ response = await this.privatePatchSpotOrderClientOrderId(this.extend(request, params));
2251
+ }
2252
+ else if (marketType === 'swap') {
2253
+ response = await this.privatePatchFuturesOrderClientOrderId(this.extend(request, params));
2254
+ }
2255
+ else if (marketType === 'margin') {
2256
+ response = await this.privatePatchMarginOrderClientOrderId(this.extend(request, params));
2257
+ }
2258
+ else {
2259
+ throw new errors.NotSupported(this.id + ' editOrder() not support this market type');
2260
+ }
2113
2261
  }
2114
- const response = await this[method](this.extend(request, query));
2115
2262
  return this.parseOrder(response, market);
2116
2263
  }
2117
2264
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -2440,6 +2587,7 @@ class hitbtc extends hitbtc$1 {
2440
2587
  * @method
2441
2588
  * @name hitbtc#transfer
2442
2589
  * @description transfer currency internally between wallets on the same account
2590
+ * @see https://api.hitbtc.com/#transfer-between-wallet-and-exchange
2443
2591
  * @param {string} code unified currency code
2444
2592
  * @param {float} amount amount to transfer
2445
2593
  * @param {string} fromAccount account to transfer from
@@ -2527,6 +2675,7 @@ class hitbtc extends hitbtc$1 {
2527
2675
  * @method
2528
2676
  * @name hitbtc#withdraw
2529
2677
  * @description make a withdrawal
2678
+ * @see https://api.hitbtc.com/#withdraw-crypto
2530
2679
  * @param {string} code unified currency code
2531
2680
  * @param {float} amount the amount to withdraw
2532
2681
  * @param {string} address the address to withdraw to
@@ -2708,6 +2857,8 @@ class hitbtc extends hitbtc$1 {
2708
2857
  * @method
2709
2858
  * @name hitbtc#fetchPositions
2710
2859
  * @description fetch all open positions
2860
+ * @see https://api.hitbtc.com/#get-futures-margin-accounts
2861
+ * @see https://api.hitbtc.com/#get-all-margin-accounts
2711
2862
  * @param {string[]|undefined} symbols not used by hitbtc fetchPositions ()
2712
2863
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2713
2864
  * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
@@ -2717,16 +2868,25 @@ class hitbtc extends hitbtc$1 {
2717
2868
  await this.loadMarkets();
2718
2869
  const request = {};
2719
2870
  let marketType = undefined;
2871
+ let marginMode = undefined;
2720
2872
  [marketType, params] = this.handleMarketTypeAndParams('fetchPositions', undefined, params);
2721
- let method = this.getSupportedMapping(marketType, {
2722
- 'swap': 'privateGetFuturesAccount',
2723
- 'margin': 'privateGetMarginAccount',
2724
- });
2725
- const [marginMode, query] = this.handleMarginModeAndParams('fetchPositions', params);
2873
+ [marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params);
2874
+ params = this.omit(params, ['marginMode', 'margin']);
2875
+ let response = undefined;
2726
2876
  if (marginMode !== undefined) {
2727
- method = 'privateGetMarginAccount';
2877
+ response = await this.privateGetMarginAccount(this.extend(request, params));
2878
+ }
2879
+ else {
2880
+ if (marketType === 'swap') {
2881
+ response = await this.privateGetFuturesAccount(this.extend(request, params));
2882
+ }
2883
+ else if (marketType === 'margin') {
2884
+ response = await this.privateGetMarginAccount(this.extend(request, params));
2885
+ }
2886
+ else {
2887
+ throw new errors.NotSupported(this.id + ' fetchPositions() not support this market type');
2888
+ }
2728
2889
  }
2729
- const response = await this[method](this.extend(request, query));
2730
2890
  //
2731
2891
  // [
2732
2892
  // {
@@ -2770,6 +2930,8 @@ class hitbtc extends hitbtc$1 {
2770
2930
  * @method
2771
2931
  * @name hitbtc#fetchPosition
2772
2932
  * @description fetch data on a single open contract trade position
2933
+ * @see https://api.hitbtc.com/#get-futures-margin-account
2934
+ * @see https://api.hitbtc.com/#get-isolated-margin-account
2773
2935
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
2774
2936
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2775
2937
  * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
@@ -2777,21 +2939,30 @@ class hitbtc extends hitbtc$1 {
2777
2939
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2778
2940
  */
2779
2941
  await this.loadMarkets();
2780
- let marketType = undefined;
2781
- [marketType, params] = this.handleMarketTypeAndParams('fetchPosition', undefined, params);
2782
- let method = this.getSupportedMapping(marketType, {
2783
- 'swap': 'privateGetFuturesAccountIsolatedSymbol',
2784
- 'margin': 'privateGetMarginAccountIsolatedSymbol',
2785
- });
2786
- const [marginMode, query] = this.handleMarginModeAndParams('fetchPosition', params);
2787
- if (marginMode !== undefined) {
2788
- method = 'privateGetMarginAccountIsolatedSymbol';
2789
- }
2790
2942
  const market = this.market(symbol);
2791
2943
  const request = {
2792
2944
  'symbol': market['id'],
2793
2945
  };
2794
- const response = await this[method](this.extend(request, query));
2946
+ let marketType = undefined;
2947
+ let marginMode = undefined;
2948
+ [marketType, params] = this.handleMarketTypeAndParams('fetchPosition', undefined, params);
2949
+ [marginMode, params] = this.handleMarginModeAndParams('fetchPosition', params);
2950
+ params = this.omit(params, ['marginMode', 'margin']);
2951
+ let response = undefined;
2952
+ if (marginMode !== undefined) {
2953
+ response = await this.privateGetMarginAccountIsolatedSymbol(this.extend(request, params));
2954
+ }
2955
+ else {
2956
+ if (marketType === 'swap') {
2957
+ response = await this.privateGetFuturesAccountIsolatedSymbol(this.extend(request, params));
2958
+ }
2959
+ else if (marketType === 'margin') {
2960
+ response = await this.privateGetMarginAccountIsolatedSymbol(this.extend(request, params));
2961
+ }
2962
+ else {
2963
+ throw new errors.NotSupported(this.id + ' fetchPosition() not support this market type');
2964
+ }
2965
+ }
2795
2966
  //
2796
2967
  // [
2797
2968
  // {
@@ -3058,7 +3229,12 @@ class hitbtc extends hitbtc$1 {
3058
3229
  throw new errors.ArgumentsRequired(this.id + ' modifyMarginHelper() requires a leverage parameter for swap markets');
3059
3230
  }
3060
3231
  }
3061
- amount = this.amountToPrecision(symbol, amount);
3232
+ if (amount !== 0) {
3233
+ amount = this.amountToPrecision(symbol, amount);
3234
+ }
3235
+ else {
3236
+ amount = '0';
3237
+ }
3062
3238
  const request = {
3063
3239
  'symbol': market['id'],
3064
3240
  'margin_balance': amount, // swap and margin
@@ -3069,16 +3245,25 @@ class hitbtc extends hitbtc$1 {
3069
3245
  request['leverage'] = leverage;
3070
3246
  }
3071
3247
  let marketType = undefined;
3072
- [marketType, params] = this.handleMarketTypeAndParams('modifyMarginHelper', undefined, params);
3073
- let method = this.getSupportedMapping(marketType, {
3074
- 'swap': 'privatePutFuturesAccountIsolatedSymbol',
3075
- 'margin': 'privatePutMarginAccountIsolatedSymbol',
3076
- });
3077
- const [marginMode, query] = this.handleMarginModeAndParams('modifyMarginHelper', params);
3248
+ let marginMode = undefined;
3249
+ [marketType, params] = this.handleMarketTypeAndParams('modifyMarginHelper', market, params);
3250
+ [marginMode, params] = this.handleMarginModeAndParams('modifyMarginHelper', params);
3251
+ params = this.omit(params, ['marginMode', 'margin']);
3252
+ let response = undefined;
3078
3253
  if (marginMode !== undefined) {
3079
- method = 'privatePutMarginAccountIsolatedSymbol';
3254
+ response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3255
+ }
3256
+ else {
3257
+ if (marketType === 'swap') {
3258
+ response = await this.privatePutFuturesAccountIsolatedSymbol(this.extend(request, params));
3259
+ }
3260
+ else if (marketType === 'margin') {
3261
+ response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3262
+ }
3263
+ else {
3264
+ throw new errors.NotSupported(this.id + ' modifyMarginHelper() not support this market type');
3265
+ }
3080
3266
  }
3081
- const response = await this[method](this.extend(request, query));
3082
3267
  //
3083
3268
  // {
3084
3269
  // "symbol": "BTCUSDT_PERP",
@@ -3119,6 +3304,8 @@ class hitbtc extends hitbtc$1 {
3119
3304
  * @method
3120
3305
  * @name hitbtc#reduceMargin
3121
3306
  * @description remove margin from a position
3307
+ * @see https://api.hitbtc.com/#create-update-margin-account-2
3308
+ * @see https://api.hitbtc.com/#create-update-margin-account
3122
3309
  * @param {string} symbol unified market symbol
3123
3310
  * @param {float} amount the amount of margin to remove
3124
3311
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3136,6 +3323,8 @@ class hitbtc extends hitbtc$1 {
3136
3323
  * @method
3137
3324
  * @name hitbtc#addMargin
3138
3325
  * @description add margin
3326
+ * @see https://api.hitbtc.com/#create-update-margin-account-2
3327
+ * @see https://api.hitbtc.com/#create-update-margin-account
3139
3328
  * @param {string} symbol unified market symbol
3140
3329
  * @param {float} amount amount of margin to add
3141
3330
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3150,6 +3339,8 @@ class hitbtc extends hitbtc$1 {
3150
3339
  * @method
3151
3340
  * @name hitbtc#fetchLeverage
3152
3341
  * @description fetch the set leverage for a market
3342
+ * @see https://api.hitbtc.com/#get-futures-margin-account
3343
+ * @see https://api.hitbtc.com/#get-isolated-margin-account
3153
3344
  * @param {string} symbol unified market symbol
3154
3345
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3155
3346
  * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if this is set
@@ -3161,16 +3352,27 @@ class hitbtc extends hitbtc$1 {
3161
3352
  const request = {
3162
3353
  'symbol': market['id'],
3163
3354
  };
3164
- let method = this.getSupportedMapping(market['type'], {
3165
- 'spot': 'privateGetMarginAccountIsolatedSymbol',
3166
- 'margin': 'privateGetMarginAccountIsolatedSymbol',
3167
- 'swap': 'privateGetFuturesAccountIsolatedSymbol',
3168
- });
3169
- const [marginMode, query] = this.handleMarginModeAndParams('modifyMarginHelper', params);
3355
+ let marginMode = undefined;
3356
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params);
3357
+ params = this.omit(params, ['marginMode', 'margin']);
3358
+ let response = undefined;
3170
3359
  if (marginMode !== undefined) {
3171
- method = 'privateGetMarginAccountIsolatedSymbol';
3360
+ response = await this.privateGetMarginAccountIsolatedSymbol(this.extend(request, params));
3361
+ }
3362
+ else {
3363
+ if (market['type'] === 'spot') {
3364
+ response = await this.privateGetMarginAccountIsolatedSymbol(this.extend(request, params));
3365
+ }
3366
+ else if (market['type'] === 'swap') {
3367
+ response = await this.privateGetFuturesAccountIsolatedSymbol(this.extend(request, params));
3368
+ }
3369
+ else if (market['type'] === 'margin') {
3370
+ response = await this.privateGetMarginAccountIsolatedSymbol(this.extend(request, params));
3371
+ }
3372
+ else {
3373
+ throw new errors.NotSupported(this.id + ' fetchLeverage() not support this market type');
3374
+ }
3172
3375
  }
3173
- const response = await this[method](this.extend(request, query));
3174
3376
  //
3175
3377
  // {
3176
3378
  // "symbol": "BTCUSDT",
@@ -3208,6 +3410,7 @@ class hitbtc extends hitbtc$1 {
3208
3410
  * @method
3209
3411
  * @name hitbtc#setLeverage
3210
3412
  * @description set the level of leverage for a market
3413
+ * @see https://api.hitbtc.com/#create-update-margin-account-2
3211
3414
  * @param {float} leverage the rate of leverage
3212
3415
  * @param {string} symbol unified market symbol
3213
3416
  * @param {object} [params] extra parameters specific to the exchange API endpoint