ccxt 4.5.14 → 4.5.16

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 (66) hide show
  1. package/README.md +20 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +1 -0
  5. package/dist/cjs/src/backpack.js +7 -2
  6. package/dist/cjs/src/base/Exchange.js +46 -0
  7. package/dist/cjs/src/binance.js +3 -0
  8. package/dist/cjs/src/bingx.js +73 -46
  9. package/dist/cjs/src/bitget.js +19 -6
  10. package/dist/cjs/src/blofin.js +7 -6
  11. package/dist/cjs/src/bybit.js +16 -6
  12. package/dist/cjs/src/delta.js +98 -3
  13. package/dist/cjs/src/gate.js +152 -151
  14. package/dist/cjs/src/htx.js +1 -0
  15. package/dist/cjs/src/kraken.js +99 -4
  16. package/dist/cjs/src/kucoin.js +1 -0
  17. package/dist/cjs/src/mexc.js +1 -0
  18. package/dist/cjs/src/okx.js +10 -0
  19. package/dist/cjs/src/phemex.js +6 -3
  20. package/dist/cjs/src/poloniex.js +3 -0
  21. package/dist/cjs/src/pro/binance.js +1 -1
  22. package/dist/cjs/src/pro/kraken.js +1 -1
  23. package/dist/cjs/src/pro/upbit.js +25 -1
  24. package/dist/cjs/src/woo.js +41 -20
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/abstract/bingx.d.ts +17 -0
  28. package/js/src/abstract/bybit.d.ts +1 -0
  29. package/js/src/abstract/delta.d.ts +5 -1
  30. package/js/src/abstract/woo.d.ts +0 -3
  31. package/js/src/ascendex.js +1 -0
  32. package/js/src/backpack.d.ts +1 -1
  33. package/js/src/backpack.js +7 -2
  34. package/js/src/base/Exchange.d.ts +31 -0
  35. package/js/src/base/Exchange.js +47 -1
  36. package/js/src/base/types.d.ts +2 -0
  37. package/js/src/binance.js +3 -0
  38. package/js/src/bingx.d.ts +2 -2
  39. package/js/src/bingx.js +73 -46
  40. package/js/src/bitget.js +19 -6
  41. package/js/src/blofin.js +7 -6
  42. package/js/src/bybit.d.ts +1 -1
  43. package/js/src/bybit.js +16 -6
  44. package/js/src/delta.d.ts +13 -0
  45. package/js/src/delta.js +98 -3
  46. package/js/src/derive.js +1 -1
  47. package/js/src/gate.d.ts +140 -140
  48. package/js/src/gate.js +152 -151
  49. package/js/src/htx.js +1 -0
  50. package/js/src/kraken.d.ts +11 -1
  51. package/js/src/kraken.js +99 -4
  52. package/js/src/kucoin.js +1 -0
  53. package/js/src/mexc.js +1 -0
  54. package/js/src/okx.js +10 -0
  55. package/js/src/phemex.js +6 -3
  56. package/js/src/poloniex.js +3 -0
  57. package/js/src/pro/binance.js +1 -1
  58. package/js/src/pro/gate.js +1 -1
  59. package/js/src/pro/gemini.js +1 -1
  60. package/js/src/pro/kraken.d.ts +1 -1
  61. package/js/src/pro/kraken.js +1 -1
  62. package/js/src/pro/onetrading.js +1 -1
  63. package/js/src/pro/upbit.js +25 -1
  64. package/js/src/woo.d.ts +1 -1
  65. package/js/src/woo.js +41 -20
  66. package/package.json +1 -1
