ccxt 4.1.8 → 4.1.9

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1240 -189
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +3 -1
  5. package/dist/cjs/src/base/Exchange.js +58 -2
  6. package/dist/cjs/src/bingx.js +100 -39
  7. package/dist/cjs/src/bitget.js +26 -2
  8. package/dist/cjs/src/gate.js +9 -1
  9. package/dist/cjs/src/kucoinfutures.js +2 -2
  10. package/dist/cjs/src/pro/bingx.js +891 -0
  11. package/js/ccxt.d.ts +6 -3
  12. package/js/ccxt.js +3 -1
  13. package/js/src/abstract/bingx.d.ts +1 -0
  14. package/js/src/base/Exchange.d.ts +6 -3
  15. package/js/src/base/Exchange.js +58 -2
  16. package/js/src/base/types.d.ts +7 -0
  17. package/js/src/binance.d.ts +17 -17
  18. package/js/src/bingx.d.ts +4 -3
  19. package/js/src/bingx.js +100 -39
  20. package/js/src/bitfinex2.d.ts +13 -13
  21. package/js/src/bitget.d.ts +15 -15
  22. package/js/src/bitget.js +26 -2
  23. package/js/src/bitmex.d.ts +15 -15
  24. package/js/src/bybit.d.ts +23 -23
  25. package/js/src/coinbase.d.ts +16 -16
  26. package/js/src/coinbasepro.d.ts +12 -12
  27. package/js/src/coinex.d.ts +2 -2
  28. package/js/src/cryptocom.d.ts +12 -12
  29. package/js/src/deribit.d.ts +2 -2
  30. package/js/src/digifinex.d.ts +2 -2
  31. package/js/src/gate.d.ts +10 -10
  32. package/js/src/gate.js +9 -1
  33. package/js/src/huobi.d.ts +16 -16
  34. package/js/src/kraken.d.ts +2 -2
  35. package/js/src/krakenfutures.d.ts +6 -6
  36. package/js/src/kucoin.d.ts +13 -13
  37. package/js/src/kucoinfutures.d.ts +10 -10
  38. package/js/src/kucoinfutures.js +2 -2
  39. package/js/src/mexc.d.ts +3 -3
  40. package/js/src/okx.d.ts +13 -13
  41. package/js/src/phemex.d.ts +2 -2
  42. package/js/src/poloniex.d.ts +5 -5
  43. package/js/src/pro/bingx.d.ts +24 -0
  44. package/js/src/pro/bingx.js +892 -0
  45. package/js/src/woo.d.ts +2 -2
  46. package/package.json +1 -1
  47. package/skip-tests.json +3 -0
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
- import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } from './src/base/types.js';
5
+ import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.7";
7
+ declare const version = "4.1.8";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -117,6 +117,7 @@ import binancePro from './src/pro/binance.js';
117
117
  import binancecoinmPro from './src/pro/binancecoinm.js';
118
118
  import binanceusPro from './src/pro/binanceus.js';
119
119
  import binanceusdmPro from './src/pro/binanceusdm.js';
120
+ import bingxPro from './src/pro/bingx.js';
120
121
  import bitcoincomPro from './src/pro/bitcoincom.js';
121
122
  import bitfinexPro from './src/pro/bitfinex.js';
122
123
  import bitfinex2Pro from './src/pro/bitfinex2.js';
