ccxt 4.2.38 → 4.2.40

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 (127) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1340 -407
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +28 -24
  6. package/dist/cjs/src/base/Exchange.js +28 -16
  7. package/dist/cjs/src/binance.js +528 -181
  8. package/dist/cjs/src/bingx.js +250 -23
  9. package/dist/cjs/src/bitget.js +14 -3
  10. package/dist/cjs/src/bitso.js +18 -2
  11. package/dist/cjs/src/bitstamp.js +24 -2
  12. package/dist/cjs/src/bl3p.js +6 -0
  13. package/dist/cjs/src/blockchaincom.js +21 -0
  14. package/dist/cjs/src/btcalpha.js +9 -0
  15. package/dist/cjs/src/btcbox.js +9 -0
  16. package/dist/cjs/src/btcmarkets.js +19 -0
  17. package/dist/cjs/src/bybit.js +3 -1
  18. package/dist/cjs/src/coinbase.js +21 -8
  19. package/dist/cjs/src/coinbasepro.js +1 -0
  20. package/dist/cjs/src/coinlist.js +9 -7
  21. package/dist/cjs/src/coinmetro.js +2 -1
  22. package/dist/cjs/src/krakenfutures.js +133 -16
  23. package/dist/cjs/src/luno.js +1 -1
  24. package/dist/cjs/src/mexc.js +43 -43
  25. package/dist/cjs/src/okx.js +11 -17
  26. package/dist/cjs/src/phemex.js +1 -0
  27. package/dist/cjs/src/poloniexfutures.js +11 -5
  28. package/dist/cjs/src/pro/bitmart.js +141 -48
  29. package/dist/cjs/src/pro/bybit.js +5 -5
  30. package/dist/cjs/src/pro/mexc.js +1 -1
  31. package/dist/cjs/src/wavesexchange.js +1 -1
  32. package/dist/cjs/src/woo.js +1 -1
  33. package/js/ccxt.d.ts +1 -1
  34. package/js/ccxt.js +1 -1
  35. package/js/src/abstract/bingx.d.ts +4 -0
  36. package/js/src/abstract/coinbase.d.ts +1 -0
  37. package/js/src/abstract/coinbasepro.d.ts +1 -0
  38. package/js/src/abstract/okx.d.ts +1 -0
  39. package/js/src/ascendex.d.ts +2 -2
  40. package/js/src/ascendex.js +28 -24
  41. package/js/src/base/Exchange.d.ts +12 -8
  42. package/js/src/base/Exchange.js +28 -16
  43. package/js/src/base/types.d.ts +2 -0
  44. package/js/src/bigone.d.ts +2 -2
  45. package/js/src/binance.d.ts +9 -9
  46. package/js/src/binance.js +528 -181
  47. package/js/src/bingx.d.ts +6 -5
  48. package/js/src/bingx.js +250 -23
  49. package/js/src/bitfinex.d.ts +3 -3
  50. package/js/src/bitfinex2.d.ts +2 -2
  51. package/js/src/bitget.d.ts +5 -5
  52. package/js/src/bitget.js +14 -3
  53. package/js/src/bitmart.d.ts +2 -2
  54. package/js/src/bitmex.d.ts +2 -2
  55. package/js/src/bitrue.d.ts +2 -2
  56. package/js/src/bitso.d.ts +1 -1
  57. package/js/src/bitso.js +18 -2
  58. package/js/src/bitstamp.d.ts +1 -1
  59. package/js/src/bitstamp.js +24 -2
  60. package/js/src/bitvavo.d.ts +1 -1
  61. package/js/src/bl3p.js +6 -0
  62. package/js/src/blockchaincom.js +21 -0
  63. package/js/src/blofin.d.ts +2 -2
  64. package/js/src/btcalpha.js +9 -0
  65. package/js/src/btcbox.js +9 -0
  66. package/js/src/btcmarkets.js +19 -0
  67. package/js/src/bybit.d.ts +7 -7
  68. package/js/src/bybit.js +3 -1
  69. package/js/src/cex.d.ts +1 -1
  70. package/js/src/coinbase.d.ts +2 -2
  71. package/js/src/coinbase.js +21 -8
  72. package/js/src/coinbasepro.js +1 -0
  73. package/js/src/coinex.d.ts +4 -4
  74. package/js/src/coinlist.d.ts +2 -2
  75. package/js/src/coinlist.js +9 -7
  76. package/js/src/coinmetro.js +2 -1
  77. package/js/src/coinone.d.ts +1 -1
  78. package/js/src/delta.d.ts +2 -2
  79. package/js/src/deribit.d.ts +3 -3
  80. package/js/src/digifinex.d.ts +3 -3
  81. package/js/src/exmo.d.ts +2 -2
  82. package/js/src/gate.d.ts +6 -6
  83. package/js/src/hitbtc.d.ts +2 -2
  84. package/js/src/hollaex.d.ts +1 -1
  85. package/js/src/htx.d.ts +3 -3
  86. package/js/src/huobijp.d.ts +1 -1
  87. package/js/src/kraken.d.ts +2 -2
  88. package/js/src/krakenfutures.d.ts +4 -2
  89. package/js/src/krakenfutures.js +133 -16
  90. package/js/src/kucoin.d.ts +5 -5
  91. package/js/src/kucoinfutures.d.ts +2 -2
  92. package/js/src/latoken.d.ts +1 -1
  93. package/js/src/lbank.d.ts +2 -2
  94. package/js/src/luno.d.ts +1 -1
  95. package/js/src/luno.js +1 -1
  96. package/js/src/mexc.d.ts +4 -4
  97. package/js/src/mexc.js +43 -43
  98. package/js/src/ndax.d.ts +1 -1
  99. package/js/src/novadax.d.ts +1 -1
  100. package/js/src/okcoin.d.ts +2 -2
  101. package/js/src/okx.d.ts +7 -7
  102. package/js/src/okx.js +11 -17
  103. package/js/src/paymium.d.ts +2 -2
  104. package/js/src/phemex.d.ts +4 -4
  105. package/js/src/phemex.js +1 -0
  106. package/js/src/poloniex.d.ts +2 -2
  107. package/js/src/poloniexfutures.d.ts +2 -2
  108. package/js/src/poloniexfutures.js +11 -5
  109. package/js/src/pro/bitmart.d.ts +4 -0
  110. package/js/src/pro/bitmart.js +141 -48
  111. package/js/src/pro/bitvavo.d.ts +1 -1
  112. package/js/src/pro/bybit.d.ts +1 -1
  113. package/js/src/pro/bybit.js +5 -5
  114. package/js/src/pro/cex.d.ts +2 -2
  115. package/js/src/pro/coinbase.d.ts +2 -2
  116. package/js/src/pro/coinex.d.ts +1 -1
  117. package/js/src/pro/lbank.d.ts +1 -1
  118. package/js/src/pro/mexc.js +1 -1
  119. package/js/src/probit.d.ts +1 -1
  120. package/js/src/timex.d.ts +1 -1
  121. package/js/src/upbit.d.ts +1 -1
  122. package/js/src/wavesexchange.js +1 -1
  123. package/js/src/whitebit.d.ts +2 -2
  124. package/js/src/woo.d.ts +3 -3
  125. package/js/src/woo.js +1 -1
  126. package/js/src/zonda.d.ts +3 -3
  127. package/package.json +2 -2