@@ -56,6 +56,7 @@ export default class backpack extends Exchange {
56
56
  'createTrailingPercentOrder': false,
57
57
  'createTriggerOrder': true,
58
58
  'fetchAccounts': false,
59
+ 'fetchAllGreeks': false,
59
60
  'fetchBalance': true,
60
61
  'fetchCanceledAndClosedOrders': false,
61
62
  'fetchCanceledOrders': false,
@@ -74,6 +75,7 @@ export default class backpack extends Exchange {
74
75
  'fetchFundingRate': true,
75
76
  'fetchFundingRateHistory': true,
76
77
  'fetchFundingRates': false,
78
+ 'fetchGreeks': false,
77
79
  'fetchIndexOHLCV': true,
78
80
  'fetchLedger': false,
79
81
  'fetchLeverage': false,
@@ -88,6 +90,8 @@ export default class backpack extends Exchange {
88
90
  'fetchOpenInterestHistory': true,
89
91
  'fetchOpenOrder': true,
90
92
  'fetchOpenOrders': true,
93
+ 'fetchOption': false,
94
+ 'fetchOptionChain': false,
91
95
  'fetchOrder': false,
92
96
  'fetchOrderBook': true,
93
97
  'fetchOrders': true,
@@ -108,6 +112,7 @@ export default class backpack extends Exchange {
108
112
  'fetchTradingFees': false,
109
113
  'fetchTransactions': false,
110
114
  'fetchTransfers': false,
115
+ 'fetchVolatilityHistory': false,
111
116
  'fetchWithdrawals': true,
112
117
  'reduceMargin': false,
113
118
  'sandbox': false,
@@ -1431,7 +1436,7 @@ export default class backpack extends Exchange {
1431
1436
  * @param {string} address the address to withdraw to
1432
1437
  * @param {string} tag
1433
1438
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1434
- * @param {string} [params.network] the network to withdraw on (mandatory)
1439
+ * @param {string} params.network the network to withdraw on (mandatory)
1435
1440
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1436
1441
  */
1437
1442
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -1439,7 +1444,7 @@ export default class backpack extends Exchange {
1439
1444
  const currency = this.currency(code);
1440
1445
  const request = {
1441
1446
  'symbol': currency['id'],
1442
- 'amount': this.numberToString(amount),
1447
+ 'quantity': this.numberToString(amount),
1443
1448
  'address': address,
1444
1449
  };
1445
1450
  if (tag !== undefined) {
@@ -677,6 +677,7 @@ export default class Exchange {
677
677
  editLimitSellOrder(id: string, symbol: string, amount: number, price?: Num, params?: {}): Promise<Order>;
678
678
  editLimitOrder(id: string, symbol: string, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
679
679
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
680
+ editOrderWithClientOrderId(clientOrderId: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
680
681
  editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
681
682
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
682
683
  fetchPositionWs(symbol: string, params?: {}): Promise<Position[]>;
@@ -737,6 +738,16 @@ export default class Exchange {
737
738
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
738
739
  unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
739
740
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
741
+ /**
742
+ * @method
743
+ * @name fetchOrderWithClientOrderId
744
+ * @description create a market order by providing the symbol, side and cost
745
+ * @param {string} clientOrderId client order Id
746
+ * @param {string} symbol unified symbol of the market to create an order in
747
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
748
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
749
+ */
750
+ fetchOrderWithClientOrderId(clientOrderId: string, symbol?: Str, params?: {}): Promise<Order>;
740
751
  fetchOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
741
752
  fetchOrderStatus(id: string, symbol?: Str, params?: {}): Promise<string>;
742
753
  fetchUnifiedOrder(order: any, params?: {}): Promise<Order>;
@@ -766,8 +777,28 @@ export default class Exchange {
766
777
  editOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
767
778
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
768
779
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
780
+ /**
781
+ * @method
782
+ * @name cancelOrderWithClientOrderId
783
+ * @description create a market order by providing the symbol, side and cost
784
+ * @param {string} clientOrderId client order Id
785
+ * @param {string} symbol unified symbol of the market to create an order in
786
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
787
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
788
+ */
789
+ cancelOrderWithClientOrderId(clientOrderId: string, symbol?: Str, params?: {}): Promise<Order>;
769
790
  cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
770
791
  cancelOrders(ids: string[], symbol?: Str, params?: {}): Promise<Order[]>;
792
+ /**
793
+ * @method
794
+ * @name cancelOrdersWithClientOrderIds
795
+ * @description create a market order by providing the symbol, side and cost
796
+ * @param {string[]} clientOrderIds client order Ids
797
+ * @param {string} symbol unified symbol of the market to create an order in
798
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
799
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
800
+ */
801
+ cancelOrdersWithClientOrderIds(clientOrderIds: string[], symbol?: Str, params?: {}): Promise<Order[]>;
771
802
  cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<Order[]>;
772
803
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
773
804
  cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<{}>;
@@ -14,7 +14,7 @@ import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './
14
14
  // ----------------------------------------------------------------------------
15
15
  //
16
16
  import { axolotl } from './functions/crypto.js';
17
- import totp from './functions/totp.js';
17
+ import { totp } from './functions/totp.js';
18
18
  import ethers from '../static_dependencies/ethers/index.js';
19
19
  import { TypedDataEncoder } from '../static_dependencies/ethers/hash/index.js';
20
20
  import { SecureRandom } from '../static_dependencies/jsencrypt/lib/jsbn/rng.js';
@@ -1434,8 +1434,10 @@ export default class Exchange {
1434
1434
  'cancelAllOrders': undefined,
1435
1435
  'cancelAllOrdersWs': undefined,
1436
1436
  'cancelOrder': true,
1437
+ 'cancelOrderWithClientOrderId': undefined,
1437
1438
  'cancelOrderWs': undefined,
1438
1439
  'cancelOrders': undefined,
1440
+ 'cancelOrdersWithClientOrderId': undefined,
1439
1441
  'cancelOrdersWs': undefined,
1440
1442
  'closeAllPositions': undefined,
1441
1443
  'closePosition': undefined,
@@ -1485,6 +1487,7 @@ export default class Exchange {
1485
1487
  'createTriggerOrderWs': undefined,
1486
1488
  'deposit': undefined,
1487
1489
  'editOrder': 'emulated',
1490
+ 'editOrderWithClientOrderId': undefined,
1488
1491
  'editOrders': undefined,
1489
1492
  'editOrderWs': undefined,
1490
1493
  'fetchAccounts': undefined,
@@ -1563,6 +1566,7 @@ export default class Exchange {
1563
1566
  'fetchOption': undefined,
1564
1567
  'fetchOptionChain': undefined,
1565
1568
  'fetchOrder': undefined,
1569
+ 'fetchOrderWithClientOrderId': undefined,
1566
1570
  'fetchOrderBook': true,
1567
1571
  'fetchOrderBooks': undefined,
1568
1572
  'fetchOrderBookWs': undefined,
@@ -4746,6 +4750,9 @@ export default class Exchange {
4746
4750
  await this.cancelOrder(id, symbol);
4747
4751
  return await this.createOrder(symbol, type, side, amount, price, params);
4748
4752
  }
4753
+ async editOrderWithClientOrderId(clientOrderId, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4754
+ return await this.editOrder('', symbol, type, side, amount, price, this.extend({ 'clientOrderId': clientOrderId }, params));
4755
+ }
4749
4756
  async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4750
4757
  await this.cancelOrderWs(id, symbol);
4751
4758
  return await this.createOrderWs(symbol, type, side, amount, price, params);
@@ -5236,6 +5243,19 @@ export default class Exchange {
5236
5243
  async fetchOrder(id, symbol = undefined, params = {}) {
5237
5244
  throw new NotSupported(this.id + ' fetchOrder() is not supported yet');
5238
5245
  }
5246
+ /**
5247
+ * @method
5248
+ * @name fetchOrderWithClientOrderId
5249
+ * @description create a market order by providing the symbol, side and cost
5250
+ * @param {string} clientOrderId client order Id
5251
+ * @param {string} symbol unified symbol of the market to create an order in
5252
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5253
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5254
+ */
5255
+ async fetchOrderWithClientOrderId(clientOrderId, symbol = undefined, params = {}) {
5256
+ const extendedParams = this.extend(params, { 'clientOrderId': clientOrderId });
5257
+ return await this.fetchOrder('', symbol, extendedParams);
5258
+ }
5239
5259
  async fetchOrderWs(id, symbol = undefined, params = {}) {
5240
5260
  throw new NotSupported(this.id + ' fetchOrderWs() is not supported yet');
5241
5261
  }
@@ -5690,12 +5710,38 @@ export default class Exchange {
5690
5710
  async cancelOrder(id, symbol = undefined, params = {}) {
5691
5711
  throw new NotSupported(this.id + ' cancelOrder() is not supported yet');
5692
5712
  }
5713
+ /**
5714
+ * @method
5715
+ * @name cancelOrderWithClientOrderId
5716
+ * @description create a market order by providing the symbol, side and cost
5717
+ * @param {string} clientOrderId client order Id
5718
+ * @param {string} symbol unified symbol of the market to create an order in
5719
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5720
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5721
+ */
5722
+ async cancelOrderWithClientOrderId(clientOrderId, symbol = undefined, params = {}) {
5723
+ const extendedParams = this.extend(params, { 'clientOrderId': clientOrderId });
5724
+ return await this.cancelOrder('', symbol, extendedParams);
5725
+ }
5693
5726
  async cancelOrderWs(id, symbol = undefined, params = {}) {
5694
5727
  throw new NotSupported(this.id + ' cancelOrderWs() is not supported yet');
5695
5728
  }
5696
5729
  async cancelOrders(ids, symbol = undefined, params = {}) {
5697
5730
  throw new NotSupported(this.id + ' cancelOrders() is not supported yet');
5698
5731
  }
5732
+ /**
5733
+ * @method
5734
+ * @name cancelOrdersWithClientOrderIds
5735
+ * @description create a market order by providing the symbol, side and cost
5736
+ * @param {string[]} clientOrderIds client order Ids
5737
+ * @param {string} symbol unified symbol of the market to create an order in
5738
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5739
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5740
+ */
5741
+ async cancelOrdersWithClientOrderIds(clientOrderIds, symbol = undefined, params = {}) {
5742
+ const extendedParams = this.extend(params, { 'clientOrderIds': clientOrderIds });
5743
+ return await this.cancelOrders([], symbol, extendedParams);
5744
+ }
5699
5745
  async cancelOrdersWs(ids, symbol = undefined, params = {}) {
5700
5746
  throw new NotSupported(this.id + ' cancelOrdersWs() is not supported yet');
5701
5747
  }
@@ -407,6 +407,8 @@ export interface Liquidation {
407
407
  price: number;
408
408
  baseValue?: number;
409
409
  quoteValue?: number;
410
+ contracts?: number;
411
+ contractSize?: number;
410
412
  side?: OrderSide;
411
413
  }
412
414
  export interface OrderRequest {
package/js/src/binance.js CHANGED
@@ -12127,6 +12127,9 @@ export default class binance extends Exchange {
12127
12127
  const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
12128
12128
  const origclientorderidlist = this.safeList2(extendedParams, 'origclientorderidlist', 'origClientOrderIdList', []);
12129
12129
  extendedParams = this.omit(extendedParams, ['orderidlist', 'origclientorderidlist', 'origClientOrderIdList']);
12130
+ if ('symbol' in extendedParams) {
12131
+ extendedParams['symbol'] = this.encodeURIComponent(extendedParams['symbol']);
12132
+ }
12130
12133
  query = this.rawencode(extendedParams);
12131
12134
  const orderidlistLength = orderidlist.length;
12132
12135
  const origclientorderidlistLength = origclientorderidlist.length;
package/js/src/bingx.d.ts CHANGED
@@ -191,7 +191,7 @@ export default class bingx extends Exchange {
191
191
  * @name bingx#fetchBalance
192
192
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
193
193
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
194
- * @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
194
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20account%20data
195
195
  * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
196
196
  * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
197
197
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -640,7 +640,7 @@ export default class bingx extends Exchange {
640
640
  * @param {string} address the address to withdraw to
641
641
  * @param {string} [tag]
642
642
  * @param {object} [params] extra parameters specific to the exchange API endpoint
643
- * @param {int} [params.walletType] 1 fund account, 2 standard account, 3 perpetual account, 15 spot account
643
+ * @param {int} [params.walletType] 1 fund (funding) account, 2 standard account, 3 perpetual account, 15 spot account
644
644
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
645
645
  */
646
646
  withdraw(code: string, amount: number, address: string, tag?: Str, params?: {}): Promise<Transaction>;
package/js/src/bingx.js CHANGED
@@ -168,6 +168,9 @@ export default class bingx extends Exchange {
168
168
  'trade/myTrades': 2,
169
169
  'user/commissionRate': 5,
170
170
  'account/balance': 2,
171
+ 'oco/orderList': 5,
172
+ 'oco/openOrderList': 5,
173
+ 'oco/historyOrderList': 5,
171
174
  },
172
175
  'post': {
173
176
  'trade/order': 2,
@@ -177,6 +180,8 @@ export default class bingx extends Exchange {
177
180
  'trade/cancelOrders': 5,
178
181
  'trade/cancelOpenOrders': 5,
179
182
  'trade/cancelAllAfter': 5,
183
+ 'oco/order': 5,
184
+ 'oco/cancel': 5,
180
185
  },
181
186
  },
182
187
  },
@@ -210,6 +215,7 @@ export default class bingx extends Exchange {
210
215
  'market/historicalTrades': 1,
211
216
  'market/markPriceKlines': 1,
212
217
  'trade/multiAssetsRules': 1,
218
+ 'tradingRules': 1,
213
219
  },
214
220
  },
215
221
  'private': {
@@ -235,6 +241,8 @@ export default class bingx extends Exchange {
235
241
  'twap/order': 5,
236
242
  'twap/cancelOrder': 5,
237
243
  'trade/assetMode': 5,
244
+ 'trade/reverse': 5,
245
+ 'trade/autoAddMargin': 5,
238
246
  },
239
247
  },
240
248
  },
@@ -295,6 +303,11 @@ export default class bingx extends Exchange {
295
303
  'quote/klines': 1,
296
304
  },
297
305
  },
306
+ 'private': {
307
+ 'get': {
308
+ 'user/balance': 2,
309
+ },
310
+ },
298
311
  },
299
312
  },
300
313
  'cswap': {
@@ -473,6 +486,22 @@ export default class bingx extends Exchange {
473
486
  },
474
487
  },
475
488
  },
489
+ 'agent': {
490
+ 'v1': {
491
+ 'private': {
492
+ 'get': {
493
+ 'account/inviteAccountList': 5,
494
+ 'reward/commissionDataList': 5,
495
+ 'account/inviteRelationCheck': 5,
496
+ 'asset/depositDetailList': 5,
497
+ 'reward/third/commissionDataList': 5,
498
+ 'asset/partnerData': 5,
499
+ 'commissionDataList/referralCode': 5,
500
+ 'account/superiorCheck': 5,
501
+ },
502
+ },
503
+ },
504
+ },
476
505
  },
477
506
  'timeframes': {
478
507
  '1m': '1m',
@@ -2195,7 +2224,7 @@ export default class bingx extends Exchange {
2195
2224
  * @name bingx#fetchBalance
2196
2225
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
2197
2226
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
2198
- * @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
2227
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20account%20data
2199
2228
  * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
2200
2229
  * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
2201
2230
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2291,27 +2320,26 @@ export default class bingx extends Exchange {
2291
2320
  //
2292
2321
  }
2293
2322
  else {
2294
- response = await this.swapV2PrivateGetUserBalance(marketTypeQuery);
2323
+ response = await this.swapV3PrivateGetUserBalance(marketTypeQuery);
2295
2324
  //
2296
2325
  // {
2297
2326
  // "code": 0,
2298
2327
  // "msg": "",
2299
- // "data": {
2300
- // "balance": {
2301
- // "userId": "1177064765068660742",
2328
+ // "data": [
2329
+ // {
2330
+ // "userId": "116***295",
2302
2331
  // "asset": "USDT",
2303
- // "balance": "51.5198",
2304
- // "equity": "50.5349",
2305
- // "unrealizedProfit": "-0.9849",
2306
- // "realisedProfit": "-0.2134",
2307
- // "availableMargin": "49.1428",
2308
- // "usedMargin": "1.3922",
2332
+ // "balance": "194.8212",
2333
+ // "equity": "196.7431",
2334
+ // "unrealizedProfit": "1.9219",
2335
+ // "realisedProfit": "-109.2504",
2336
+ // "availableMargin": "193.7609",
2337
+ // "usedMargin": "1.0602",
2309
2338
  // "freezedMargin": "0.0000",
2310
2339
  // "shortUid": "12851936"
2311
2340
  // }
2312
- // }
2341
+ // ]
2313
2342
  // }
2314
- //
2315
2343
  }
2316
2344
  }
2317
2345
  return this.parseBalance(response);
@@ -2379,34 +2407,35 @@ export default class bingx extends Exchange {
2379
2407
  // {
2380
2408
  // "code": 0,
2381
2409
  // "msg": "",
2382
- // "data": {
2383
- // "balance": {
2384
- // "userId": "1177064765068660742",
2410
+ // "data": [
2411
+ // {
2412
+ // "userId": "116***295",
2385
2413
  // "asset": "USDT",
2386
- // "balance": "51.5198",
2387
- // "equity": "50.5349",
2388
- // "unrealizedProfit": "-0.9849",
2389
- // "realisedProfit": "-0.2134",
2390
- // "availableMargin": "49.1428",
2391
- // "usedMargin": "1.3922",
2414
+ // "balance": "194.8212",
2415
+ // "equity": "196.7431",
2416
+ // "unrealizedProfit": "1.9219",
2417
+ // "realisedProfit": "-109.2504",
2418
+ // "availableMargin": "193.7609",
2419
+ // "usedMargin": "1.0602",
2392
2420
  // "freezedMargin": "0.0000",
2393
2421
  // "shortUid": "12851936"
2394
2422
  // }
2395
- // }
2423
+ // ]
2396
2424
  // }
2397
2425
  //
2398
2426
  const result = { 'info': response };
2399
- const standardAndInverseBalances = this.safeList(response, 'data');
2400
- const firstStandardOrInverse = this.safeDict(standardAndInverseBalances, 0);
2401
- const isStandardOrInverse = firstStandardOrInverse !== undefined;
2427
+ const contractBalances = this.safeList(response, 'data');
2428
+ const firstContractBalances = this.safeDict(contractBalances, 0);
2429
+ const isContract = firstContractBalances !== undefined;
2402
2430
  const spotData = this.safeDict(response, 'data', {});
2403
2431
  const spotBalances = this.safeList2(spotData, 'balances', 'assets', []);
2404
- const firstSpot = this.safeDict(spotBalances, 0);
2405
- const isSpot = firstSpot !== undefined;
2406
- if (isStandardOrInverse) {
2407
- for (let i = 0; i < standardAndInverseBalances.length; i++) {
2408
- const balance = standardAndInverseBalances[i];
2432
+ if (isContract) {
2433
+ for (let i = 0; i < contractBalances.length; i++) {
2434
+ const balance = contractBalances[i];
2409
2435
  const currencyId = this.safeString(balance, 'asset');
2436
+ if (currencyId === undefined) { // linear v3 returns empty asset
2437
+ break;
2438
+ }
2410
2439
  const code = this.safeCurrencyCode(currencyId);
2411
2440
  const account = this.account();
2412
2441
  account['free'] = this.safeString2(balance, 'availableMargin', 'availableBalance');
@@ -2415,7 +2444,7 @@ export default class bingx extends Exchange {
2415
2444
  result[code] = account;
2416
2445
  }
2417
2446
  }
2418
- else if (isSpot) {
2447
+ else {
2419
2448
  for (let i = 0; i < spotBalances.length; i++) {
2420
2449
  const balance = spotBalances[i];
2421
2450
  const currencyId = this.safeString(balance, 'asset');
@@ -2426,18 +2455,6 @@ export default class bingx extends Exchange {
2426
2455
  result[code] = account;
2427
2456
  }
2428
2457
  }
2429
- else {
2430
- const linearSwapData = this.safeDict(response, 'data', {});
2431
- const linearSwapBalance = this.safeDict(linearSwapData, 'balance');
2432
- if (linearSwapBalance) {
2433
- const currencyId = this.safeString(linearSwapBalance, 'asset');
2434
- const code = this.safeCurrencyCode(currencyId);
2435
- const account = this.account();
2436
- account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
2437
- account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
2438
- result[code] = account;
2439
- }
2440
- }
2441
2458
  return this.safeBalance(result);
2442
2459
  }
2443
2460
  /**
@@ -5878,7 +5895,7 @@ export default class bingx extends Exchange {
5878
5895
  * @param {string} address the address to withdraw to
5879
5896
  * @param {string} [tag]
5880
5897
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5881
- * @param {int} [params.walletType] 1 fund account, 2 standard account, 3 perpetual account, 15 spot account
5898
+ * @param {int} [params.walletType] 1 fund (funding) account, 2 standard account, 3 perpetual account, 15 spot account
5882
5899
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
5883
5900
  */
5884
5901
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -5886,7 +5903,17 @@ export default class bingx extends Exchange {
5886
5903
  this.checkAddress(address);
5887
5904
  await this.loadMarkets();
5888
5905
  const currency = this.currency(code);
5889
- const walletType = this.safeInteger(params, 'walletType', 15);
5906
+ const defaultWalletType = 15; // spot
5907
+ let walletType = undefined;
5908
+ [walletType, params] = this.handleOptionAndParams2(params, 'withdraw', 'type', 'walletType', defaultWalletType);
5909
+ const walletTypes = {
5910
+ 'funding': 1,
5911
+ 'fund': 1,
5912
+ 'standard': 2,
5913
+ 'perpetual': 3,
5914
+ 'spot': 15,
5915
+ };
5916
+ walletType = this.safeInteger(walletTypes, walletType, defaultWalletType);
5890
5917
  const request = {
5891
5918
  'coin': currency['id'],
5892
5919
  'address': address,
package/js/src/bitget.js CHANGED
@@ -1395,6 +1395,7 @@ export default class bitget extends Exchange {
1395
1395
  'commonCurrencies': {
1396
1396
  'APX': 'AstroPepeX',
1397
1397
  'DEGEN': 'DegenReborn',
1398
+ 'EVA': 'Evadore',
1398
1399
  'JADE': 'Jade Protocol',
1399
1400
  'OMNI': 'omni',
1400
1401
  'TONCOIN': 'TON',
@@ -2455,11 +2456,22 @@ export default class bitget extends Exchange {
2455
2456
  const code = this.safeCurrencyCode(id);
2456
2457
  const chains = this.safeValue(entry, 'chains', []);
2457
2458
  const networks = {};
2458
- for (let j = 0; j < chains.length; j++) {
2459
+ let withdraw = undefined;
2460
+ let deposit = undefined;
2461
+ const chainsLength = chains.length;
2462
+ if (chainsLength === 0) {
2463
+ withdraw = false;
2464
+ deposit = false;
2465
+ }
2466
+ for (let j = 0; j < chainsLength; j++) {
2459
2467
  const chain = chains[j];
2460
2468
  const networkId = this.safeString(chain, 'chain');
2461
2469
  let network = this.networkIdToCode(networkId, code);
2462
2470
  network = network.toUpperCase();
2471
+ const withdrawable = (this.safeString(chain, 'withdrawable') === 'true');
2472
+ const rechargeable = (this.safeString(chain, 'rechargeable') === 'true');
2473
+ withdraw = (withdraw === undefined) ? withdrawable : (withdraw || withdrawable);
2474
+ deposit = (deposit === undefined) ? rechargeable : (deposit || rechargeable);
2463
2475
  networks[network] = {
2464
2476
  'info': chain,
2465
2477
  'id': networkId,
@@ -2475,12 +2487,13 @@ export default class bitget extends Exchange {
2475
2487
  },
2476
2488
  },
2477
2489
  'active': undefined,
2478
- 'withdraw': this.safeString(chain, 'withdrawable') === 'true',
2479
- 'deposit': this.safeString(chain, 'rechargeable') === 'true',
2490
+ 'withdraw': withdrawable,
2491
+ 'deposit': rechargeable,
2480
2492
  'fee': this.safeNumber(chain, 'withdrawFee'),
2481
2493
  'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawMinScale'))),
2482
2494
  };
2483
2495
  }
2496
+ const active = withdraw && deposit;
2484
2497
  const isFiat = this.inArray(code, fiatCurrencies);
2485
2498
  result[code] = this.safeCurrencyStructure({
2486
2499
  'info': entry,
@@ -2489,9 +2502,9 @@ export default class bitget extends Exchange {
2489
2502
  'networks': networks,
2490
2503
  'type': isFiat ? 'fiat' : 'crypto',
2491
2504
  'name': undefined,
2492
- 'active': undefined,
2493
- 'deposit': undefined,
2494
- 'withdraw': undefined,
2505
+ 'active': active,
2506
+ 'deposit': deposit,
2507
+ 'withdraw': withdraw,
2495
2508
  'fee': undefined,
2496
2509
  'precision': undefined,
2497
2510
  'limits': {
package/js/src/blofin.js CHANGED
@@ -1383,18 +1383,20 @@ export default class blofin extends Exchange {
1383
1383
  [method, params] = this.handleOptionAndParams(params, 'createOrder', 'method', 'privatePostTradeOrder');
1384
1384
  const isStopLossPriceDefined = this.safeString(params, 'stopLossPrice') !== undefined;
1385
1385
  const isTakeProfitPriceDefined = this.safeString(params, 'takeProfitPrice') !== undefined;
1386
- const isTriggerOrder = this.safeString(params, 'triggerPrice') !== undefined;
1386
+ const hasTriggerPrice = this.safeString(params, 'triggerPrice') !== undefined;
1387
1387
  const isType2Order = (isStopLossPriceDefined || isTakeProfitPriceDefined);
1388
1388
  let response = undefined;
1389
1389
  const reduceOnly = this.safeBool(params, 'reduceOnly');
1390
1390
  if (reduceOnly !== undefined) {
1391
1391
  params['reduceOnly'] = reduceOnly ? 'true' : 'false';
1392
1392
  }
1393
- if (tpsl || (method === 'privatePostTradeOrderTpsl') || isType2Order) {
1393
+ const isTpslOrder = tpsl || (method === 'privatePostTradeOrderTpsl') || isType2Order;
1394
+ const isTriggerOrder = hasTriggerPrice || (method === 'privatePostTradeOrderAlgo');
1395
+ if (isTpslOrder) {
1394
1396
  const tpslRequest = this.createTpslOrderRequest(symbol, type, side, amount, price, params);
1395
1397
  response = await this.privatePostTradeOrderTpsl(tpslRequest);
1396
1398
  }
1397
- else if (isTriggerOrder || (method === 'privatePostTradeOrderAlgo')) {
1399
+ else if (isTriggerOrder) {
1398
1400
  const triggerRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
1399
1401
  response = await this.privatePostTradeOrderAlgo(triggerRequest);
1400
1402
  }
@@ -1402,10 +1404,9 @@ export default class blofin extends Exchange {
1402
1404
  const request = this.createOrderRequest(symbol, type, side, amount, price, params);
1403
1405
  response = await this.privatePostTradeOrder(request);
1404
1406
  }
1405
- if (isTriggerOrder || (method === 'privatePostTradeOrderAlgo')) {
1407
+ if (isTpslOrder || isTriggerOrder) {
1406
1408
  const dataDict = this.safeDict(response, 'data', {});
1407
- const triggerOrder = this.parseOrder(dataDict, market);
1408
- return triggerOrder;
1409
+ return this.parseOrder(dataDict, market);
1409
1410
  }
1410
1411
  const data = this.safeList(response, 'data', []);
1411
1412
  const first = this.safeDict(data, 0);
package/js/src/bybit.d.ts CHANGED
@@ -232,7 +232,7 @@ export default class bybit extends Exchange {
232
232
  * @param {string} [params.positionIdx] *contracts only* 0 for one-way mode, 1 buy side of hedged mode, 2 sell side of hedged mode
233
233
  * @param {bool} [params.hedged] *contracts only* true for hedged mode, false for one way mode, default is false
234
234
  * @param {int} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
235
- * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
235
+ * @param {string} [params.tpslMode] *contract only* 'Full' or 'Partial'
236
236
  * @param {string} [params.mmp] *option only* market maker protection
237
237
  * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'ascending' or 'descending'
238
238
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at