@@ -284,6 +285,7 @@ declare const pro: {
284
285
  binancecoinm: typeof binancecoinmPro;
285
286
  binanceus: typeof binanceusPro;
286
287
  binanceusdm: typeof binanceusdmPro;
288
+ bingx: typeof bingxPro;
287
289
  bitcoincom: typeof bitcoincomPro;
288
290
  bitfinex: typeof bitfinexPro;
289
291
  bitfinex2: typeof bitfinex2Pro;
@@ -350,6 +352,7 @@ declare const ccxt: {
350
352
  binancecoinm: typeof binancecoinmPro;
351
353
  binanceus: typeof binanceusPro;
352
354
  binanceusdm: typeof binanceusdmPro;
355
+ bingx: typeof bingxPro;
353
356
  bitcoincom: typeof bitcoincomPro;
354
357
  bitfinex: typeof bitfinexPro;
355
358
  bitfinex2: typeof bitfinex2Pro;
@@ -510,5 +513,5 @@ declare const ccxt: {
510
513
  zaif: typeof zaif;
511
514
  zonda: typeof zonda;
512
515
  } & typeof functions & typeof errors;
513
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
516
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
514
517
  export default ccxt;
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.8';
41
+ const version = '4.1.9';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -154,6 +154,7 @@ import binancePro from './src/pro/binance.js';
154
154
  import binancecoinmPro from './src/pro/binancecoinm.js';
155
155
  import binanceusPro from './src/pro/binanceus.js';
156
156
  import binanceusdmPro from './src/pro/binanceusdm.js';
157
+ import bingxPro from './src/pro/bingx.js';
157
158
  import bitcoincomPro from './src/pro/bitcoincom.js';
158
159
  import bitfinexPro from './src/pro/bitfinex.js';
159
160
  import bitfinex2Pro from './src/pro/bitfinex2.js';
@@ -321,6 +322,7 @@ const pro = {
321
322
  'binancecoinm': binancecoinmPro,
322
323
  'binanceus': binanceusPro,
323
324
  'binanceusdm': binanceusdmPro,
325
+ 'bingx': bingxPro,
324
326
  'bitcoincom': bitcoincomPro,
325
327
  'bitfinex': bitfinexPro,
326
328
  'bitfinex2': bitfinex2Pro,
@@ -76,6 +76,7 @@ interface Exchange {
76
76
  subAccountV1PrivatePostUpdateStatus(params?: {}): Promise<implicitReturnType>;
77
77
  accountV1PrivateGetUid(params?: {}): Promise<implicitReturnType>;
78
78
  accountV1PrivatePostInnerTransferAuthorizeSubAccount(params?: {}): Promise<implicitReturnType>;
79
+ userAuthPrivatePostUserDataStream(params?: {}): Promise<implicitReturnType>;
79
80
  copyTradingV1PrivateGetSwapTraceCurrentTrack(params?: {}): Promise<implicitReturnType>;
80
81
  copyTradingV1PrivatePostSwapTraceCloseTrackOrder(params?: {}): Promise<implicitReturnType>;
81
82
  copyTradingV1PrivatePostSwapTraceSetTPSL(params?: {}): Promise<implicitReturnType>;
@@ -4,7 +4,7 @@ ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotA
4
4
  import WsClient from './ws/WsClient.js';
5
5
  import { Future } from './ws/Future.js';
6
6
  import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
7
- import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position } from './types.js';
7
+ import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory } from './types.js';
8
8
  export { Market, Trade, Fee, Position, Ticker } from './types.js';
9
9
  /**
10
10
  * @class Exchange
@@ -557,7 +557,7 @@ export default class Exchange {
557
557
  parseMarketLeverageTiers(info: any, market?: any): void;
558
558
  fetchLeverageTiers(symbols?: string[], params?: {}): Promise<any>;
559
559
  parsePosition(position: any, market?: any): void;
560
- parseFundingRateHistory(info: any, market?: any): void;
560
+ parseFundingRateHistory(info: any, market?: any): FundingRateHistory;
561
561
  parseBorrowInterest(info: any, market?: any): void;
562
562
  parseWsTrade(trade: any, market?: any): Trade;
563
563
  parseWsOrder(order: any, market?: any): Order;
@@ -731,6 +731,7 @@ export default class Exchange {
731
731
  fetchDeposits(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
732
732
  fetchWithdrawals(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
733
733
  fetchOpenInterest(symbol: string, params?: {}): Promise<any>;
734
+ fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
734
735
  parseLastPrice(price: any, market?: any): any;
735
736
  fetchDepositAddress(code: string, params?: {}): Promise<any>;
736
737
  account(): Balance;
@@ -771,7 +772,7 @@ export default class Exchange {
771
772
  parseTickers(tickers: any, symbols?: string[], params?: {}): Dictionary<Ticker>;
772
773
  parseDepositAddresses(addresses: any, codes?: string[], indexed?: boolean, params?: {}): {};
773
774
  parseBorrowInterests(response: any, market?: any): any[];
774
- parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): any;
775
+ parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): FundingRateHistory[];
775
776
  safeSymbol(marketId: any, market?: any, delimiter?: any, marketType?: any): any;
776
777
  parseFundingRate(contract: string, market?: any): void;
777
778
  parseFundingRates(response: any, market?: any): {};
@@ -810,6 +811,8 @@ export default class Exchange {
810
811
  safeDeterministicCall(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}): Promise<any>;
811
812
  fetchPaginatedCallDeterministic(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}, maxEntriesPerRequest?: any): Promise<any>;
812
813
  fetchPaginatedCallCursor(method: string, symbol?: string, since?: any, limit?: any, params?: {}, cursorReceived?: any, cursorSent?: any, cursorIncrement?: any, maxEntriesPerRequest?: any): Promise<any>;
814
+ fetchPaginatedCallIncremental(method: string, symbol?: string, since?: any, limit?: any, params?: {}, pageKey?: any, maxEntriesPerRequest?: any): Promise<any>;
815
+ sortCursorPaginatedResult(result: any): any;
813
816
  removeRepeatedElementsFromArray(input: any): any;
814
817
  handleUntilOption(key: any, request: any, params: any, multiplier?: number): any[];
815
818
  }
@@ -3285,6 +3285,9 @@ export default class Exchange {
3285
3285
  async fetchOpenInterest(symbol, params = {}) {
3286
3286
  throw new NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
3287
3287
  }
3288
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3289
+ throw new NotSupported(this.id + ' fetchFundingRateHistory() is not supported yet');
3290
+ }
3288
3291
  parseLastPrice(price, market = undefined) {
3289
3292
  throw new NotSupported(this.id + ' parseLastPrice() is not supported yet');
3290
3293
  }
@@ -4175,7 +4178,9 @@ export default class Exchange {
4175
4178
  }
4176
4179
  }
4177
4180
  }
4178
- return this.removeRepeatedElementsFromArray(result);
4181
+ const uniqueResults = this.removeRepeatedElementsFromArray(result);
4182
+ const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
4183
+ return this.filterBySinceLimit(uniqueResults, since, limit, key);
4179
4184
  }
4180
4185
  async safeDeterministicCall(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}) {
4181
4186
  let maxRetries = undefined;
@@ -4230,7 +4235,9 @@ export default class Exchange {
4230
4235
  for (let i = 0; i < results.length; i++) {
4231
4236
  result = this.arrayConcat(result, results[i]);
4232
4237
  }
4233
- return this.removeRepeatedElementsFromArray(result);
4238
+ const uniqueResults = this.removeRepeatedElementsFromArray(result);
4239
+ const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
4240
+ return this.filterBySinceLimit(uniqueResults, since, limit, key);
4234
4241
  }
4235
4242
  async fetchPaginatedCallCursor(method, symbol = undefined, since = undefined, limit = undefined, params = {}, cursorReceived = undefined, cursorSent = undefined, cursorIncrement = undefined, maxEntriesPerRequest = undefined) {
4236
4243
  let maxCalls = undefined;
@@ -4274,6 +4281,55 @@ export default class Exchange {
4274
4281
  }
4275
4282
  i += 1;
4276
4283
  }
4284
+ const sorted = this.sortCursorPaginatedResult(result);
4285
+ const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
4286
+ return this.filterBySinceLimit(sorted, since, limit, key);
4287
+ }
4288
+ async fetchPaginatedCallIncremental(method, symbol = undefined, since = undefined, limit = undefined, params = {}, pageKey = undefined, maxEntriesPerRequest = undefined) {
4289
+ let maxCalls = undefined;
4290
+ [maxCalls, params] = this.handleOptionAndParams(params, method, 'paginationCalls', 10);
4291
+ let maxRetries = undefined;
4292
+ [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
4293
+ [maxEntriesPerRequest, params] = this.handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest, params);
4294
+ let i = 0;
4295
+ let errors = 0;
4296
+ let result = [];
4297
+ while (i < maxCalls) {
4298
+ try {
4299
+ params[pageKey] = i + 1;
4300
+ const response = await this[method](symbol, since, maxEntriesPerRequest, params);
4301
+ errors = 0;
4302
+ const responseLength = response.length;
4303
+ if (this.verbose) {
4304
+ this.log('Incremental pagination call', i + 1, 'method', method, 'response length', responseLength);
4305
+ }
4306
+ if (responseLength === 0) {
4307
+ break;
4308
+ }
4309
+ result = this.arrayConcat(result, response);
4310
+ }
4311
+ catch (e) {
4312
+ errors += 1;
4313
+ if (errors > maxRetries) {
4314
+ throw e;
4315
+ }
4316
+ }
4317
+ i += 1;
4318
+ }
4319
+ const sorted = this.sortCursorPaginatedResult(result);
4320
+ const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
4321
+ return this.filterBySinceLimit(sorted, since, limit, key);
4322
+ }
4323
+ sortCursorPaginatedResult(result) {
4324
+ const first = this.safeValue(result, 0);
4325
+ if (first !== undefined) {
4326
+ if ('timestamp' in first) {
4327
+ return this.sortBy(result, 'timestamp');
4328
+ }
4329
+ if ('id' in first) {
4330
+ return this.sortBy(result, 'id');
4331
+ }
4332
+ }
4277
4333
  return result;
4278
4334
  }
4279
4335
  removeRepeatedElementsFromArray(input) {
@@ -201,6 +201,13 @@ export interface Position {
201
201
  takeProfitPrice?: number;
202
202
  info: any;
203
203
  }
204
+ export interface FundingRateHistory {
205
+ info: any;
206
+ symbol: string;
207
+ fundingRate: number;
208
+ timestamp?: number;
209
+ datetime?: string;
210
+ }
204
211
  /** [ timestamp, open, high, low, close, volume ] */
205
212
  export declare type OHLCV = [number, number, number, number, number, number];
206
213
  /** [ timestamp, open, high, low, close, volume, count ] */
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import { Market, Int, OrderSide, Balances, OrderType } from './base/types.js';
2
+ import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @extends Exchange
@@ -97,8 +97,8 @@ export default class binance extends Exchange {
97
97
  };
98
98
  fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
99
99
  parseOHLCV(ohlcv: any, market?: any): number[];
100
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
101
- parseTrade(trade: any, market?: any): import("./base/types.js").Trade | {
100
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
101
+ parseTrade(trade: any, market?: any): Trade | {
102
102
  id: any;
103
103
  timestamp: number;
104
104
  datetime: string;
@@ -116,25 +116,25 @@ export default class binance extends Exchange {
116
116
  };
117
117
  info: any;
118
118
  };
119
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
120
- editSpotOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
119
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
120
+ editSpotOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
121
121
  editSpotOrderRequest(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): any;
122
- editContractOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
123
- editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
122
+ editContractOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
123
+ editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
124
124
  parseOrderStatus(status: any): string;
125
- parseOrder(order: any, market?: any): import("./base/types.js").Order;
126
- createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
125
+ parseOrder(order: any, market?: any): Order;
126
+ createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
127
127
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
128
- fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
129
- fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
130
- fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
128
+ fetchOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
129
+ fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
130
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
131
131
  fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
132
132
  fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
133
- cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
133
+ cancelOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
134
134
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
135
- cancelOrders(ids: Int[], symbol?: string, params?: {}): Promise<import("./base/types.js").Order[]>;
136
- fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
137
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
135
+ cancelOrders(ids: Int[], symbol?: string, params?: {}): Promise<Order[]>;
136
+ fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
137
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
138
138
  fetchMyDustTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
139
139
  parseDustTrade(trade: any, market?: any): {
140
140
  id: any;
@@ -289,7 +289,7 @@ export default class binance extends Exchange {
289
289
  previousFundingTimestamp: any;
290
290
  previousFundingDatetime: any;
291
291
  }>;
292
- fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
292
+ fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
293
293
  fetchFundingRates(symbols?: string[], params?: {}): Promise<any>;
294
294
  parseFundingRate(contract: any, market?: any): {
295
295
  info: any;
package/js/src/bingx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bingx.js';
2
- import { Int, OrderSide } from './base/types.js';
2
+ import { Int, OrderSide, OHLCV, FundingRateHistory } from './base/types.js';
3
3
  export default class bingx extends Exchange {
4
4
  describe(): any;
5
5
  fetchTime(params?: {}): Promise<number>;
@@ -59,7 +59,7 @@ export default class bingx extends Exchange {
59
59
  info: any;
60
60
  };
61
61
  fetchMarkets(params?: {}): Promise<any>;
62
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
62
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
63
63
  parseOHLCV(ohlcv: any, market?: any): number[];
64
64
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
65
65
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
@@ -102,7 +102,7 @@ export default class bingx extends Exchange {
102
102
  previousFundingTimestamp: any;
103
103
  previousFundingDatetime: any;
104
104
  };
105
- fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
105
+ fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
106
106
  fetchOpenInterest(symbol: string, params?: {}): Promise<{
107
107
  symbol: any;
108
108
  openInterestAmount: any;
@@ -127,6 +127,7 @@ export default class bingx extends Exchange {
127
127
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
128
128
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
129
129
  createOrder(symbol: string, type: any, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
130
+ parseOrderSide(side: any): string;
130
131
  parseOrder(order: any, market?: any): import("./base/types.js").Order;
131
132
  parseOrderStatus(status: any): string;
132
133
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
package/js/src/bingx.js CHANGED
@@ -69,6 +69,7 @@ export default class bingx extends Exchange {
69
69
  'swap': 'https://open-api.{hostname}/openApi',
70
70
  'contract': 'https://open-api.{hostname}/openApi',
71
71
  'wallets': 'https://open-api.{hostname}/openApi',
72
+ 'user': 'https://open-api.{hostname}/openApi',
72
73
  'subAccount': 'https://open-api.{hostname}/openApi',
73
74
  'account': 'https://open-api.{hostname}/openApi',
74
75
  },
@@ -237,6 +238,15 @@ export default class bingx extends Exchange {
237
238
  },
238
239
  },
239
240
  },
241
+ 'user': {
242
+ 'auth': {
243
+ 'private': {
244
+ 'post': {
245
+ 'userDataStream': 1,
246
+ },
247
+ },
248
+ },
249
+ },
240
250
  'copyTrading': {
241
251
  'v1': {
242
252
  'private': {
@@ -314,6 +324,7 @@ export default class bingx extends Exchange {
314
324
  },
315
325
  'commonCurrencies': {},
316
326
  'options': {
327
+ 'defaultType': 'spot',
317
328
  'accountsByType': {
318
329
  'spot': 'FUND',
319
330
  'swap': 'PFUTURES',
@@ -833,37 +844,63 @@ export default class bingx extends Exchange {
833
844
  // filledTime: '2023-07-04T20:56:01.000+0800'
834
845
  // }
835
846
  //
836
- let time = this.safeInteger2(trade, 'time', 'filledTm');
847
+ //
848
+ // ws
849
+ //
850
+ // spot
851
+ //
852
+ // {
853
+ // E: 1690214529432,
854
+ // T: 1690214529386,
855
+ // e: 'trade',
856
+ // m: true,
857
+ // p: '29110.19',
858
+ // q: '0.1868',
859
+ // s: 'BTC-USDT',
860
+ // t: '57903921'
861
+ // }
862
+ //
863
+ // swap
864
+ //
865
+ // {
866
+ // q: '0.0421',
867
+ // p: '29023.5',
868
+ // T: 1690221401344,
869
+ // m: false,
870
+ // s: 'BTC-USDT'
871
+ // }
872
+ //
873
+ let time = this.safeIntegerN(trade, ['time', 'filledTm', 'T']);
837
874
  const datetimeId = this.safeString(trade, 'filledTm');
838
875
  if (datetimeId !== undefined) {
839
876
  time = this.parse8601(datetimeId);
840
877
  }
841
- const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
842
- let takeOrMaker = undefined;
843
- let side = undefined;
844
- if (isBuyerMaker !== undefined) {
845
- side = isBuyerMaker ? 'sell' : 'buy';
846
- takeOrMaker = 'taker';
878
+ if (time === 0) {
879
+ time = undefined;
847
880
  }
881
+ const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
882
+ const side = this.safeStringLower2(trade, 'side', 'S');
848
883
  const cost = this.safeString(trade, 'quoteQty');
849
884
  const type = (cost === undefined) ? 'spot' : 'swap';
850
- const currencyId = this.safeString(trade, 'currency');
885
+ const currencyId = this.safeString2(trade, 'currency', 'N');
851
886
  const currencyCode = this.safeCurrencyCode(currencyId);
887
+ const m = this.safeValue(trade, 'm', false);
888
+ const marketId = this.safeString(trade, 's');
852
889
  return this.safeTrade({
853
- 'id': this.safeString2(trade, 'id', 'orderId'),
890
+ 'id': this.safeStringN(trade, ['id', 't']),
854
891
  'info': trade,
855
892
  'timestamp': time,
856
893
  'datetime': this.iso8601(time),
857
- 'symbol': this.safeSymbol(undefined, market, '-', type),
858
- 'order': undefined,
859
- 'type': undefined,
860
- 'side': side,
861
- 'takerOrMaker': takeOrMaker,
862
- 'price': this.safeString(trade, 'price'),
863
- 'amount': this.safeString2(trade, 'qty', 'amount'),
894
+ 'symbol': this.safeSymbol(marketId, market, '-', type),
895
+ 'order': this.safeString2(trade, 'orderId', 'i'),
896
+ 'type': this.safeStringLower(trade, 'o'),
897
+ 'side': this.parseOrderSide(side),
898
+ 'takerOrMaker': (isBuyerMaker || m) ? 'maker' : 'taker',
899
+ 'price': this.safeString2(trade, 'price', 'p'),
900
+ 'amount': this.safeStringN(trade, ['qty', 'amount', 'q']),
864
901
  'cost': cost,
865
902
  'fee': {
866
- 'cost': this.parseNumber(Precise.stringAbs(this.safeString(trade, 'commission'))),
903
+ 'cost': this.parseNumber(Precise.stringAbs(this.safeString2(trade, 'commission', 'n'))),
867
904
  'currency': currencyCode,
868
905
  'rate': undefined,
869
906
  },
@@ -1583,15 +1620,20 @@ export default class bingx extends Exchange {
1583
1620
  request['timeInForce'] = 'POC';
1584
1621
  }
1585
1622
  const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
1586
- if (createMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
1587
- if (price === undefined) {
1588
- throw new InvalidOrder(this.id + ' createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
1623
+ if (isMarketOrder && (side === 'buy')) {
1624
+ if (createMarketBuyOrderRequiresPrice) {
1625
+ if (price === undefined) {
1626
+ throw new InvalidOrder(this.id + ' createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
1627
+ }
1628
+ else {
1629
+ const amountString = this.numberToString(amount);
1630
+ const priceString = this.numberToString(price);
1631
+ const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
1632
+ request['quoteOrderQty'] = this.priceToPrecision(symbol, cost);
1633
+ }
1589
1634
  }
1590
1635
  else {
1591
- const amountString = this.numberToString(amount);
1592
- const priceString = this.numberToString(price);
1593
- const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
1594
- request['quoteOrderQty'] = this.priceToPrecision(symbol, cost);
1636
+ request['quoteOrderQty'] = this.priceToPrecision(symbol, amount);
1595
1637
  }
1596
1638
  }
1597
1639
  else {
@@ -1707,6 +1749,15 @@ export default class bingx extends Exchange {
1707
1749
  const order = this.safeValue(data, 'order', data);
1708
1750
  return this.parseOrder(order, market);
1709
1751
  }
1752
+ parseOrderSide(side) {
1753
+ const sides = {
1754
+ 'BUY': 'buy',
1755
+ 'SELL': 'sell',
1756
+ 'SHORT': 'sell',
1757
+ 'LONG': 'buy',
1758
+ };
1759
+ return this.safeString(sides, side, side);
1760
+ }
1710
1761
  parseOrder(order, market = undefined) {
1711
1762
  //
1712
1763
  // spot
@@ -1804,39 +1855,49 @@ export default class bingx extends Exchange {
1804
1855
  // "workingType": "MARK_PRICE"
1805
1856
  // }
1806
1857
  //
1807
- const positionSide = this.safeString(order, 'positionSide');
1858
+ const positionSide = this.safeString2(order, 'positionSide', 'ps');
1808
1859
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
1809
- const marketId = this.safeString(order, 'symbol');
1860
+ const marketId = this.safeString2(order, 'symbol', 's');
1810
1861
  const symbol = this.safeSymbol(marketId, market, '-', marketType);
1811
- const timestamp = this.safeInteger2(order, 'time', 'transactTime');
1862
+ const orderId = this.safeString2(order, 'orderId', 'i');
1863
+ const side = this.safeStringLower2(order, 'side', 'S');
1864
+ const type = this.safeStringLower2(order, 'type', 'o');
1865
+ const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
1866
+ const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
1867
+ const price = this.safeString2(order, 'price', 'p');
1868
+ const average = this.safeString2(order, 'avgPrice', 'ap');
1869
+ const amount = this.safeString2(order, 'origQty', 'q');
1870
+ const filled = this.safeString2(order, 'executedQty', 'z');
1871
+ const statusId = this.safeString2(order, 'status', 'X');
1812
1872
  const fee = {
1813
- 'currency': this.safeString(order, 'feeAsset'),
1814
- 'rate': this.safeString2(order, 'fee', 'commission'),
1873
+ 'currency': this.safeString2(order, 'feeAsset', 'N'),
1874
+ 'rate': this.safeStringN(order, ['fee', 'commission', 'n']),
1815
1875
  };
1876
+ const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
1816
1877
  return this.safeOrder({
1817
1878
  'info': order,
1818
- 'id': this.safeString(order, 'orderId'),
1819
- 'clientOrderId': this.safeString(order, 'clientOrderId'),
1879
+ 'id': orderId,
1880
+ 'clientOrderId': clientOrderId,
1820
1881
  'timestamp': timestamp,
1821
1882
  'datetime': this.iso8601(timestamp),
1822
- 'lastTradeTimestamp': this.safeInteger(order, 'updateTime'),
1883
+ 'lastTradeTimestamp': lastTradeTimestamp,
1823
1884
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
1824
1885
  'symbol': symbol,
1825
- 'type': this.safeStringLower(order, 'type'),
1886
+ 'type': type,
1826
1887
  'timeInForce': undefined,
1827
1888
  'postOnly': undefined,
1828
- 'side': this.safeStringLower(order, 'side'),
1829
- 'price': this.safeString(order, 'price'),
1889
+ 'side': this.parseOrderSide(side),
1890
+ 'price': price,
1830
1891
  'stopPrice': this.safeNumber(order, 'stopPrice'),
1831
1892
  'triggerPrice': this.safeNumber(order, 'stopPrice'),
1832
1893
  'stopLossPrice': this.safeNumber(order, 'stopLoss'),
1833
1894
  'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
1834
- 'average': this.safeString(order, 'avgPrice'),
1895
+ 'average': average,
1835
1896
  'cost': undefined,
1836
- 'amount': this.safeString(order, 'origQty'),
1837
- 'filled': this.safeString(order, 'executedQty'),
1897
+ 'amount': amount,
1898
+ 'filled': filled,
1838
1899
  'remaining': undefined,
1839
- 'status': this.parseOrderStatus(this.safeString(order, 'status')),
1900
+ 'status': this.parseOrderStatus(statusId),
1840
1901
  'fee': fee,
1841
1902
  'trades': undefined,
1842
1903
  }, market);
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex2.js';
2
- import { Int, OrderSide, OrderType } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex2
5
5
  * @extends Exchange
@@ -50,23 +50,23 @@ export default class bitfinex2 extends Exchange {
50
50
  parseTicker(ticker: any, market?: any): import("./base/types.js").Ticker;
51
51
  fetchTickers(symbols?: string[], params?: {}): Promise<any>;
52
52
  fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
53
- parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
54
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
55
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: number, params?: {}): Promise<any>;
53
+ parseTrade(trade: any, market?: any): Trade;
54
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
55
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: number, params?: {}): Promise<OHLCV[]>;
56
56
  parseOHLCV(ohlcv: any, market?: any): number[];
57
57
  parseOrderStatus(status: any): any;
58
58
  parseOrderFlags(flags: any): any;
59
59
  parseTimeInForce(orderType: any): string;
60
- parseOrder(order: any, market?: any): import("./base/types.js").Order;
61
- createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
62
- cancelAllOrders(symbol?: string, params?: {}): Promise<import("./base/types.js").Order[]>;
63
- cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
60
+ parseOrder(order: any, market?: any): Order;
61
+ createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
62
+ cancelAllOrders(symbol?: string, params?: {}): Promise<Order[]>;
63
+ cancelOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
64
64
  fetchOpenOrder(id: string, symbol?: string, params?: {}): Promise<any>;
65
65
  fetchClosedOrder(id: string, symbol?: string, params?: {}): Promise<any>;
66
- fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
67
- fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
68
- fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
69
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
66
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
67
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
68
+ fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
69
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
70
70
  createDepositAddress(code: string, params?: {}): Promise<{
71
71
  currency: string;
72
72
  address: string;
@@ -141,7 +141,7 @@ export default class bitfinex2 extends Exchange {
141
141
  fetchLedger(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
142
142
  fetchFundingRate(symbol: string, params?: {}): Promise<{}>;
143
143
  fetchFundingRates(symbols?: string[], params?: {}): Promise<{}>;
144
- fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
144
+ fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
145
145
  parseFundingRate(contract: any, market?: any): {
146
146
  info: any;
147
147
  symbol: any;