ccxt 4.4.47 → 4.4.49

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 (135) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +16 -16
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ace.js +1 -1
  5. package/dist/cjs/src/binance.js +18 -14
  6. package/dist/cjs/src/bingx.js +88 -30
  7. package/dist/cjs/src/bitget.js +16 -12
  8. package/dist/cjs/src/bitmart.js +7 -2
  9. package/dist/cjs/src/bitmex.js +8 -5
  10. package/dist/cjs/src/bybit.js +7 -2
  11. package/dist/cjs/src/coinbase.js +11 -1
  12. package/dist/cjs/src/coincatch.js +86 -2
  13. package/dist/cjs/src/coincheck.js +52 -0
  14. package/dist/cjs/src/coinlist.js +77 -0
  15. package/dist/cjs/src/coinmate.js +63 -0
  16. package/dist/cjs/src/coinmetro.js +68 -0
  17. package/dist/cjs/src/coinone.js +56 -0
  18. package/dist/cjs/src/coinsph.js +85 -10
  19. package/dist/cjs/src/coinspot.js +47 -0
  20. package/dist/cjs/src/currencycom.js +72 -0
  21. package/dist/cjs/src/defx.js +93 -6
  22. package/dist/cjs/src/delta.js +83 -1
  23. package/dist/cjs/src/deribit.js +82 -0
  24. package/dist/cjs/src/digifinex.js +131 -11
  25. package/dist/cjs/src/ellipx.js +61 -0
  26. package/dist/cjs/src/exmo.js +58 -0
  27. package/dist/cjs/src/gate.js +10 -1
  28. package/dist/cjs/src/hitbtc.js +99 -0
  29. package/dist/cjs/src/hollaex.js +73 -0
  30. package/dist/cjs/src/htx.js +10 -2
  31. package/dist/cjs/src/huobijp.js +73 -0
  32. package/dist/cjs/src/hyperliquid.js +28 -2
  33. package/dist/cjs/src/idex.js +71 -0
  34. package/dist/cjs/src/independentreserve.js +124 -0
  35. package/dist/cjs/src/indodax.js +61 -0
  36. package/dist/cjs/src/kraken.js +1 -1
  37. package/dist/cjs/src/krakenfutures.js +4 -4
  38. package/dist/cjs/src/kuna.js +60 -1
  39. package/dist/cjs/src/latoken.js +64 -0
  40. package/dist/cjs/src/lbank.js +70 -0
  41. package/dist/cjs/src/luno.js +73 -0
  42. package/dist/cjs/src/lykke.js +64 -0
  43. package/dist/cjs/src/mercado.js +65 -0
  44. package/dist/cjs/src/mexc.js +1 -1
  45. package/dist/cjs/src/myokx.js +10 -0
  46. package/dist/cjs/src/ndax.js +71 -0
  47. package/dist/cjs/src/novadax.js +74 -0
  48. package/dist/cjs/src/oceanex.js +69 -0
  49. package/dist/cjs/src/okcoin.js +79 -2
  50. package/dist/cjs/src/okx.js +9 -1
  51. package/dist/cjs/src/onetrading.js +66 -0
  52. package/dist/cjs/src/oxfun.js +66 -0
  53. package/dist/cjs/src/p2b.js +63 -1
  54. package/dist/cjs/src/paradex.js +73 -2
  55. package/dist/cjs/src/phemex.js +103 -0
  56. package/dist/cjs/src/poloniex.js +61 -0
  57. package/dist/cjs/src/poloniexfutures.js +74 -0
  58. package/dist/cjs/src/pro/bitmart.js +6 -0
  59. package/dist/cjs/src/upbit.js +61 -0
  60. package/dist/cjs/src/woo.js +6 -1
  61. package/js/ccxt.d.ts +1 -1
  62. package/js/ccxt.js +1 -1
  63. package/js/src/abstract/independentreserve.d.ts +6 -0
  64. package/js/src/ace.js +1 -1
  65. package/js/src/binance.d.ts +7 -0
  66. package/js/src/binance.js +18 -14
  67. package/js/src/bingx.d.ts +8 -0
  68. package/js/src/bingx.js +88 -30
  69. package/js/src/bitget.d.ts +1 -0
  70. package/js/src/bitget.js +16 -12
  71. package/js/src/bitmart.js +7 -2
  72. package/js/src/bitmex.js +8 -5
  73. package/js/src/bybit.d.ts +1 -1
  74. package/js/src/bybit.js +7 -2
  75. package/js/src/coinbase.d.ts +1 -0
  76. package/js/src/coinbase.js +11 -1
  77. package/js/src/coincatch.d.ts +1 -2
  78. package/js/src/coincatch.js +86 -2
  79. package/js/src/coincheck.js +52 -0
  80. package/js/src/coinlist.js +77 -0
  81. package/js/src/coinmate.js +63 -0
  82. package/js/src/coinmetro.js +68 -0
  83. package/js/src/coinone.js +56 -0
  84. package/js/src/coinsph.d.ts +2 -1
  85. package/js/src/coinsph.js +85 -10
  86. package/js/src/coinspot.js +47 -0
  87. package/js/src/currencycom.js +72 -0
  88. package/js/src/defx.js +93 -6
  89. package/js/src/delta.js +83 -1
  90. package/js/src/deribit.js +82 -0
  91. package/js/src/digifinex.d.ts +1 -0
  92. package/js/src/digifinex.js +131 -11
  93. package/js/src/ellipx.d.ts +1 -0
  94. package/js/src/ellipx.js +61 -0
  95. package/js/src/exmo.js +58 -0
  96. package/js/src/gate.d.ts +1 -0
  97. package/js/src/gate.js +10 -1
  98. package/js/src/hitbtc.js +99 -0
  99. package/js/src/hollaex.js +73 -0
  100. package/js/src/htx.d.ts +1 -0
  101. package/js/src/htx.js +10 -2
  102. package/js/src/huobijp.js +73 -0
  103. package/js/src/hyperliquid.d.ts +1 -0
  104. package/js/src/hyperliquid.js +28 -2
  105. package/js/src/idex.js +71 -0
  106. package/js/src/independentreserve.js +124 -0
  107. package/js/src/indodax.js +61 -0
  108. package/js/src/kraken.js +1 -1
  109. package/js/src/krakenfutures.js +4 -4
  110. package/js/src/kuna.js +60 -1
  111. package/js/src/latoken.js +64 -0
  112. package/js/src/lbank.js +70 -0
  113. package/js/src/luno.js +73 -0
  114. package/js/src/lykke.js +64 -0
  115. package/js/src/mercado.js +65 -0
  116. package/js/src/mexc.js +1 -1
  117. package/js/src/myokx.js +10 -0
  118. package/js/src/ndax.js +71 -0
  119. package/js/src/novadax.js +74 -0
  120. package/js/src/oceanex.js +69 -0
  121. package/js/src/okcoin.js +79 -2
  122. package/js/src/okx.d.ts +1 -0
  123. package/js/src/okx.js +9 -1
  124. package/js/src/onetrading.js +66 -0
  125. package/js/src/oxfun.js +66 -0
  126. package/js/src/p2b.js +63 -1
  127. package/js/src/paradex.js +73 -2
  128. package/js/src/phemex.js +103 -0
  129. package/js/src/poloniex.js +61 -0
  130. package/js/src/poloniexfutures.js +74 -0
  131. package/js/src/pro/bitmart.d.ts +1 -0
  132. package/js/src/pro/bitmart.js +6 -0
  133. package/js/src/upbit.js +61 -0
  134. package/js/src/woo.js +6 -1
  135. package/package.json +2 -2
