ccxt 4.1.30 → 4.1.32

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 (56) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +428 -174
  4. package/dist/ccxt.browser.min.js +3 -3
  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/bitget.js +43 -27
  9. package/dist/cjs/src/bitvavo.js +43 -7
  10. package/dist/cjs/src/bybit.js +0 -3
  11. package/dist/cjs/src/coinex.js +2 -1
  12. package/dist/cjs/src/gemini.js +1 -2
  13. package/dist/cjs/src/hitbtc.js +32 -22
  14. package/dist/cjs/src/huobi.js +18 -12
  15. package/dist/cjs/src/krakenfutures.js +1 -0
  16. package/dist/cjs/src/mexc.js +2 -6
  17. package/dist/cjs/src/okx.js +1 -0
  18. package/dist/cjs/src/phemex.js +8 -6
  19. package/dist/cjs/src/pro/bittrex.js +68 -2
  20. package/dist/cjs/src/pro/huobi.js +76 -32
  21. package/dist/cjs/src/woo.js +27 -31
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +1 -1
  24. package/js/src/ascendex.d.ts +11 -1
  25. package/js/src/ascendex.js +89 -12
  26. package/js/src/base/Exchange.d.ts +5 -3
  27. package/js/src/base/Exchange.js +6 -0
  28. package/js/src/base/types.d.ts +9 -0
  29. package/js/src/binance.d.ts +1 -1
  30. package/js/src/bitget.d.ts +3 -3
  31. package/js/src/bitget.js +43 -27
  32. package/js/src/bitvavo.d.ts +13 -13
  33. package/js/src/bitvavo.js +43 -7
  34. package/js/src/bybit.js +0 -3
  35. package/js/src/coinex.d.ts +2 -2
  36. package/js/src/coinex.js +2 -1
  37. package/js/src/gate.d.ts +3 -3
  38. package/js/src/gemini.js +1 -2
  39. package/js/src/hitbtc.js +33 -23
  40. package/js/src/huobi.d.ts +1 -1
  41. package/js/src/huobi.js +18 -12
  42. package/js/src/krakenfutures.js +1 -0
  43. package/js/src/kucoinfutures.d.ts +2 -2
  44. package/js/src/mexc.d.ts +2 -2
  45. package/js/src/mexc.js +2 -6
  46. package/js/src/okx.d.ts +2 -2
  47. package/js/src/okx.js +1 -0
  48. package/js/src/phemex.d.ts +2 -2
  49. package/js/src/phemex.js +8 -6
  50. package/js/src/poloniexfutures.d.ts +2 -2
  51. package/js/src/pro/bittrex.d.ts +1 -0
  52. package/js/src/pro/bittrex.js +69 -3
  53. package/js/src/pro/huobi.js +76 -32
  54. package/js/src/woo.d.ts +1 -1
  55. package/js/src/woo.js +27 -31
  56. package/package.json +2 -2
package/js/src/bitvavo.js CHANGED
@@ -504,6 +504,7 @@ export default class bitvavo extends Exchange {
504
504
  /**
505
505
  * @method
506
506
  * @name bitvavo#fetchTicker
507
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1ticker~124h/get
507
508
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
508
509
  * @param {string} symbol unified symbol of the market to fetch the ticker for
509
510
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
@@ -617,16 +618,24 @@ export default class bitvavo extends Exchange {
617
618
  /**
618
619
  * @method
619
620
  * @name bitvavo#fetchTrades
621
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1trades/get
620
622
  * @description get the list of most recent trades for a particular symbol
621
623
  * @param {string} symbol unified symbol of the market to fetch trades for
622
624
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
623
625
  * @param {int} [limit] the maximum amount of trades to fetch
624
626
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
627
+ * @param {int} [params.until] the latest time in ms to fetch entries for
628
+ * @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)
625
629
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
626
630
  */
627
631
  await this.loadMarkets();
628
632
  const market = this.market(symbol);
629
- const request = {
633
+ let paginate = false;
634
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
635
+ if (paginate) {
636
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
637
+ }
638
+ let request = {
630
639
  'market': market['id'],
631
640
  // 'limit': 500, // default 500, max 1000
632
641
  // 'start': since,
@@ -640,6 +649,7 @@ export default class bitvavo extends Exchange {
640
649
  if (since !== undefined) {
641
650
  request['start'] = since;
642
651
  }
652
+ [request, params] = this.handleUntilOption('end', request, params);
643
653
  const response = await this.publicGetMarketTrades(this.extend(request, params));
644
654
  //
645
655
  // [
@@ -790,6 +800,7 @@ export default class bitvavo extends Exchange {
790
800
  /**
791
801
  * @method
792
802
  * @name bitvavo#fetchOrderBook
803
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1book/get
793
804
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
794
805
  * @param {string} symbol unified symbol of the market to fetch the order book for
795
806
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -849,17 +860,25 @@ export default class bitvavo extends Exchange {
849
860
  /**
850
861
  * @method
851
862
  * @name bitvavo#fetchOHLCV
863
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1candles/get
852
864
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
853
865
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
854
866
  * @param {string} timeframe the length of time each candle represents
855
867
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
856
868
  * @param {int} [limit] the maximum amount of candles to fetch
857
869
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
870
+ * @param {int} [params.until] the latest time in ms to fetch entries for
871
+ * @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)
858
872
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
859
873
  */
860
874
  await this.loadMarkets();
861
875
  const market = this.market(symbol);
862
- const request = {
876
+ let paginate = false;
877
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
878
+ if (paginate) {
879
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1440);
880
+ }
881
+ let request = {
863
882
  'market': market['id'],
864
883
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
865
884
  // 'limit': 1440, // default 1440, max 1440
@@ -875,6 +894,7 @@ export default class bitvavo extends Exchange {
875
894
  }
876
895
  request['end'] = this.sum(since, limit * duration * 1000);
877
896
  }
897
+ [request, params] = this.handleUntilOption('end', request, params);
878
898
  if (limit !== undefined) {
879
899
  request['limit'] = limit; // default 1440, max 1440
880
900
  }
@@ -1228,19 +1248,25 @@ export default class bitvavo extends Exchange {
1228
1248
  /**
1229
1249
  * @method
1230
1250
  * @name bitvavo#fetchOrders
1251
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1orders/get
1231
1252
  * @description fetches information on multiple orders made by the user
1232
1253
  * @param {string} symbol unified market symbol of the market orders were made in
1233
1254
  * @param {int} [since] the earliest time in ms to fetch orders for
1234
1255
  * @param {int} [limit] the maximum number of orde structures to retrieve
1235
1256
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
1257
+ * @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)
1258
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1236
1259
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1237
1260
  */
1238
- if (symbol === undefined) {
1239
- throw new ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
1240
- }
1261
+ this.checkRequiredSymbol('fetchOrders', symbol);
1241
1262
  await this.loadMarkets();
1263
+ let paginate = false;
1264
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
1265
+ if (paginate) {
1266
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
1267
+ }
1242
1268
  const market = this.market(symbol);
1243
- const request = {
1269
+ let request = {
1244
1270
  'market': market['id'],
1245
1271
  // 'limit': 500,
1246
1272
  // 'start': since,
@@ -1254,6 +1280,7 @@ export default class bitvavo extends Exchange {
1254
1280
  if (limit !== undefined) {
1255
1281
  request['limit'] = limit; // default 500, max 1000
1256
1282
  }
1283
+ [request, params] = this.handleUntilOption('end', request, params);
1257
1284
  const response = await this.privateGetOrders(this.extend(request, params));
1258
1285
  //
1259
1286
  // [
@@ -1478,19 +1505,27 @@ export default class bitvavo extends Exchange {
1478
1505
  /**
1479
1506
  * @method
1480
1507
  * @name bitvavo#fetchMyTrades
1508
+ * @see https://docs.bitvavo.com/#tag/Trades/paths/~1trades/get
1481
1509
  * @description fetch all trades made by the user
1482
1510
  * @param {string} symbol unified market symbol
1483
1511
  * @param {int} [since] the earliest time in ms to fetch trades for
1484
1512
  * @param {int} [limit] the maximum number of trades structures to retrieve
1485
1513
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
1514
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1515
+ * @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)
1486
1516
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1487
1517
  */
1488
1518
  if (symbol === undefined) {
1489
1519
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1490
1520
  }
1491
1521
  await this.loadMarkets();
1522
+ let paginate = false;
1523
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1524
+ if (paginate) {
1525
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1526
+ }
1492
1527
  const market = this.market(symbol);
1493
- const request = {
1528
+ let request = {
1494
1529
  'market': market['id'],
1495
1530
  // 'limit': 500,
1496
1531
  // 'start': since,
@@ -1504,6 +1539,7 @@ export default class bitvavo extends Exchange {
1504
1539
  if (limit !== undefined) {
1505
1540
  request['limit'] = limit; // default 500, max 1000
1506
1541
  }
1542
+ [request, params] = this.handleUntilOption('end', request, params);
1507
1543
  const response = await this.privateGetTrades(this.extend(request, params));
1508
1544
  //
1509
1545
  // [
package/js/src/bybit.js CHANGED
@@ -1201,9 +1201,6 @@ export default class bybit extends Exchange {
1201
1201
  'deposit': {},
1202
1202
  },
1203
1203
  },
1204
- 'commonCurrencies': {
1205
- 'GAS': 'GASDAO',
1206
- },
1207
1204
  });
1208
1205
  }
1209
1206
  nonce() {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinex.js';
2
- import { FundingRateHistory, Int, OrderSide, OrderType } from './base/types.js';
2
+ import { FundingHistory, FundingRateHistory, Int, OrderSide, OrderType } from './base/types.js';
3
3
  /**
4
4
  * @class coinex
5
5
  * @extends Exchange
@@ -94,7 +94,7 @@ export default class coinex extends Exchange {
94
94
  };
95
95
  addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
96
96
  reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
97
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
97
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
98
98
  fetchFundingRate(symbol: string, params?: {}): Promise<{
99
99
  info: any;
100
100
  symbol: any;
package/js/src/coinex.js CHANGED
@@ -1754,7 +1754,8 @@ export default class coinex extends Exchange {
1754
1754
  const remainingString = this.safeString(order, 'left');
1755
1755
  const marketId = this.safeString(order, 'market');
1756
1756
  const defaultType = this.safeString(this.options, 'defaultType');
1757
- market = this.safeMarket(marketId, market, undefined, defaultType);
1757
+ const orderType = ('source' in order) ? 'swap' : defaultType;
1758
+ market = this.safeMarket(marketId, market, undefined, orderType);
1758
1759
  const feeCurrencyId = this.safeString(order, 'fee_asset');
1759
1760
  let feeCurrency = this.safeCurrencyCode(feeCurrencyId);
1760
1761
  if (feeCurrency === undefined) {
package/js/src/gate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/gate.js';
2
- import { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory } from './base/types.js';
3
3
  /**
4
4
  * @class gate
5
5
  * @extends Exchange
@@ -192,8 +192,8 @@ export default class gate extends Exchange {
192
192
  };
193
193
  networks: {};
194
194
  };
195
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
196
- parseFundingHistories(response: any, symbol: any, since: any, limit: any): any;
195
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
196
+ parseFundingHistories(response: any, symbol: any, since: any, limit: any): FundingHistory[];
197
197
  parseFundingHistory(info: any, market?: any): {
198
198
  info: any;
199
199
  symbol: string;
package/js/src/gemini.js CHANGED
@@ -560,11 +560,10 @@ export default class gemini extends Exchange {
560
560
  }
561
561
  for (let i = 0; i < marketIds.length; i++) {
562
562
  const marketId = marketIds[i];
563
- const method = 'publicGetV1SymbolsDetailsSymbol';
564
563
  const request = {
565
564
  'symbol': marketId,
566
565
  };
567
- promises.push(this[method](this.extend(request, params)));
566
+ promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
568
567
  //
569
568
  // {
570
569
  // "symbol": "BTCUSD",
package/js/src/hitbtc.js CHANGED
@@ -7,7 +7,7 @@
7
7
  import Exchange from './abstract/hitbtc.js';
8
8
  import { TICK_SIZE } from './base/functions/number.js';
9
9
  import { Precise } from './base/Precise.js';
10
- import { BadSymbol, BadRequest, OnMaintenance, AccountSuspended, PermissionDenied, ExchangeError, RateLimitExceeded, ExchangeNotAvailable, OrderNotFound, InsufficientFunds, InvalidOrder, AuthenticationError, ArgumentsRequired, NotSupported } from './base/errors.js';
10
+ import { BadSymbol, BadRequest, OnMaintenance, AccountSuspended, PermissionDenied, ExchangeError, RateLimitExceeded, ExchangeNotAvailable, OrderNotFound, InsufficientFunds, InvalidOrder, AuthenticationError, ArgumentsRequired } from './base/errors.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  /**
13
13
  * @class hitbtc
@@ -36,6 +36,7 @@ export default class hitbtc extends Exchange {
36
36
  'cancelOrder': true,
37
37
  'createDepositAddress': true,
38
38
  'createOrder': true,
39
+ 'createPostOnlyOrder': true,
39
40
  'createReduceOnlyOrder': true,
40
41
  'createStopLimitOrder': true,
41
42
  'createStopMarketOrder': true,
@@ -2050,14 +2051,24 @@ export default class hitbtc extends Exchange {
2050
2051
  * @param {float} amount how much of currency you want to trade in units of base currency
2051
2052
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2052
2053
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
2053
- * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
2054
+ * @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported for spot-margin, swap supports both
2054
2055
  * @param {bool} [params.margin] true for creating a margin order
2055
2056
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2057
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2058
+ * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", "Day", "GTD"
2056
2059
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2057
2060
  */
2058
2061
  await this.loadMarkets();
2059
2062
  const market = this.market(symbol);
2060
2063
  const isLimit = (type === 'limit');
2064
+ const reduceOnly = this.safeValue(params, 'reduceOnly');
2065
+ const timeInForce = this.safeString(params, 'timeInForce');
2066
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
2067
+ let marketType = undefined;
2068
+ [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
2069
+ let marginMode = undefined;
2070
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
2071
+ const isPostOnly = this.isPostOnly(type === 'market', undefined, params);
2061
2072
  const request = {
2062
2073
  'type': type,
2063
2074
  'side': side,
@@ -2075,7 +2086,6 @@ export default class hitbtc extends Exchange {
2075
2086
  // 'take_rate': 0.001, // Optional
2076
2087
  // 'make_rate': 0.001, // Optional
2077
2088
  };
2078
- const reduceOnly = this.safeValue(params, 'reduceOnly');
2079
2089
  if (reduceOnly !== undefined) {
2080
2090
  if ((market['type'] !== 'swap') && (market['type'] !== 'margin')) {
2081
2091
  throw new InvalidOrder(this.id + ' createOrder() does not support reduce_only for ' + market['type'] + ' orders, reduce_only orders are supported for swap and margin markets only');
@@ -2084,8 +2094,12 @@ export default class hitbtc extends Exchange {
2084
2094
  if (reduceOnly === true) {
2085
2095
  request['reduce_only'] = reduceOnly;
2086
2096
  }
2087
- const timeInForce = this.safeString2(params, 'timeInForce', 'time_in_force');
2088
- const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
2097
+ if (isPostOnly) {
2098
+ request['post_only'] = true;
2099
+ }
2100
+ if (timeInForce !== undefined) {
2101
+ request['time_in_force'] = timeInForce;
2102
+ }
2089
2103
  if (isLimit || (type === 'stopLimit') || (type === 'takeProfitLimit')) {
2090
2104
  if (price === undefined) {
2091
2105
  throw new ExchangeError(this.id + ' createOrder() requires a price argument for limit orders');
@@ -2110,19 +2124,20 @@ export default class hitbtc extends Exchange {
2110
2124
  else if ((type === 'stopLimit') || (type === 'stopMarket') || (type === 'takeProfitLimit') || (type === 'takeProfitMarket')) {
2111
2125
  throw new ExchangeError(this.id + ' createOrder() requires a stopPrice parameter for stop-loss and take-profit orders');
2112
2126
  }
2113
- let marketType = undefined;
2114
- [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
2115
- let method = this.getSupportedMapping(marketType, {
2116
- 'spot': 'privatePostSpotOrder',
2117
- 'swap': 'privatePostFuturesOrder',
2118
- 'margin': 'privatePostMarginOrder',
2119
- });
2120
- const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
2121
- if (marginMode !== undefined) {
2122
- method = 'privatePostMarginOrder';
2127
+ params = this.omit(params, ['triggerPrice', 'timeInForce', 'stopPrice', 'stop_price', 'reduceOnly', 'postOnly']);
2128
+ if ((marketType === 'swap') && (marginMode !== undefined)) {
2129
+ request['margin_mode'] = marginMode;
2130
+ }
2131
+ let response = undefined;
2132
+ if (marketType === 'swap') {
2133
+ response = await this.privatePostFuturesOrder(this.extend(request, params));
2134
+ }
2135
+ else if ((marketType === 'margin') || (marginMode !== undefined)) {
2136
+ response = await this.privatePostMarginOrder(this.extend(request, params));
2137
+ }
2138
+ else {
2139
+ response = await this.privatePostSpotOrder(this.extend(request, params));
2123
2140
  }
2124
- params = this.omit(params, ['triggerPrice', 'timeInForce', 'time_in_force', 'stopPrice', 'stop_price', 'reduceOnly']);
2125
- const response = await this[method](this.extend(request, query));
2126
2141
  return this.parseOrder(response, market);
2127
2142
  }
2128
2143
  parseOrderStatus(status) {
@@ -3045,12 +3060,7 @@ export default class hitbtc extends Exchange {
3045
3060
  const isMargin = this.safeValue(params, 'margin', false);
3046
3061
  let marginMode = undefined;
3047
3062
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3048
- if (marginMode !== undefined) {
3049
- if (marginMode !== 'isolated') {
3050
- throw new NotSupported(this.id + ' only isolated margin is supported');
3051
- }
3052
- }
3053
- else {
3063
+ if (marginMode === undefined) {
3054
3064
  if ((defaultType === 'margin') || (isMargin === true)) {
3055
3065
  marginMode = 'isolated';
3056
3066
  }
package/js/src/huobi.d.ts CHANGED
@@ -237,7 +237,7 @@ export default class huobi extends Exchange {
237
237
  headers: any;
238
238
  };
239
239
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
240
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
240
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").FundingHistory[]>;
241
241
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
242
242
  parseIncome(income: any, market?: any): {
243
243
  info: any;
package/js/src/huobi.js CHANGED
@@ -875,6 +875,7 @@ export default class huobi extends Exchange {
875
875
  '1220': AccountNotEnabled,
876
876
  '1303': BadRequest,
877
877
  '1461': InvalidOrder,
878
+ '4007': BadRequest,
878
879
  'bad-request': BadRequest,
879
880
  'validation-format-error': BadRequest,
880
881
  'validation-constraints-required': BadRequest,
@@ -3017,6 +3018,13 @@ export default class huobi extends Exchange {
3017
3018
  /**
3018
3019
  * @method
3019
3020
  * @name huobi#fetchBalance
3021
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
3022
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
3023
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
3024
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
3025
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
3026
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
3027
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information
3020
3028
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
3021
3029
  * @param {object} [params] extra parameters specific to the huobi api endpoint
3022
3030
  * @param {bool} [params.unified] provide this parameter if you have a recent account with unified cross+isolated margin account
@@ -3029,10 +3037,8 @@ export default class huobi extends Exchange {
3029
3037
  const isUnifiedAccount = this.safeValue2(params, 'isUnifiedAccount', 'unified', false);
3030
3038
  params = this.omit(params, ['isUnifiedAccount', 'unified']);
3031
3039
  const request = {};
3032
- let method = undefined;
3033
3040
  const spot = (type === 'spot');
3034
3041
  const future = (type === 'future');
3035
- const swap = (type === 'swap');
3036
3042
  const defaultSubType = this.safeString2(this.options, 'defaultSubType', 'subType', 'linear');
3037
3043
  let subType = this.safeString2(options, 'defaultSubType', 'subType', defaultSubType);
3038
3044
  subType = this.safeString2(params, 'defaultSubType', 'subType', subType);
@@ -3044,42 +3050,42 @@ export default class huobi extends Exchange {
3044
3050
  const isolated = (marginMode === 'isolated');
3045
3051
  const cross = (marginMode === 'cross');
3046
3052
  const margin = (type === 'margin') || (spot && (cross || isolated));
3053
+ let response = undefined;
3047
3054
  if (spot || margin) {
3048
3055
  if (margin) {
3049
3056
  if (isolated) {
3050
- method = 'spotPrivateGetV1MarginAccountsBalance';
3057
+ response = await this.spotPrivateGetV1MarginAccountsBalance(this.extend(request, params));
3051
3058
  }
3052
3059
  else {
3053
- method = 'spotPrivateGetV1CrossMarginAccountsBalance';
3060
+ response = await this.spotPrivateGetV1CrossMarginAccountsBalance(this.extend(request, params));
3054
3061
  }
3055
3062
  }
3056
3063
  else {
3057
3064
  await this.loadAccounts();
3058
3065
  const accountId = await this.fetchAccountIdByType(type, undefined, undefined, params);
3059
3066
  request['account-id'] = accountId;
3060
- method = 'spotPrivateGetV1AccountAccountsAccountIdBalance';
3067
+ response = await this.spotPrivateGetV1AccountAccountsAccountIdBalance(this.extend(request, params));
3061
3068
  }
3062
3069
  }
3063
3070
  else if (isUnifiedAccount) {
3064
- method = 'contractPrivateGetLinearSwapApiV3UnifiedAccountInfo';
3071
+ response = await this.contractPrivateGetLinearSwapApiV3UnifiedAccountInfo(this.extend(request, params));
3065
3072
  }
3066
3073
  else if (linear) {
3067
3074
  if (isolated) {
3068
- method = 'contractPrivatePostLinearSwapApiV1SwapAccountInfo';
3075
+ response = await this.contractPrivatePostLinearSwapApiV1SwapAccountInfo(this.extend(request, params));
3069
3076
  }
3070
3077
  else {
3071
- method = 'contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo';
3078
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo(this.extend(request, params));
3072
3079
  }
3073
3080
  }
3074
3081
  else if (inverse) {
3075
3082
  if (future) {
3076
- method = 'contractPrivatePostApiV1ContractAccountInfo';
3083
+ response = await this.contractPrivatePostApiV1ContractAccountInfo(this.extend(request, params));
3077
3084
  }
3078
- else if (swap) {
3079
- method = 'contractPrivatePostSwapApiV1SwapAccountInfo';
3085
+ else {
3086
+ response = await this.contractPrivatePostSwapApiV1SwapAccountInfo(this.extend(request, params));
3080
3087
  }
3081
3088
  }
3082
- const response = await this[method](this.extend(request, params));
3083
3089
  //
3084
3090
  // spot
3085
3091
  //
@@ -2346,6 +2346,7 @@ export default class krakenfutures extends Exchange {
2346
2346
  }
2347
2347
  const url = this.urls['api'][api] + query;
2348
2348
  if (api === 'private' || access === 'private') {
2349
+ this.checkRequiredCredentials();
2349
2350
  let auth = postData + '/api/';
2350
2351
  if (api !== 'private') {
2351
2352
  auth += api + '/';
@@ -1,5 +1,5 @@
1
1
  import kucoin from './abstract/kucoinfutures.js';
2
- import { Dictionary, Int, OrderSide, Ticker, OrderType, OHLCV, Order, Trade, FundingRateHistory } from './base/types.js';
2
+ import { Dictionary, Int, OrderSide, Ticker, OrderType, OHLCV, Order, Trade, FundingRateHistory, FundingHistory } from './base/types.js';
3
3
  export default class kucoinfutures extends kucoin {
4
4
  describe(): any;
5
5
  fetchStatus(params?: {}): Promise<{
@@ -25,7 +25,7 @@ export default class kucoinfutures extends kucoin {
25
25
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
26
26
  fetchTickers(symbols?: string[], params?: {}): Promise<Dictionary<Ticker>>;
27
27
  parseTicker(ticker: any, market?: any): Ticker;
28
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
28
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
29
29
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
30
30
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
31
31
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
package/js/src/mexc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/mexc.js';
2
- import { IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest } from './base/types.js';
2
+ import { IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest, FundingHistory } from './base/types.js';
3
3
  /**
4
4
  * @class mexc
5
5
  * @extends Exchange
@@ -62,7 +62,7 @@ export default class mexc extends Exchange {
62
62
  reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
63
63
  addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
64
64
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
65
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
65
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
66
66
  parseFundingRate(contract: any, market?: any): {
67
67
  info: any;
68
68
  symbol: any;
package/js/src/mexc.js CHANGED
@@ -30,8 +30,8 @@ export default class mexc extends Exchange {
30
30
  'spot': true,
31
31
  'margin': true,
32
32
  'swap': true,
33
- 'future': true,
34
- 'option': undefined,
33
+ 'future': false,
34
+ 'option': false,
35
35
  'addMargin': true,
36
36
  'borrowMargin': true,
37
37
  'cancelAllOrders': true,
@@ -399,10 +399,6 @@ export default class mexc extends Exchange {
399
399
  'fetchMarkets': {
400
400
  'types': {
401
401
  'spot': true,
402
- 'future': {
403
- 'linear': false,
404
- 'inverse': false,
405
- },
406
402
  'swap': {
407
403
  'linear': true,
408
404
  'inverse': false,
package/js/src/okx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/okx.js';
2
- import { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory } from './base/types.js';
3
3
  /**
4
4
  * @class okx
5
5
  * @extends Exchange
@@ -318,7 +318,7 @@ export default class okx extends Exchange {
318
318
  previousFundingTimestamp: any;
319
319
  previousFundingDatetime: any;
320
320
  }>;
321
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
321
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
322
322
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
323
323
  setPositionMode(hedged: any, symbol?: string, params?: {}): Promise<any>;
324
324
  setMarginMode(marginMode: any, symbol?: string, params?: {}): Promise<any>;
package/js/src/okx.js CHANGED
@@ -3088,6 +3088,7 @@ export default class okx extends Exchange {
3088
3088
  parseOrderStatus(status) {
3089
3089
  const statuses = {
3090
3090
  'canceled': 'canceled',
3091
+ 'order_failed': 'canceled',
3091
3092
  'live': 'open',
3092
3093
  'partially_filled': 'open',
3093
3094
  'filled': 'closed',
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/phemex.js';
2
- import { FundingRateHistory, Int, OrderBook, OrderSide, OrderType } from './base/types.js';
2
+ import { FundingHistory, FundingRateHistory, Int, OrderBook, OrderSide, OrderType } from './base/types.js';
3
3
  /**
4
4
  * @class phemex
5
5
  * @extends Exchange
@@ -185,7 +185,7 @@ export default class phemex extends Exchange {
185
185
  };
186
186
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
187
187
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
188
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
188
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
189
189
  fetchFundingRate(symbol: string, params?: {}): Promise<{
190
190
  info: any;
191
191
  symbol: any;
package/js/src/phemex.js CHANGED
@@ -3636,17 +3636,19 @@ export default class phemex extends Exchange {
3636
3636
  // 'limit': 20, // Page size default 20, max 200
3637
3637
  // 'offset': 0, // Page start default 0
3638
3638
  };
3639
- if (limit > 200) {
3640
- throw new BadRequest(this.id + ' fetchFundingHistory() limit argument cannot exceed 200');
3641
- }
3642
3639
  if (limit !== undefined) {
3640
+ if (limit > 200) {
3641
+ throw new BadRequest(this.id + ' fetchFundingHistory() limit argument cannot exceed 200');
3642
+ }
3643
3643
  request['limit'] = limit;
3644
3644
  }
3645
- let method = 'privateGetApiDataFuturesFundingFees';
3645
+ let response = undefined;
3646
3646
  if (market['settle'] === 'USDT') {
3647
- method = 'privateGetApiDataGFuturesFundingFees';
3647
+ response = await this.privateGetApiDataGFuturesFundingFees(this.extend(request, params));
3648
+ }
3649
+ else {
3650
+ response = await this.privateGetApiDataFuturesFundingFees(this.extend(request, params));
3648
3651
  }
3649
- const response = await this[method](this.extend(request, params));
3650
3652
  //
3651
3653
  // {
3652
3654
  // "code": 0,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/poloniexfutures.js';
2
- import { Int, OrderBook, OrderSide, OrderType } from './base/types.js';
2
+ import { FundingHistory, Int, OrderBook, OrderSide, OrderType } from './base/types.js';
3
3
  /**
4
4
  * @class poloniexfutures
5
5
  * @extends Exchange
@@ -47,7 +47,7 @@ export default class poloniexfutures extends Exchange {
47
47
  stopLossPrice: any;
48
48
  takeProfitPrice: any;
49
49
  };
50
- fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
50
+ fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
51
51
  cancelAllOrders(symbol?: string, params?: {}): Promise<any[]>;
52
52
  fetchOrdersByStatus(status: any, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
53
53
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
@@ -64,5 +64,6 @@ export default class bittrex extends bittrexRest {
64
64
  handleSystemStatusHelper(): Promise<void>;
65
65
  handleSystemStatus(client: Client, message: any): any;
66
66
  handleSubscriptionStatus(client: Client, message: any): any;
67
+ handleErrorMessage(client: Client, message: any): boolean;
67
68
  handleMessage(client: Client, message: any): void;
68
69
  }