package/js/src/bingx.d.ts CHANGED
@@ -66,9 +66,9 @@ export default class bingx extends Exchange {
66
66
  parseBalance(response: any): Balances;
67
67
  fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
68
68
  parsePosition(position: any, market?: Market): Position;
69
- createMarketOrderWithCost(symbol: string, side: OrderSide, cost: any, params?: {}): Promise<Order>;
70
- createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
71
- createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
69
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
70
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
71
+ createMarketSellOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
72
72
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): any;
73
73
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
74
74
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
@@ -81,7 +81,7 @@ export default class bingx extends Exchange {
81
81
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
82
82
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
83
83
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
84
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
84
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
85
85
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
86
86
  parseTransfer(transfer: any, currency?: Currency): {
87
87
  info: any;
@@ -130,7 +130,8 @@ export default class bingx extends Exchange {
130
130
  parseLiquidation(liquidation: any, market?: Market): import("./base/types.js").Liquidation;
131
131
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
132
132
  closeAllPositions(params?: {}): Promise<Position[]>;
133
- setPositionMode(hedged: any, symbol?: Str, params?: {}): Promise<any>;
133
+ setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
134
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
134
135
  sign(path: any, section?: string, method?: string, params?: {}, headers?: any, body?: any): {
135
136
  url: any;
136
137
  method: string;
package/js/src/bingx.js CHANGED
@@ -143,6 +143,7 @@ export default class bingx extends Exchange {
143
143
  'trade/order': 3,
144
144
  'trade/cancel': 3,
145
145
  'trade/batchOrders': 3,
146
+ 'trade/order/cancelReplace': 3,
146
147
  'trade/cancelOrders': 3,
147
148
  'trade/cancelOpenOrders': 3,
148
149
  },
@@ -164,12 +165,19 @@ export default class bingx extends Exchange {
164
165
  },
165
166
  'swap': {
166
167
  'v1': {
168
+ 'public': {
169
+ 'get': {
170
+ 'ticker/price': 1,
171
+ },
172
+ },
167
173
  'private': {
168
174
  'get': {
169
175
  'positionSide/dual': 1,
170
176
  'market/markPriceKlines': 1,
177
+ 'trade/batchCancelReplace': 1,
171
178
  },
172
179
  'post': {
180
+ 'trade/cancelReplace': 1,
173
181
  'positionSide/dual': 1,
174
182
  },
175
183
  },
@@ -2244,22 +2252,104 @@ export default class bingx extends Exchange {
2244
2252
  // reduceOnly: false
2245
2253
  // }
2246
2254
  //
2255
+ // editOrder (swap)
2256
+ //
2257
+ // {
2258
+ // cancelResult: 'true',
2259
+ // cancelMsg: '',
2260
+ // cancelResponse: {
2261
+ // cancelClientOrderId: '',
2262
+ // cancelOrderId: '1755336244265705472',
2263
+ // symbol: 'SOL-USDT',
2264
+ // orderId: '1755336244265705472',
2265
+ // side: 'SELL',
2266
+ // positionSide: 'SHORT',
2267
+ // type: 'LIMIT',
2268
+ // origQty: '1',
2269
+ // price: '100.000',
2270
+ // executedQty: '0',
2271
+ // avgPrice: '0.000',
2272
+ // cumQuote: '0',
2273
+ // stopPrice: '',
2274
+ // profit: '0.0000',
2275
+ // commission: '0.000000',
2276
+ // status: 'PENDING',
2277
+ // time: '1707339747860',
2278
+ // updateTime: '1707339747860',
2279
+ // clientOrderId: '',
2280
+ // leverage: '20X',
2281
+ // workingType: 'MARK_PRICE',
2282
+ // onlyOnePosition: false,
2283
+ // reduceOnly: false
2284
+ // },
2285
+ // replaceResult: 'true',
2286
+ // replaceMsg: '',
2287
+ // newOrderResponse: {
2288
+ // orderId: '1755338440612995072',
2289
+ // symbol: 'SOL-USDT',
2290
+ // positionSide: 'SHORT',
2291
+ // side: 'SELL',
2292
+ // type: 'LIMIT',
2293
+ // price: '99',
2294
+ // quantity: '2',
2295
+ // stopPrice: '0',
2296
+ // workingType: 'MARK_PRICE',
2297
+ // clientOrderID: '',
2298
+ // timeInForce: 'GTC',
2299
+ // priceRate: '0',
2300
+ // stopLoss: '',
2301
+ // takeProfit: '',
2302
+ // reduceOnly: false
2303
+ // }
2304
+ // }
2305
+ //
2306
+ // editOrder (spot)
2307
+ //
2308
+ // {
2309
+ // cancelResult: { code: '0', msg: '', result: true },
2310
+ // openResult: { code: '0', msg: '', result: true },
2311
+ // orderOpenResponse: {
2312
+ // symbol: 'SOL-USDT',
2313
+ // orderId: '1755334007697866752',
2314
+ // transactTime: '1707339214620',
2315
+ // price: '99',
2316
+ // stopPrice: '0',
2317
+ // origQty: '0.2',
2318
+ // executedQty: '0',
2319
+ // cummulativeQuoteQty: '0',
2320
+ // status: 'PENDING',
2321
+ // type: 'LIMIT',
2322
+ // side: 'SELL',
2323
+ // clientOrderID: ''
2324
+ // },
2325
+ // orderCancelResponse: {
2326
+ // symbol: 'SOL-USDT',
2327
+ // orderId: '1755117055251480576',
2328
+ // price: '100',
2329
+ // stopPrice: '0',
2330
+ // origQty: '0.2',
2331
+ // executedQty: '0',
2332
+ // cummulativeQuoteQty: '0',
2333
+ // status: 'CANCELED',
2334
+ // type: 'LIMIT',
2335
+ // side: 'SELL'
2336
+ // }
2337
+ // }
2338
+ //
2339
+ const info = order;
2340
+ const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
2341
+ if (newOrder !== undefined) {
2342
+ order = newOrder;
2343
+ }
2247
2344
  const positionSide = this.safeString2(order, 'positionSide', 'ps');
2248
2345
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
2249
2346
  const marketId = this.safeString2(order, 'symbol', 's');
2250
2347
  if (market === undefined) {
2251
2348
  market = this.safeMarket(marketId, undefined, undefined, marketType);
2252
2349
  }
2253
- const symbol = this.safeSymbol(marketId, market, '-', marketType);
2254
- const orderId = this.safeString2(order, 'orderId', 'i');
2255
2350
  const side = this.safeStringLower2(order, 'side', 'S');
2256
- const type = this.safeStringLower2(order, 'type', 'o');
2257
2351
  const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
2258
2352
  const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
2259
- const price = this.safeString2(order, 'price', 'p');
2260
- const average = this.safeString2(order, 'avgPrice', 'ap');
2261
- const amount = this.safeString2(order, 'origQty', 'q');
2262
- const filled = this.safeString2(order, 'executedQty', 'z');
2263
2353
  const statusId = this.safeString2(order, 'status', 'X');
2264
2354
  let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
2265
2355
  const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
@@ -2276,11 +2366,6 @@ export default class bingx extends Exchange {
2276
2366
  feeCurrencyCode = market['quote'];
2277
2367
  }
2278
2368
  }
2279
- const fee = {
2280
- 'currency': feeCurrencyCode,
2281
- 'cost': Precise.stringAbs(feeCost),
2282
- };
2283
- const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
2284
2369
  let stopLoss = this.safeValue(order, 'stopLoss');
2285
2370
  let stopLossPrice = undefined;
2286
2371
  if ((stopLoss !== undefined) && (stopLoss !== '')) {
@@ -2306,31 +2391,35 @@ export default class bingx extends Exchange {
2306
2391
  takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
2307
2392
  }
2308
2393
  return this.safeOrder({
2309
- 'info': order,
2310
- 'id': orderId,
2311
- 'clientOrderId': clientOrderId,
2394
+ 'info': info,
2395
+ 'id': this.safeString2(order, 'orderId', 'i'),
2396
+ 'clientOrderId': this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']),
2397
+ 'symbol': this.safeSymbol(marketId, market, '-', marketType),
2312
2398
  'timestamp': timestamp,
2313
2399
  'datetime': this.iso8601(timestamp),
2314
2400
  'lastTradeTimestamp': lastTradeTimestamp,
2315
2401
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
2316
- 'symbol': symbol,
2317
- 'type': type,
2318
- 'timeInForce': undefined,
2402
+ 'type': this.safeStringLower2(order, 'type', 'o'),
2403
+ 'timeInForce': this.safeString(order, 'timeInForce'),
2319
2404
  'postOnly': undefined,
2320
2405
  'side': this.parseOrderSide(side),
2321
- 'price': price,
2406
+ 'price': this.safeString2(order, 'price', 'p'),
2322
2407
  'stopPrice': this.safeNumber(order, 'stopPrice'),
2323
2408
  'triggerPrice': this.safeNumber(order, 'stopPrice'),
2324
2409
  'stopLossPrice': stopLossPrice,
2325
2410
  'takeProfitPrice': takeProfitPrice,
2326
- 'average': average,
2411
+ 'average': this.safeString2(order, 'avgPrice', 'ap'),
2327
2412
  'cost': undefined,
2328
- 'amount': amount,
2329
- 'filled': filled,
2413
+ 'amount': this.safeStringN(order, ['origQty', 'q', 'quantity']),
2414
+ 'filled': this.safeString2(order, 'executedQty', 'z'),
2330
2415
  'remaining': undefined,
2331
2416
  'status': this.parseOrderStatus(statusId),
2332
- 'fee': fee,
2417
+ 'fee': {
2418
+ 'currency': feeCurrencyCode,
2419
+ 'cost': Precise.stringAbs(feeCost),
2420
+ },
2333
2421
  'trades': undefined,
2422
+ 'reduceOnly': this.safeBool(order, 'reduceOnly'),
2334
2423
  }, market);
2335
2424
  }
2336
2425
  parseOrderStatus(status) {
@@ -3839,6 +3928,144 @@ export default class bingx extends Exchange {
3839
3928
  //
3840
3929
  return await this.swapV1PrivatePostPositionSideDual(this.extend(request, params));
3841
3930
  }
3931
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
3932
+ /**
3933
+ * @method
3934
+ * @name bingx#editOrder
3935
+ * @description cancels an order and places a new order
3936
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order // spot
3937
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order // swap
3938
+ * @param {string} id order id
3939
+ * @param {string} symbol unified symbol of the market to create an order in
3940
+ * @param {string} type 'market' or 'limit'
3941
+ * @param {string} side 'buy' or 'sell'
3942
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
3943
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
3944
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3945
+ * @param {string} [params.stopPrice] Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
3946
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
3947
+ * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
3948
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
3949
+ * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
3950
+ *
3951
+ * EXCHANGE SPECIFIC PARAMETERS
3952
+ * @param {string} [params.cancelClientOrderID] the user-defined id of the order to be canceled, 1-40 characters, different orders cannot use the same clientOrderID, only supports a query range of 2 hours
3953
+ * @param {string} [params.cancelRestrictions] cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
3954
+ * @param {string} [params.cancelReplaceMode] STOP_ON_FAILURE - if the cancel order fails, it will not continue to place a new order, ALLOW_FAILURE - regardless of whether the cancel order succeeds or fails, it will continue to place a new order
3955
+ * @param {float} [params.quoteOrderQty] order amount
3956
+ * @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
3957
+ * @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
3958
+ * @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
3959
+ * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
3960
+ * @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
3961
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3962
+ */
3963
+ await this.loadMarkets();
3964
+ const market = this.market(symbol);
3965
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
3966
+ request['cancelOrderId'] = id;
3967
+ request['cancelReplaceMode'] = 'STOP_ON_FAILURE';
3968
+ let response = undefined;
3969
+ if (market['swap']) {
3970
+ response = await this.swapV1PrivatePostTradeCancelReplace(this.extend(request, params));
3971
+ //
3972
+ // {
3973
+ // code: '0',
3974
+ // msg: '',
3975
+ // data: {
3976
+ // cancelResult: 'true',
3977
+ // cancelMsg: '',
3978
+ // cancelResponse: {
3979
+ // cancelClientOrderId: '',
3980
+ // cancelOrderId: '1755336244265705472',
3981
+ // symbol: 'SOL-USDT',
3982
+ // orderId: '1755336244265705472',
3983
+ // side: 'SELL',
3984
+ // positionSide: 'SHORT',
3985
+ // type: 'LIMIT',
3986
+ // origQty: '1',
3987
+ // price: '100.000',
3988
+ // executedQty: '0',
3989
+ // avgPrice: '0.000',
3990
+ // cumQuote: '0',
3991
+ // stopPrice: '',
3992
+ // profit: '0.0000',
3993
+ // commission: '0.000000',
3994
+ // status: 'PENDING',
3995
+ // time: '1707339747860',
3996
+ // updateTime: '1707339747860',
3997
+ // clientOrderId: '',
3998
+ // leverage: '20X',
3999
+ // workingType: 'MARK_PRICE',
4000
+ // onlyOnePosition: false,
4001
+ // reduceOnly: false
4002
+ // },
4003
+ // replaceResult: 'true',
4004
+ // replaceMsg: '',
4005
+ // newOrderResponse: {
4006
+ // orderId: '1755338440612995072',
4007
+ // symbol: 'SOL-USDT',
4008
+ // positionSide: 'SHORT',
4009
+ // side: 'SELL',
4010
+ // type: 'LIMIT',
4011
+ // price: '99',
4012
+ // quantity: '2',
4013
+ // stopPrice: '0',
4014
+ // workingType: 'MARK_PRICE',
4015
+ // clientOrderID: '',
4016
+ // timeInForce: 'GTC',
4017
+ // priceRate: '0',
4018
+ // stopLoss: '',
4019
+ // takeProfit: '',
4020
+ // reduceOnly: false
4021
+ // }
4022
+ // }
4023
+ // }
4024
+ //
4025
+ }
4026
+ else {
4027
+ response = await this.spotV1PrivatePostTradeOrderCancelReplace(this.extend(request, params));
4028
+ //
4029
+ // {
4030
+ // code: '0',
4031
+ // msg: '',
4032
+ // debugMsg: '',
4033
+ // data: {
4034
+ // cancelResult: { code: '0', msg: '', result: true },
4035
+ // openResult: { code: '0', msg: '', result: true },
4036
+ // orderOpenResponse: {
4037
+ // symbol: 'SOL-USDT',
4038
+ // orderId: '1755334007697866752',
4039
+ // transactTime: '1707339214620',
4040
+ // price: '99',
4041
+ // stopPrice: '0',
4042
+ // origQty: '0.2',
4043
+ // executedQty: '0',
4044
+ // cummulativeQuoteQty: '0',
4045
+ // status: 'PENDING',
4046
+ // type: 'LIMIT',
4047
+ // side: 'SELL',
4048
+ // clientOrderID: ''
4049
+ // },
4050
+ // orderCancelResponse: {
4051
+ // symbol: 'SOL-USDT',
4052
+ // orderId: '1755117055251480576',
4053
+ // price: '100',
4054
+ // stopPrice: '0',
4055
+ // origQty: '0.2',
4056
+ // executedQty: '0',
4057
+ // cummulativeQuoteQty: '0',
4058
+ // status: 'CANCELED',
4059
+ // type: 'LIMIT',
4060
+ // side: 'SELL'
4061
+ // }
4062
+ // }
4063
+ // }
4064
+ //
4065
+ }
4066
+ const data = this.safeDict(response, 'data');
4067
+ return this.parseOrder(data, market);
4068
+ }
3842
4069
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3843
4070
  const type = section[0];
3844
4071
  const version = section[1];
@@ -6,7 +6,7 @@ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, Orde
6
6
  */
7
7
  export default class bitfinex extends Exchange {
8
8
  describe(): any;
9
- fetchTransactionFees(codes?: any, params?: {}): Promise<{}>;
9
+ fetchTransactionFees(codes?: string[], params?: {}): Promise<{}>;
10
10
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
11
11
  parseDepositWithdrawFee(fee: any, currency?: Currency): {
12
12
  withdraw: {
@@ -25,7 +25,7 @@ export default class bitfinex extends Exchange {
25
25
  amountToPrecision(symbol: any, amount: any): any;
26
26
  priceToPrecision(symbol: any, price: any): any;
27
27
  fetchBalance(params?: {}): Promise<Balances>;
28
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
28
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
29
29
  parseTransfer(transfer: any, currency?: Currency): {
30
30
  info: any;
31
31
  id: any;
@@ -47,7 +47,7 @@ export default class bitfinex extends Exchange {
47
47
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
48
48
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
49
49
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
50
- editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
50
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
51
51
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
52
52
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
53
53
  parseOrder(order: any, market?: Market): Order;
@@ -22,7 +22,7 @@ export default class bitfinex2 extends Exchange {
22
22
  fetchCurrencies(params?: {}): Promise<{}>;
23
23
  safeNetwork(networkId: any): string;
24
24
  fetchBalance(params?: {}): Promise<Balances>;
25
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
25
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
26
26
  parseTransfer(transfer: any, currency?: Currency): {
27
27
  id: any;
28
28
  timestamp: number;
@@ -171,5 +171,5 @@ export default class bitfinex2 extends Exchange {
171
171
  status: string;
172
172
  };
173
173
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
174
- editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
174
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
175
175
  }
@@ -60,11 +60,11 @@ export default class bitget extends Exchange {
60
60
  parseBalance(balance: any): Balances;
61
61
  parseOrderStatus(status: any): string;
62
62
  parseOrder(order: any, market?: Market): Order;
63
- createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
63
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
64
64
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
65
65
  createOrderRequest(symbol: any, type: any, side: any, amount: number, price?: number, params?: {}): any;
66
66
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
67
- editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
67
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
68
68
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
69
69
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
70
70
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
@@ -159,12 +159,12 @@ export default class bitget extends Exchange {
159
159
  addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
160
160
  fetchLeverage(symbol: string, params?: {}): Promise<any>;
161
161
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
162
- setMarginMode(marginMode: any, symbol?: Str, params?: {}): Promise<any>;
163
- setPositionMode(hedged: any, symbol?: Str, params?: {}): Promise<any>;
162
+ setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
163
+ setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
164
164
  fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
165
165
  parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
166
166
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
167
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
167
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
168
168
  parseTransfer(transfer: any, currency?: Currency): {
169
169
  info: any;
170
170
  id: string;
package/js/src/bitget.js CHANGED
@@ -3952,6 +3952,13 @@ export default class bitget extends Exchange {
3952
3952
  size = this.safeString(order, 'size');
3953
3953
  filled = this.safeString(order, 'baseVolume');
3954
3954
  }
3955
+ let side = this.safeString(order, 'side');
3956
+ const posMode = this.safeString(order, 'posMode');
3957
+ if (posMode === 'hedge_mode' && reduceOnly) {
3958
+ side = (side === 'buy') ? 'sell' : 'buy';
3959
+ // on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
3960
+ // so the side of the reduceOnly order is inversed
3961
+ }
3955
3962
  return this.safeOrder({
3956
3963
  'info': order,
3957
3964
  'id': this.safeString2(order, 'orderId', 'data'),
@@ -3962,7 +3969,7 @@ export default class bitget extends Exchange {
3962
3969
  'lastUpdateTimestamp': updateTimestamp,
3963
3970
  'symbol': market['symbol'],
3964
3971
  'type': this.safeString(order, 'orderType'),
3965
- 'side': this.safeString(order, 'side'),
3972
+ 'side': side,
3966
3973
  'price': price,
3967
3974
  'amount': size,
3968
3975
  'cost': this.safeString2(order, 'quoteVolume', 'quoteSize'),
@@ -4488,7 +4495,7 @@ export default class bitget extends Exchange {
4488
4495
  const takeProfit = this.safeValue(params, 'takeProfit');
4489
4496
  const isStopLoss = stopLoss !== undefined;
4490
4497
  const isTakeProfit = takeProfit !== undefined;
4491
- const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
4498
+ const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', this.numberToString(price));
4492
4499
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'newCallbackRatio');
4493
4500
  const isTrailingPercentOrder = trailingPercent !== undefined;
4494
4501
  if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1) {
@@ -8289,7 +8296,11 @@ export default class bitget extends Exchange {
8289
8296
  }
8290
8297
  else {
8291
8298
  if (Object.keys(params).length) {
8292
- const queryInner = '?' + this.urlencode(this.keysort(params));
8299
+ let queryInner = '?' + this.urlencode(this.keysort(params));
8300
+ // check #21169 pr
8301
+ if (queryInner.indexOf('%24') > -1) {
8302
+ queryInner = queryInner.replace('%24', '$');
8303
+ }
8293
8304
  url += queryInner;
8294
8305
  auth += queryInner;
8295
8306
  }
@@ -64,7 +64,7 @@ export default class bitmart extends Exchange {
64
64
  parseOrder(order: any, market?: Market): Order;
65
65
  parseOrderSide(side: any): string;
66
66
  parseOrderStatusByType(type: any, status: any): string;
67
- createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
67
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
68
68
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
69
69
  createSwapOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): any;
70
70
  createSpotOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): any;
@@ -125,7 +125,7 @@ export default class bitmart extends Exchange {
125
125
  info: any;
126
126
  };
127
127
  fetchIsolatedBorrowRates(params?: {}): Promise<any[]>;
128
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
128
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
129
129
  parseTransferStatus(status: any): string;
130
130
  parseTransferToAccount(type: any): string;
131
131
  parseTransferFromAccount(type: any): string;
@@ -58,7 +58,7 @@ export default class bitmex extends Exchange {
58
58
  parseOrder(order: any, market?: Market): Order;
59
59
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
60
60
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
61
- editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
61
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
62
62
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
63
63
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
64
64
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
@@ -94,7 +94,7 @@ export default class bitmex extends Exchange {
94
94
  datetime: string;
95
95
  };
96
96
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
97
- setMarginMode(marginMode: any, symbol?: Str, params?: {}): Promise<any>;
97
+ setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
98
98
  fetchDepositAddress(code: string, params?: {}): Promise<{
99
99
  currency: string;
100
100
  address: any;
@@ -33,7 +33,7 @@ export default class bitrue extends Exchange {
33
33
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
34
34
  parseOrderStatus(status: any): string;
35
35
  parseOrder(order: any, market?: Market): Order;
36
- createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
36
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
37
37
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
38
38
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
39
39
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -71,7 +71,7 @@ export default class bitrue extends Exchange {
71
71
  status: string;
72
72
  };
73
73
  fetchTransfers(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
74
- transfer(code: string, amount: number, fromAccount: any, toAccount: any, params?: {}): Promise<TransferEntry>;
74
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
75
75
  setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<any>;
76
76
  parseMarginModification(data: any, market?: any): {
77
77
  info: any;
package/js/src/bitso.d.ts CHANGED
@@ -55,7 +55,7 @@ export default class bitso extends Exchange {
55
55
  network: any;
56
56
  info: any;
57
57
  }>;
58
- fetchTransactionFees(codes?: any, params?: {}): Promise<{}>;
58
+ fetchTransactionFees(codes?: string[], params?: {}): Promise<{}>;
59
59
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<{}>;
60
60
  parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): {};
61
61
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;