@@ -271,6 +271,67 @@ class poloniex extends poloniex$1 {
271
271
  'futures': 'future',
272
272
  },
273
273
  },
274
+ 'features': {
275
+ 'default': {
276
+ 'sandbox': true,
277
+ 'createOrder': {
278
+ 'marginMode': true,
279
+ 'triggerPrice': true,
280
+ 'triggerPriceType': undefined,
281
+ 'triggerDirection': false,
282
+ 'stopLossPrice': false,
283
+ 'takeProfitPrice': false,
284
+ 'attachedStopLossTakeProfit': undefined,
285
+ 'timeInForce': {
286
+ 'IOC': true,
287
+ 'FOK': true,
288
+ 'PO': false,
289
+ 'GTD': false,
290
+ },
291
+ 'hedged': false,
292
+ 'leverage': false,
293
+ 'marketBuyByCost': true,
294
+ 'marketBuyRequiresPrice': false,
295
+ 'selfTradePrevention': true,
296
+ 'trailing': false,
297
+ 'iceberg': false,
298
+ },
299
+ 'createOrders': undefined,
300
+ 'fetchMyTrades': {
301
+ 'marginMode': false,
302
+ 'limit': 1000,
303
+ 'daysBack': 100000,
304
+ 'untilDays': 100000,
305
+ },
306
+ 'fetchOrder': {
307
+ 'marginMode': false,
308
+ 'trigger': false,
309
+ 'trailing': false,
310
+ },
311
+ 'fetchOpenOrders': {
312
+ 'marginMode': false,
313
+ 'limit': 2000,
314
+ 'trigger': false,
315
+ 'trailing': false,
316
+ },
317
+ 'fetchOrders': undefined,
318
+ 'fetchClosedOrders': undefined,
319
+ 'fetchOHLCV': {
320
+ 'limit': 500,
321
+ },
322
+ },
323
+ 'spot': {
324
+ 'extends': 'default',
325
+ },
326
+ 'swap': {
327
+ 'linear': undefined,
328
+ 'inverse': undefined,
329
+ },
330
+ 'future': {
331
+ 'linear': undefined,
332
+ 'inverse': undefined,
333
+ },
334
+ },
274
335
  'precisionMode': number.TICK_SIZE,
275
336
  'exceptions': {
276
337
  'exact': {
@@ -178,6 +178,80 @@ class poloniexfutures extends poloniexfutures$1 {
178
178
  },
179
179
  },
180
180
  },
181
+ 'features': {
182
+ 'default': {
183
+ 'sandbox': false,
184
+ 'createOrder': {
185
+ 'marginMode': false,
186
+ 'triggerPrice': true,
187
+ // todo implementation
188
+ 'triggerPriceType': {
189
+ 'last': true,
190
+ 'mark': true,
191
+ 'index': true,
192
+ },
193
+ 'triggerDirection': true,
194
+ 'stopLossPrice': false,
195
+ 'takeProfitPrice': false,
196
+ 'attachedStopLossTakeProfit': undefined,
197
+ 'timeInForce': {
198
+ 'IOC': true,
199
+ 'FOK': false,
200
+ 'PO': true,
201
+ 'GTD': false,
202
+ },
203
+ 'hedged': false,
204
+ 'leverage': true,
205
+ 'marketBuyByCost': true,
206
+ 'marketBuyRequiresPrice': false,
207
+ 'selfTradePrevention': false,
208
+ 'trailing': false,
209
+ 'iceberg': true, // deprecated?
210
+ },
211
+ 'createOrders': undefined,
212
+ 'fetchMyTrades': {
213
+ 'marginMode': false,
214
+ 'limit': undefined,
215
+ 'daysBack': 100000,
216
+ 'untilDays': 7,
217
+ },
218
+ 'fetchOrder': {
219
+ 'marginMode': false,
220
+ 'trigger': false,
221
+ 'trailing': false,
222
+ },
223
+ 'fetchOpenOrders': {
224
+ 'marginMode': true,
225
+ 'limit': undefined,
226
+ 'trigger': false,
227
+ 'trailing': false,
228
+ },
229
+ 'fetchOrders': undefined,
230
+ 'fetchClosedOrders': {
231
+ 'marginMode': false,
232
+ 'limit': 100,
233
+ 'daysBack': 100000,
234
+ 'daysBackCanceled': 1,
235
+ 'untilDays': 100000,
236
+ 'trigger': false,
237
+ 'trailing': false,
238
+ },
239
+ 'fetchOHLCV': {
240
+ 'limit': 200, // todo implement
241
+ },
242
+ },
243
+ 'spot': undefined,
244
+ 'swap': {
245
+ 'linear': {
246
+ 'extends': 'default',
247
+ },
248
+ 'inverse': undefined,
249
+ },
250
+ 'future': {
251
+ 'linear': undefined,
252
+ 'inverse': undefined,
253
+ },
254
+ },
181
255
  'exceptions': {
182
256
  'exact': {
183
257
  '400': errors.BadRequest,
@@ -101,6 +101,11 @@ class bitmart extends bitmart$1 {
101
101
  }
102
102
  else {
103
103
  messageHash = 'futures/' + channel + ':' + market['id'];
104
+ const speed = this.safeString(params, 'speed');
105
+ if (speed !== undefined) {
106
+ params = this.omit(params, 'speed');
107
+ messageHash += ':' + speed;
108
+ }
104
109
  request = {
105
110
  'action': 'subscribe',
106
111
  'args': [messageHash],
@@ -1208,6 +1213,7 @@ class bitmart extends bitmart$1 {
1208
1213
  * @param {string} symbol unified symbol of the market to fetch the order book for
1209
1214
  * @param {int} [limit] the maximum amount of order book entries to return
1210
1215
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1216
+ * @param {string} [params.speed] *futures only* '100ms' or '200ms'
1211
1217
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1212
1218
  */
1213
1219
  async watchOrderBook(symbol, limit = undefined, params = {}) {
@@ -164,6 +164,67 @@ class upbit extends upbit$1 {
164
164
  'deposit': {},
165
165
  },
166
166
  },
167
+ 'features': {
168
+ 'spot': {
169
+ 'sandbox': false,
170
+ 'createOrder': {
171
+ 'marginMode': false,
172
+ 'triggerPrice': false,
173
+ 'triggerPriceType': undefined,
174
+ 'triggerDirection': false,
175
+ 'stopLossPrice': false,
176
+ 'takeProfitPrice': false,
177
+ 'attachedStopLossTakeProfit': undefined,
178
+ 'timeInForce': {
179
+ 'IOC': true,
180
+ 'FOK': true,
181
+ 'PO': false,
182
+ 'GTD': false,
183
+ },
184
+ 'hedged': false,
185
+ 'leverage': false,
186
+ 'marketBuyByCost': false,
187
+ 'marketBuyRequiresPrice': false,
188
+ 'selfTradePrevention': false,
189
+ 'trailing': false,
190
+ 'iceberg': false,
191
+ },
192
+ 'createOrders': undefined,
193
+ 'fetchMyTrades': undefined,
194
+ 'fetchOrder': {
195
+ 'marginMode': false,
196
+ 'trigger': false,
197
+ 'trailing': false,
198
+ },
199
+ 'fetchOpenOrders': {
200
+ 'marginMode': true,
201
+ 'limit': 100,
202
+ 'trigger': false,
203
+ 'trailing': false,
204
+ },
205
+ 'fetchOrders': undefined,
206
+ 'fetchClosedOrders': {
207
+ 'marginMode': false,
208
+ 'limit': 1000,
209
+ 'daysBack': 100000,
210
+ 'daysBackCanceled': 1,
211
+ 'untilDays': 7,
212
+ 'trigger': false,
213
+ 'trailing': false,
214
+ },
215
+ 'fetchOHLCV': {
216
+ 'limit': 200,
217
+ },
218
+ },
219
+ 'swap': {
220
+ 'linear': undefined,
221
+ 'inverse': undefined,
222
+ },
223
+ 'future': {
224
+ 'linear': undefined,
225
+ 'inverse': undefined,
226
+ },
227
+ },
167
228
  'precisionMode': number.TICK_SIZE,
168
229
  'exceptions': {
169
230
  'exact': {
@@ -285,6 +285,8 @@ class woo extends woo$1 {
285
285
  },
286
286
  },
287
287
  'options': {
288
+ 'timeDifference': 0,
289
+ 'adjustForTimeDifference': false,
288
290
  'sandboxMode': false,
289
291
  'createMarketBuyOrderRequiresPrice': true,
290
292
  // these network aliases require manual mapping here
@@ -500,6 +502,9 @@ class woo extends woo$1 {
500
502
  * @returns {object[]} an array of objects representing market data
501
503
  */
502
504
  async fetchMarkets(params = {}) {
505
+ if (this.options['adjustForTimeDifference']) {
506
+ await this.loadTimeDifference();
507
+ }
503
508
  const response = await this.v1PublicGetInfo(params);
504
509
  //
505
510
  // {
@@ -2640,7 +2645,7 @@ class woo extends woo$1 {
2640
2645
  };
2641
2646
  }
2642
2647
  nonce() {
2643
- return this.milliseconds();
2648
+ return this.milliseconds() - this.options['timeDifference'];
2644
2649
  }
2645
2650
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2646
2651
  const version = section[0];
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OpenInterests } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.46";
7
+ declare const version = "4.4.48";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.47';
41
+ const version = '4.4.49';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -15,6 +15,9 @@ interface Exchange {
15
15
  publicGetGetFxRates(params?: {}): Promise<implicitReturnType>;
16
16
  publicGetGetOrderMinimumVolumes(params?: {}): Promise<implicitReturnType>;
17
17
  publicGetGetCryptoWithdrawalFees(params?: {}): Promise<implicitReturnType>;
18
+ publicGetGetCryptoWithdrawalFees2(params?: {}): Promise<implicitReturnType>;
19
+ publicGetGetNetworks(params?: {}): Promise<implicitReturnType>;
20
+ publicGetGetPrimaryCurrencyConfig2(params?: {}): Promise<implicitReturnType>;
18
21
  privatePostGetOpenOrders(params?: {}): Promise<implicitReturnType>;
19
22
  privatePostGetClosedOrders(params?: {}): Promise<implicitReturnType>;
20
23
  privatePostGetClosedFilledOrders(params?: {}): Promise<implicitReturnType>;
@@ -23,7 +26,9 @@ interface Exchange {
23
26
  privatePostGetTransactions(params?: {}): Promise<implicitReturnType>;
24
27
  privatePostGetFiatBankAccounts(params?: {}): Promise<implicitReturnType>;
25
28
  privatePostGetDigitalCurrencyDepositAddress(params?: {}): Promise<implicitReturnType>;
29
+ privatePostGetDigitalCurrencyDepositAddress2(params?: {}): Promise<implicitReturnType>;
26
30
  privatePostGetDigitalCurrencyDepositAddresses(params?: {}): Promise<implicitReturnType>;
31
+ privatePostGetDigitalCurrencyDepositAddresses2(params?: {}): Promise<implicitReturnType>;
27
32
  privatePostGetTrades(params?: {}): Promise<implicitReturnType>;
28
33
  privatePostGetBrokerageFees(params?: {}): Promise<implicitReturnType>;
29
34
  privatePostGetDigitalCurrencyWithdrawal(params?: {}): Promise<implicitReturnType>;
@@ -34,6 +39,7 @@ interface Exchange {
34
39
  privatePostRequestFiatWithdrawal(params?: {}): Promise<implicitReturnType>;
35
40
  privatePostWithdrawFiatCurrency(params?: {}): Promise<implicitReturnType>;
36
41
  privatePostWithdrawDigitalCurrency(params?: {}): Promise<implicitReturnType>;
42
+ privatePostWithdrawCrypto(params?: {}): Promise<implicitReturnType>;
37
43
  }
38
44
  declare abstract class Exchange extends _Exchange {
39
45
  }
package/js/src/ace.js CHANGED
@@ -478,7 +478,7 @@ export default class ace extends Exchange {
478
478
  // }
479
479
  //
480
480
  const orderBook = this.safeDict(response, 'attachment');
481
- return this.parseOrderBook(orderBook, market['symbol'], undefined, 'bids', 'asks');
481
+ return this.parseOrderBook(orderBook, market['symbol'], undefined, 'bids', 'asks', 1, 0);
482
482
  }
483
483
  parseOHLCV(ohlcv, market = undefined) {
484
484
  //
@@ -872,6 +872,13 @@ export default class binance extends Exchange {
872
872
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
873
873
  */
874
874
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
875
+ parseFundingRateHistory(contract: any, market?: Market): {
876
+ info: any;
877
+ symbol: string;
878
+ fundingRate: number;
879
+ timestamp: number;
880
+ datetime: string;
881
+ };
875
882
  /**
876
883
  * @method
877
884
  * @name binance#fetchFundingRates
package/js/src/binance.js CHANGED
@@ -9873,20 +9873,24 @@ export default class binance extends Exchange {
9873
9873
  // "fundingTime": "1621267200000",
9874
9874
  // }
9875
9875
  //
9876
- const rates = [];
9877
- for (let i = 0; i < response.length; i++) {
9878
- const entry = response[i];
9879
- const timestamp = this.safeInteger(entry, 'fundingTime');
9880
- rates.push({
9881
- 'info': entry,
9882
- 'symbol': this.safeSymbol(this.safeString(entry, 'symbol'), undefined, undefined, 'swap'),
9883
- 'fundingRate': this.safeNumber(entry, 'fundingRate'),
9884
- 'timestamp': timestamp,
9885
- 'datetime': this.iso8601(timestamp),
9886
- });
9887
- }
9888
- const sorted = this.sortBy(rates, 'timestamp');
9889
- return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
9876
+ return this.parseFundingRateHistories(response, market, since, limit);
9877
+ }
9878
+ parseFundingRateHistory(contract, market = undefined) {
9879
+ //
9880
+ // {
9881
+ // "symbol": "BTCUSDT",
9882
+ // "fundingRate": "0.00063521",
9883
+ // "fundingTime": "1621267200000",
9884
+ // }
9885
+ //
9886
+ const timestamp = this.safeInteger(contract, 'fundingTime');
9887
+ return {
9888
+ 'info': contract,
9889
+ 'symbol': this.safeSymbol(this.safeString(contract, 'symbol'), undefined, undefined, 'swap'),
9890
+ 'fundingRate': this.safeNumber(contract, 'fundingRate'),
9891
+ 'timestamp': timestamp,
9892
+ 'datetime': this.iso8601(timestamp),
9893
+ };
9890
9894
  }
9891
9895
  /**
9892
9896
  * @method
package/js/src/bingx.d.ts CHANGED
@@ -122,6 +122,13 @@ export default class bingx extends Exchange {
122
122
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
123
123
  */
124
124
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
125
+ parseFundingRateHistory(contract: any, market?: Market): {
126
+ info: any;
127
+ symbol: string;
128
+ fundingRate: number;
129
+ timestamp: number;
130
+ datetime: string;
131
+ };
125
132
  /**
126
133
  * @method
127
134
  * @name bingx#fetchOpenInterest
@@ -753,6 +760,7 @@ export default class bingx extends Exchange {
753
760
  */
754
761
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
755
762
  parseTradingFee(fee: Dict, market?: Market): TradingFeeInterface;
763
+ customEncode(params: any): any;
756
764
  sign(path: any, section?: string, method?: string, params?: {}, headers?: any, body?: any): {
757
765
  url: string;
758
766
  method: string;
package/js/src/bingx.js CHANGED
@@ -824,8 +824,8 @@ export default class bingx extends Exchange {
824
824
  // "symbols": [
825
825
  // {
826
826
  // "symbol": "GEAR-USDT",
827
- // "minQty": 735,
828
- // "maxQty": 2941177,
827
+ // "minQty": 735, // deprecated
828
+ // "maxQty": 2941177, // deprecated
829
829
  // "minNotional": 5,
830
830
  // "maxNotional": 20000,
831
831
  // "status": 1,
@@ -949,6 +949,10 @@ export default class bingx extends Exchange {
949
949
  }
950
950
  const isInverse = (spot) ? undefined : checkIsInverse;
951
951
  const isLinear = (spot) ? undefined : checkIsLinear;
952
+ let minAmount = undefined;
953
+ if (!spot) {
954
+ minAmount = this.safeNumber2(market, 'minQty', 'tradeMinQuantity');
955
+ }
952
956
  let timeOnline = this.safeInteger(market, 'timeOnline');
953
957
  if (timeOnline === 0) {
954
958
  timeOnline = undefined;
@@ -990,8 +994,8 @@ export default class bingx extends Exchange {
990
994
  'max': undefined,
991
995
  },
992
996
  'amount': {
993
- 'min': this.safeNumber2(market, 'minQty', 'tradeMinQuantity'),
994
- 'max': this.safeNumber(market, 'maxQty'),
997
+ 'min': minAmount,
998
+ 'max': undefined,
995
999
  },
996
1000
  'price': {
997
1001
  'min': minTickSize,
@@ -1659,22 +1663,24 @@ export default class bingx extends Exchange {
1659
1663
  // }
1660
1664
  //
1661
1665
  const data = this.safeList(response, 'data', []);
1662
- const rates = [];
1663
- for (let i = 0; i < data.length; i++) {
1664
- const entry = data[i];
1665
- const marketId = this.safeString(entry, 'symbol');
1666
- const symbolInner = this.safeSymbol(marketId, market, '-', 'swap');
1667
- const timestamp = this.safeInteger(entry, 'fundingTime');
1668
- rates.push({
1669
- 'info': entry,
1670
- 'symbol': symbolInner,
1671
- 'fundingRate': this.safeNumber(entry, 'fundingRate'),
1672
- 'timestamp': timestamp,
1673
- 'datetime': this.iso8601(timestamp),
1674
- });
1675
- }
1676
- const sorted = this.sortBy(rates, 'timestamp');
1677
- return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
1666
+ return this.parseFundingRateHistories(data, market, since, limit);
1667
+ }
1668
+ parseFundingRateHistory(contract, market = undefined) {
1669
+ //
1670
+ // {
1671
+ // "symbol": "BTC-USDT",
1672
+ // "fundingRate": "0.0001",
1673
+ // "fundingTime": 1585684800000
1674
+ // }
1675
+ //
1676
+ const timestamp = this.safeInteger(contract, 'fundingTime');
1677
+ return {
1678
+ 'info': contract,
1679
+ 'symbol': this.safeSymbol(this.safeString(contract, 'symbol'), market, '-', 'swap'),
1680
+ 'fundingRate': this.safeNumber(contract, 'fundingRate'),
1681
+ 'timestamp': timestamp,
1682
+ 'datetime': this.iso8601(timestamp),
1683
+ };
1678
1684
  }
1679
1685
  /**
1680
1686
  * @method
@@ -2346,12 +2352,14 @@ export default class bingx extends Exchange {
2346
2352
  else {
2347
2353
  const linearSwapData = this.safeDict(response, 'data', {});
2348
2354
  const linearSwapBalance = this.safeDict(linearSwapData, 'balance');
2349
- const currencyId = this.safeString(linearSwapBalance, 'asset');
2350
- const code = this.safeCurrencyCode(currencyId);
2351
- const account = this.account();
2352
- account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
2353
- account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
2354
- result[code] = account;
2355
+ if (linearSwapBalance) {
2356
+ const currencyId = this.safeString(linearSwapBalance, 'asset');
2357
+ const code = this.safeCurrencyCode(currencyId);
2358
+ const account = this.account();
2359
+ account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
2360
+ account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
2361
+ result[code] = account;
2362
+ }
2355
2363
  }
2356
2364
  return this.safeBalance(result);
2357
2365
  }
@@ -6455,6 +6463,48 @@ export default class bingx extends Exchange {
6455
6463
  'tierBased': false,
6456
6464
  };
6457
6465
  }
6466
+ customEncode(params) {
6467
+ const sortedParams = this.keysort(params);
6468
+ const keys = Object.keys(sortedParams);
6469
+ let adjustedValue = undefined;
6470
+ let result = undefined;
6471
+ for (let i = 0; i < keys.length; i++) {
6472
+ const key = keys[i];
6473
+ let value = sortedParams[key];
6474
+ if (Array.isArray(value)) {
6475
+ let arrStr = undefined;
6476
+ for (let j = 0; j < value.length; j++) {
6477
+ const arrayElement = value[j];
6478
+ const isString = (typeof arrayElement === 'string');
6479
+ if (isString) {
6480
+ if (j > 0) {
6481
+ arrStr += ',' + '"' + arrayElement.toString() + '"';
6482
+ }
6483
+ else {
6484
+ arrStr = '"' + arrayElement.toString() + '"';
6485
+ }
6486
+ }
6487
+ else {
6488
+ if (j > 0) {
6489
+ arrStr += ',' + arrayElement.toString();
6490
+ }
6491
+ else {
6492
+ arrStr = arrayElement.toString();
6493
+ }
6494
+ }
6495
+ }
6496
+ adjustedValue = '[' + arrStr + ']';
6497
+ value = adjustedValue;
6498
+ }
6499
+ if (i === 0) {
6500
+ result = key + '=' + value;
6501
+ }
6502
+ else {
6503
+ result += '&' + key + '=' + value;
6504
+ }
6505
+ }
6506
+ return result;
6507
+ }
6458
6508
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
6459
6509
  let type = section[0];
6460
6510
  let version = section[1];
@@ -6490,16 +6540,24 @@ export default class bingx extends Exchange {
6490
6540
  else if (access === 'private') {
6491
6541
  this.checkRequiredCredentials();
6492
6542
  const isJsonContentType = (((type === 'subAccount') || (type === 'account/transfer')) && (method === 'POST'));
6493
- const parsedParams = this.parseParams(params);
6494
- const signature = this.hmac(this.encode(this.rawencode(parsedParams)), this.encode(this.secret), sha256);
6543
+ let parsedParams = undefined;
6544
+ let encodeRequest = undefined;
6545
+ if (isJsonContentType) {
6546
+ encodeRequest = this.customEncode(params);
6547
+ }
6548
+ else {
6549
+ parsedParams = this.parseParams(params);
6550
+ encodeRequest = this.rawencode(parsedParams);
6551
+ }
6552
+ const signature = this.hmac(this.encode(encodeRequest), this.encode(this.secret), sha256);
6495
6553
  headers = {
6496
6554
  'X-BX-APIKEY': this.apiKey,
6497
6555
  'X-SOURCE-KEY': this.safeString(this.options, 'broker', 'CCXT'),
6498
6556
  };
6499
6557
  if (isJsonContentType) {
6500
6558
  headers['Content-Type'] = 'application/json';
6501
- parsedParams['signature'] = signature;
6502
- body = this.json(parsedParams);
6559
+ params['signature'] = signature;
6560
+ body = this.json(params);
6503
6561
  }
6504
6562
  else {
6505
6563
  const query = this.urlencode(parsedParams);
@@ -226,6 +226,7 @@ export default class bitget extends Exchange {
226
226
  * @param {int} [limit] the maximum amount of candles to fetch
227
227
  * @param {object} [params] extra parameters specific to the exchange API endpoint
228
228
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
229
+ * @param {boolean} [params.useHistoryEndpoint] whether to force to use historical endpoint (it has max limit of 200)
229
230
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
230
231
  * @param {string} [params.price] *swap only* "mark" (to fetch mark price candles) or "index" (to fetch index price candles)
231
232
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume