ccxt 4.2.38__py2.py3-none-any.whl → 4.2.40__py2.py3-none-any.whl

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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (141) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bingx.py +4 -0
  3. ccxt/abstract/coinbase.py +1 -0
  4. ccxt/abstract/coinbasepro.py +1 -0
  5. ccxt/abstract/okx.py +1 -0
  6. ccxt/ascendex.py +31 -27
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/ascendex.py +31 -27
  9. ccxt/async_support/base/exchange.py +19 -7
  10. ccxt/async_support/bigone.py +2 -2
  11. ccxt/async_support/binance.py +478 -188
  12. ccxt/async_support/bingx.py +250 -28
  13. ccxt/async_support/bitfinex.py +3 -3
  14. ccxt/async_support/bitfinex2.py +2 -2
  15. ccxt/async_support/bitget.py +16 -7
  16. ccxt/async_support/bitmart.py +2 -2
  17. ccxt/async_support/bitmex.py +2 -2
  18. ccxt/async_support/bitrue.py +2 -2
  19. ccxt/async_support/bitso.py +19 -3
  20. ccxt/async_support/bitstamp.py +25 -3
  21. ccxt/async_support/bitvavo.py +1 -1
  22. ccxt/async_support/bl3p.py +6 -0
  23. ccxt/async_support/blockchaincom.py +21 -0
  24. ccxt/async_support/blofin.py +2 -2
  25. ccxt/async_support/btcalpha.py +9 -0
  26. ccxt/async_support/btcbox.py +9 -0
  27. ccxt/async_support/btcmarkets.py +19 -0
  28. ccxt/async_support/bybit.py +9 -7
  29. ccxt/async_support/cex.py +1 -1
  30. ccxt/async_support/coinbase.py +20 -9
  31. ccxt/async_support/coinbasepro.py +1 -0
  32. ccxt/async_support/coinex.py +4 -4
  33. ccxt/async_support/coinlist.py +11 -9
  34. ccxt/async_support/coinmetro.py +2 -1
  35. ccxt/async_support/coinone.py +1 -1
  36. ccxt/async_support/delta.py +2 -2
  37. ccxt/async_support/deribit.py +3 -3
  38. ccxt/async_support/digifinex.py +3 -3
  39. ccxt/async_support/exmo.py +2 -2
  40. ccxt/async_support/gate.py +6 -6
  41. ccxt/async_support/hitbtc.py +2 -2
  42. ccxt/async_support/hollaex.py +1 -1
  43. ccxt/async_support/htx.py +3 -3
  44. ccxt/async_support/huobijp.py +1 -1
  45. ccxt/async_support/kraken.py +2 -2
  46. ccxt/async_support/krakenfutures.py +117 -16
  47. ccxt/async_support/kucoin.py +5 -5
  48. ccxt/async_support/kucoinfutures.py +2 -2
  49. ccxt/async_support/latoken.py +1 -1
  50. ccxt/async_support/lbank.py +2 -2
  51. ccxt/async_support/luno.py +2 -2
  52. ccxt/async_support/mexc.py +5 -5
  53. ccxt/async_support/ndax.py +1 -1
  54. ccxt/async_support/novadax.py +1 -1
  55. ccxt/async_support/okcoin.py +2 -2
  56. ccxt/async_support/okx.py +18 -21
  57. ccxt/async_support/paymium.py +2 -2
  58. ccxt/async_support/phemex.py +5 -4
  59. ccxt/async_support/poloniex.py +2 -2
  60. ccxt/async_support/poloniexfutures.py +10 -6
  61. ccxt/async_support/probit.py +1 -1
  62. ccxt/async_support/timex.py +1 -1
  63. ccxt/async_support/upbit.py +1 -1
  64. ccxt/async_support/wavesexchange.py +1 -1
  65. ccxt/async_support/whitebit.py +2 -2
  66. ccxt/async_support/woo.py +4 -4
  67. ccxt/async_support/zonda.py +3 -3
  68. ccxt/base/exchange.py +37 -25
  69. ccxt/bigone.py +2 -2
  70. ccxt/binance.py +478 -188
  71. ccxt/bingx.py +250 -28
  72. ccxt/bitfinex.py +3 -3
  73. ccxt/bitfinex2.py +2 -2
  74. ccxt/bitget.py +16 -7
  75. ccxt/bitmart.py +2 -2
  76. ccxt/bitmex.py +2 -2
  77. ccxt/bitrue.py +2 -2
  78. ccxt/bitso.py +19 -3
  79. ccxt/bitstamp.py +25 -3
  80. ccxt/bitvavo.py +1 -1
  81. ccxt/bl3p.py +6 -0
  82. ccxt/blockchaincom.py +21 -0
  83. ccxt/blofin.py +2 -2
  84. ccxt/btcalpha.py +9 -0
  85. ccxt/btcbox.py +9 -0
  86. ccxt/btcmarkets.py +19 -0
  87. ccxt/bybit.py +9 -7
  88. ccxt/cex.py +1 -1
  89. ccxt/coinbase.py +20 -9
  90. ccxt/coinbasepro.py +1 -0
  91. ccxt/coinex.py +4 -4
  92. ccxt/coinlist.py +11 -9
  93. ccxt/coinmetro.py +2 -1
  94. ccxt/coinone.py +1 -1
  95. ccxt/delta.py +2 -2
  96. ccxt/deribit.py +3 -3
  97. ccxt/digifinex.py +3 -3
  98. ccxt/exmo.py +2 -2
  99. ccxt/gate.py +6 -6
  100. ccxt/hitbtc.py +2 -2
  101. ccxt/hollaex.py +1 -1
  102. ccxt/htx.py +3 -3
  103. ccxt/huobijp.py +1 -1
  104. ccxt/kraken.py +2 -2
  105. ccxt/krakenfutures.py +117 -16
  106. ccxt/kucoin.py +5 -5
  107. ccxt/kucoinfutures.py +2 -2
  108. ccxt/latoken.py +1 -1
  109. ccxt/lbank.py +2 -2
  110. ccxt/luno.py +2 -2
  111. ccxt/mexc.py +5 -5
  112. ccxt/ndax.py +1 -1
  113. ccxt/novadax.py +1 -1
  114. ccxt/okcoin.py +2 -2
  115. ccxt/okx.py +18 -21
  116. ccxt/paymium.py +2 -2
  117. ccxt/phemex.py +5 -4
  118. ccxt/poloniex.py +2 -2
  119. ccxt/poloniexfutures.py +10 -6
  120. ccxt/pro/__init__.py +1 -1
  121. ccxt/pro/bitmart.py +129 -46
  122. ccxt/pro/bitvavo.py +1 -1
  123. ccxt/pro/bybit.py +6 -6
  124. ccxt/pro/cex.py +2 -2
  125. ccxt/pro/coinbase.py +2 -2
  126. ccxt/pro/coinex.py +1 -1
  127. ccxt/pro/lbank.py +1 -1
  128. ccxt/pro/mexc.py +1 -1
  129. ccxt/probit.py +1 -1
  130. ccxt/test/test_async.py +3 -1
  131. ccxt/test/test_sync.py +3 -1
  132. ccxt/timex.py +1 -1
  133. ccxt/upbit.py +1 -1
  134. ccxt/wavesexchange.py +1 -1
  135. ccxt/whitebit.py +2 -2
  136. ccxt/woo.py +4 -4
  137. ccxt/zonda.py +3 -3
  138. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/METADATA +4 -4
  139. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/RECORD +141 -141
  140. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/WHEEL +0 -0
  141. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/top_level.txt +0 -0
@@ -154,6 +154,7 @@ class bingx(Exchange, ImplicitAPI):
154
154
  'trade/order': 3,
155
155
  'trade/cancel': 3,
156
156
  'trade/batchOrders': 3,
157
+ 'trade/order/cancelReplace': 3,
157
158
  'trade/cancelOrders': 3,
158
159
  'trade/cancelOpenOrders': 3,
159
160
  },
@@ -175,12 +176,19 @@ class bingx(Exchange, ImplicitAPI):
175
176
  },
176
177
  'swap': {
177
178
  'v1': {
179
+ 'public': {
180
+ 'get': {
181
+ 'ticker/price': 1,
182
+ },
183
+ },
178
184
  'private': {
179
185
  'get': {
180
186
  'positionSide/dual': 1,
181
187
  'market/markPriceKlines': 1,
188
+ 'trade/batchCancelReplace': 1,
182
189
  },
183
190
  'post': {
191
+ 'trade/cancelReplace': 1,
184
192
  'positionSide/dual': 1,
185
193
  },
186
194
  },
@@ -1646,7 +1654,7 @@ class bingx(Exchange, ImplicitAPI):
1646
1654
  'takeProfitPrice': None,
1647
1655
  })
1648
1656
 
1649
- async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost, params={}):
1657
+ async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1650
1658
  """
1651
1659
  create a market order by providing the symbol, side and cost
1652
1660
  :param str symbol: unified symbol of the market to create an order in
@@ -1658,7 +1666,7 @@ class bingx(Exchange, ImplicitAPI):
1658
1666
  params['quoteOrderQty'] = cost
1659
1667
  return await self.create_order(symbol, 'market', side, cost, None, params)
1660
1668
 
1661
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1669
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1662
1670
  """
1663
1671
  create a market buy order by providing the symbol and cost
1664
1672
  :param str symbol: unified symbol of the market to create an order in
@@ -1669,7 +1677,7 @@ class bingx(Exchange, ImplicitAPI):
1669
1677
  params['quoteOrderQty'] = cost
1670
1678
  return await self.create_order(symbol, 'market', 'buy', cost, None, params)
1671
1679
 
1672
- async def create_market_sell_order_with_cost(self, symbol: str, cost, params={}):
1680
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
1673
1681
  """
1674
1682
  create a market sell order by providing the symbol and cost
1675
1683
  :param str symbol: unified symbol of the market to create an order in
@@ -2117,21 +2125,102 @@ class bingx(Exchange, ImplicitAPI):
2117
2125
  # reduceOnly: False
2118
2126
  # }
2119
2127
  #
2128
+ # editOrder(swap)
2129
+ #
2130
+ # {
2131
+ # cancelResult: 'true',
2132
+ # cancelMsg: '',
2133
+ # cancelResponse: {
2134
+ # cancelClientOrderId: '',
2135
+ # cancelOrderId: '1755336244265705472',
2136
+ # symbol: 'SOL-USDT',
2137
+ # orderId: '1755336244265705472',
2138
+ # side: 'SELL',
2139
+ # positionSide: 'SHORT',
2140
+ # type: 'LIMIT',
2141
+ # origQty: '1',
2142
+ # price: '100.000',
2143
+ # executedQty: '0',
2144
+ # avgPrice: '0.000',
2145
+ # cumQuote: '0',
2146
+ # stopPrice: '',
2147
+ # profit: '0.0000',
2148
+ # commission: '0.000000',
2149
+ # status: 'PENDING',
2150
+ # time: '1707339747860',
2151
+ # updateTime: '1707339747860',
2152
+ # clientOrderId: '',
2153
+ # leverage: '20X',
2154
+ # workingType: 'MARK_PRICE',
2155
+ # onlyOnePosition: False,
2156
+ # reduceOnly: False
2157
+ # },
2158
+ # replaceResult: 'true',
2159
+ # replaceMsg: '',
2160
+ # newOrderResponse: {
2161
+ # orderId: '1755338440612995072',
2162
+ # symbol: 'SOL-USDT',
2163
+ # positionSide: 'SHORT',
2164
+ # side: 'SELL',
2165
+ # type: 'LIMIT',
2166
+ # price: '99',
2167
+ # quantity: '2',
2168
+ # stopPrice: '0',
2169
+ # workingType: 'MARK_PRICE',
2170
+ # clientOrderID: '',
2171
+ # timeInForce: 'GTC',
2172
+ # priceRate: '0',
2173
+ # stopLoss: '',
2174
+ # takeProfit: '',
2175
+ # reduceOnly: False
2176
+ # }
2177
+ # }
2178
+ #
2179
+ # editOrder(spot)
2180
+ #
2181
+ # {
2182
+ # cancelResult: {code: '0', msg: '', result: True},
2183
+ # openResult: {code: '0', msg: '', result: True},
2184
+ # orderOpenResponse: {
2185
+ # symbol: 'SOL-USDT',
2186
+ # orderId: '1755334007697866752',
2187
+ # transactTime: '1707339214620',
2188
+ # price: '99',
2189
+ # stopPrice: '0',
2190
+ # origQty: '0.2',
2191
+ # executedQty: '0',
2192
+ # cummulativeQuoteQty: '0',
2193
+ # status: 'PENDING',
2194
+ # type: 'LIMIT',
2195
+ # side: 'SELL',
2196
+ # clientOrderID: ''
2197
+ # },
2198
+ # orderCancelResponse: {
2199
+ # symbol: 'SOL-USDT',
2200
+ # orderId: '1755117055251480576',
2201
+ # price: '100',
2202
+ # stopPrice: '0',
2203
+ # origQty: '0.2',
2204
+ # executedQty: '0',
2205
+ # cummulativeQuoteQty: '0',
2206
+ # status: 'CANCELED',
2207
+ # type: 'LIMIT',
2208
+ # side: 'SELL'
2209
+ # }
2210
+ # }
2211
+ #
2212
+ info = order
2213
+ newOrder = self.safe_dict_2(order, 'newOrderResponse', 'orderOpenResponse')
2214
+ if newOrder is not None:
2215
+ order = newOrder
2120
2216
  positionSide = self.safe_string_2(order, 'positionSide', 'ps')
2121
2217
  marketType = 'spot' if (positionSide is None) else 'swap'
2122
2218
  marketId = self.safe_string_2(order, 'symbol', 's')
2123
2219
  if market is None:
2124
2220
  market = self.safe_market(marketId, None, None, marketType)
2125
- symbol = self.safe_symbol(marketId, market, '-', marketType)
2126
- orderId = self.safe_string_2(order, 'orderId', 'i')
2127
2221
  side = self.safe_string_lower_2(order, 'side', 'S')
2128
- type = self.safe_string_lower_2(order, 'type', 'o')
2129
2222
  timestamp = self.safe_integer_n(order, ['time', 'transactTime', 'E'])
2130
2223
  lastTradeTimestamp = self.safe_integer_2(order, 'updateTime', 'T')
2131
- price = self.safe_string_2(order, 'price', 'p')
2132
- average = self.safe_string_2(order, 'avgPrice', 'ap')
2133
- amount = self.safe_string_2(order, 'origQty', 'q')
2134
- filled = self.safe_string_2(order, 'executedQty', 'z')
2135
2224
  statusId = self.safe_string_2(order, 'status', 'X')
2136
2225
  feeCurrencyCode = self.safe_string_2(order, 'feeAsset', 'N')
2137
2226
  feeCost = self.safe_string_n(order, ['fee', 'commission', 'n'])
@@ -2143,11 +2232,6 @@ class bingx(Exchange, ImplicitAPI):
2143
2232
  feeCurrencyCode = market['quote']
2144
2233
  else:
2145
2234
  feeCurrencyCode = market['quote']
2146
- fee = {
2147
- 'currency': feeCurrencyCode,
2148
- 'cost': Precise.string_abs(feeCost),
2149
- }
2150
- clientOrderId = self.safe_string_n(order, ['clientOrderID', 'origClientOrderId', 'c'])
2151
2235
  stopLoss = self.safe_value(order, 'stopLoss')
2152
2236
  stopLossPrice = None
2153
2237
  if (stopLoss is not None) and (stopLoss != ''):
@@ -2167,31 +2251,35 @@ class bingx(Exchange, ImplicitAPI):
2167
2251
  takeProfit = self.parse_json(takeProfit)
2168
2252
  takeProfitPrice = self.safe_number(takeProfit, 'stopPrice')
2169
2253
  return self.safe_order({
2170
- 'info': order,
2171
- 'id': orderId,
2172
- 'clientOrderId': clientOrderId,
2254
+ 'info': info,
2255
+ 'id': self.safe_string_2(order, 'orderId', 'i'),
2256
+ 'clientOrderId': self.safe_string_n(order, ['clientOrderID', 'origClientOrderId', 'c']),
2257
+ 'symbol': self.safe_symbol(marketId, market, '-', marketType),
2173
2258
  'timestamp': timestamp,
2174
2259
  'datetime': self.iso8601(timestamp),
2175
2260
  'lastTradeTimestamp': lastTradeTimestamp,
2176
2261
  'lastUpdateTimestamp': self.safe_integer(order, 'updateTime'),
2177
- 'symbol': symbol,
2178
- 'type': type,
2179
- 'timeInForce': None,
2262
+ 'type': self.safe_string_lower_2(order, 'type', 'o'),
2263
+ 'timeInForce': self.safe_string(order, 'timeInForce'),
2180
2264
  'postOnly': None,
2181
2265
  'side': self.parse_order_side(side),
2182
- 'price': price,
2266
+ 'price': self.safe_string_2(order, 'price', 'p'),
2183
2267
  'stopPrice': self.safe_number(order, 'stopPrice'),
2184
2268
  'triggerPrice': self.safe_number(order, 'stopPrice'),
2185
2269
  'stopLossPrice': stopLossPrice,
2186
2270
  'takeProfitPrice': takeProfitPrice,
2187
- 'average': average,
2271
+ 'average': self.safe_string_2(order, 'avgPrice', 'ap'),
2188
2272
  'cost': None,
2189
- 'amount': amount,
2190
- 'filled': filled,
2273
+ 'amount': self.safe_string_n(order, ['origQty', 'q', 'quantity']),
2274
+ 'filled': self.safe_string_2(order, 'executedQty', 'z'),
2191
2275
  'remaining': None,
2192
2276
  'status': self.parse_order_status(statusId),
2193
- 'fee': fee,
2277
+ 'fee': {
2278
+ 'currency': feeCurrencyCode,
2279
+ 'cost': Precise.string_abs(feeCost),
2280
+ },
2194
2281
  'trades': None,
2282
+ 'reduceOnly': self.safe_bool(order, 'reduceOnly'),
2195
2283
  }, market)
2196
2284
 
2197
2285
  def parse_order_status(self, status):
@@ -2683,7 +2771,7 @@ class bingx(Exchange, ImplicitAPI):
2683
2771
  orders = self.safe_value(data, 'orders', [])
2684
2772
  return self.parse_orders(orders, market, since, limit)
2685
2773
 
2686
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2774
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2687
2775
  """
2688
2776
  transfer currency internally between wallets on the same account
2689
2777
  :see: https://bingx-api.github.io/docs/#/spot/account-api.html#User%20Universal%20Transfer
@@ -3561,7 +3649,7 @@ class bingx(Exchange, ImplicitAPI):
3561
3649
  positions.append(position)
3562
3650
  return positions
3563
3651
 
3564
- async def set_position_mode(self, hedged, symbol: Str = None, params={}):
3652
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
3565
3653
  """
3566
3654
  set hedged to True or False for a market
3567
3655
  :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode
@@ -3588,6 +3676,140 @@ class bingx(Exchange, ImplicitAPI):
3588
3676
  #
3589
3677
  return await self.swapV1PrivatePostPositionSideDual(self.extend(request, params))
3590
3678
 
3679
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}) -> Order:
3680
+ """
3681
+ cancels an order and places a new order
3682
+ :see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order # spot
3683
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order # swap
3684
+ :param str id: order id
3685
+ :param str symbol: unified symbol of the market to create an order in
3686
+ :param str type: 'market' or 'limit'
3687
+ :param str side: 'buy' or 'sell'
3688
+ :param float amount: how much of the currency you want to trade in units of the base currency
3689
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
3690
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3691
+ :param str [params.stopPrice]: Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
3692
+ :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
3693
+ :param float [params.takeProfit.triggerPrice]: take profit trigger price
3694
+ :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
3695
+ :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3696
+ *
3697
+ * EXCHANGE SPECIFIC PARAMETERS
3698
+ :param str [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
3699
+ :param str [params.cancelRestrictions]: cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
3700
+ :param str [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
3701
+ :param float [params.quoteOrderQty]: order amount
3702
+ :param str [params.newClientOrderId]: custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
3703
+ :param str [params.positionSide]: *contract only* position direction, required for single position, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
3704
+ :param str [params.reduceOnly]: *contract only* True or False, default=false for single position mode. self parameter is not accepted for both long and short positions mode
3705
+ :param float [params.priceRate]: *contract only* for type TRAILING_STOP_Market, Max = 1
3706
+ :param str [params.workingType]: *contract only* StopPrice trigger price types, MARK_PRICE(default), CONTRACT_PRICE, or INDEX_PRICE
3707
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3708
+ """
3709
+ await self.load_markets()
3710
+ market = self.market(symbol)
3711
+ request = self.create_order_request(symbol, type, side, amount, price, params)
3712
+ request['cancelOrderId'] = id
3713
+ request['cancelReplaceMode'] = 'STOP_ON_FAILURE'
3714
+ response = None
3715
+ if market['swap']:
3716
+ response = await self.swapV1PrivatePostTradeCancelReplace(self.extend(request, params))
3717
+ #
3718
+ # {
3719
+ # code: '0',
3720
+ # msg: '',
3721
+ # data: {
3722
+ # cancelResult: 'true',
3723
+ # cancelMsg: '',
3724
+ # cancelResponse: {
3725
+ # cancelClientOrderId: '',
3726
+ # cancelOrderId: '1755336244265705472',
3727
+ # symbol: 'SOL-USDT',
3728
+ # orderId: '1755336244265705472',
3729
+ # side: 'SELL',
3730
+ # positionSide: 'SHORT',
3731
+ # type: 'LIMIT',
3732
+ # origQty: '1',
3733
+ # price: '100.000',
3734
+ # executedQty: '0',
3735
+ # avgPrice: '0.000',
3736
+ # cumQuote: '0',
3737
+ # stopPrice: '',
3738
+ # profit: '0.0000',
3739
+ # commission: '0.000000',
3740
+ # status: 'PENDING',
3741
+ # time: '1707339747860',
3742
+ # updateTime: '1707339747860',
3743
+ # clientOrderId: '',
3744
+ # leverage: '20X',
3745
+ # workingType: 'MARK_PRICE',
3746
+ # onlyOnePosition: False,
3747
+ # reduceOnly: False
3748
+ # },
3749
+ # replaceResult: 'true',
3750
+ # replaceMsg: '',
3751
+ # newOrderResponse: {
3752
+ # orderId: '1755338440612995072',
3753
+ # symbol: 'SOL-USDT',
3754
+ # positionSide: 'SHORT',
3755
+ # side: 'SELL',
3756
+ # type: 'LIMIT',
3757
+ # price: '99',
3758
+ # quantity: '2',
3759
+ # stopPrice: '0',
3760
+ # workingType: 'MARK_PRICE',
3761
+ # clientOrderID: '',
3762
+ # timeInForce: 'GTC',
3763
+ # priceRate: '0',
3764
+ # stopLoss: '',
3765
+ # takeProfit: '',
3766
+ # reduceOnly: False
3767
+ # }
3768
+ # }
3769
+ # }
3770
+ #
3771
+ else:
3772
+ response = await self.spotV1PrivatePostTradeOrderCancelReplace(self.extend(request, params))
3773
+ #
3774
+ # {
3775
+ # code: '0',
3776
+ # msg: '',
3777
+ # debugMsg: '',
3778
+ # data: {
3779
+ # cancelResult: {code: '0', msg: '', result: True},
3780
+ # openResult: {code: '0', msg: '', result: True},
3781
+ # orderOpenResponse: {
3782
+ # symbol: 'SOL-USDT',
3783
+ # orderId: '1755334007697866752',
3784
+ # transactTime: '1707339214620',
3785
+ # price: '99',
3786
+ # stopPrice: '0',
3787
+ # origQty: '0.2',
3788
+ # executedQty: '0',
3789
+ # cummulativeQuoteQty: '0',
3790
+ # status: 'PENDING',
3791
+ # type: 'LIMIT',
3792
+ # side: 'SELL',
3793
+ # clientOrderID: ''
3794
+ # },
3795
+ # orderCancelResponse: {
3796
+ # symbol: 'SOL-USDT',
3797
+ # orderId: '1755117055251480576',
3798
+ # price: '100',
3799
+ # stopPrice: '0',
3800
+ # origQty: '0.2',
3801
+ # executedQty: '0',
3802
+ # cummulativeQuoteQty: '0',
3803
+ # status: 'CANCELED',
3804
+ # type: 'LIMIT',
3805
+ # side: 'SELL'
3806
+ # }
3807
+ # }
3808
+ # }
3809
+ #
3810
+ data = self.safe_dict(response, 'data')
3811
+ return self.parse_order(data, market)
3812
+
3591
3813
  def sign(self, path, section='public', method='GET', params={}, headers=None, body=None):
3592
3814
  type = section[0]
3593
3815
  version = section[1]
@@ -409,7 +409,7 @@ class bitfinex(Exchange, ImplicitAPI):
409
409
  },
410
410
  })
411
411
 
412
- async def fetch_transaction_fees(self, codes=None, params={}):
412
+ async def fetch_transaction_fees(self, codes: List[str] = None, params={}):
413
413
  """
414
414
  * @deprecated
415
415
  please use fetchDepositWithdrawFees instead
@@ -728,7 +728,7 @@ class bitfinex(Exchange, ImplicitAPI):
728
728
  result[code] = account
729
729
  return self.safe_balance(result)
730
730
 
731
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
731
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
732
732
  """
733
733
  transfer currency internally between wallets on the same account
734
734
  :see: https://docs.bitfinex.com/v1/reference/rest-auth-transfer-between-wallets
@@ -1056,7 +1056,7 @@ class bitfinex(Exchange, ImplicitAPI):
1056
1056
  response = await self.privatePostOrderNew(self.extend(request, params))
1057
1057
  return self.parse_order(response, market)
1058
1058
 
1059
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1059
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1060
1060
  await self.load_markets()
1061
1061
  order = {
1062
1062
  'order_id': int(id),
@@ -864,7 +864,7 @@ class bitfinex2(Exchange, ImplicitAPI):
864
864
  result[code] = account
865
865
  return self.safe_balance(result)
866
866
 
867
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
867
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
868
868
  """
869
869
  transfer currency internally between wallets on the same account
870
870
  :see: https://docs.bitfinex.com/reference/rest-auth-transfer
@@ -3363,7 +3363,7 @@ class bitfinex2(Exchange, ImplicitAPI):
3363
3363
  order = self.safe_list(response, 0)
3364
3364
  return self.parse_order(order, market)
3365
3365
 
3366
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
3366
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
3367
3367
  """
3368
3368
  edit a trade order
3369
3369
  :see: https://docs.bitfinex.com/reference/rest-auth-update-order
@@ -3795,6 +3795,12 @@ class bitget(Exchange, ImplicitAPI):
3795
3795
  else:
3796
3796
  size = self.safe_string(order, 'size')
3797
3797
  filled = self.safe_string(order, 'baseVolume')
3798
+ side = self.safe_string(order, 'side')
3799
+ posMode = self.safe_string(order, 'posMode')
3800
+ if posMode == 'hedge_mode' and reduceOnly:
3801
+ side = 'sell' if (side == 'buy') else 'buy'
3802
+ # 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
3803
+ # so the side of the reduceOnly order is inversed
3798
3804
  return self.safe_order({
3799
3805
  'info': order,
3800
3806
  'id': self.safe_string_2(order, 'orderId', 'data'),
@@ -3805,7 +3811,7 @@ class bitget(Exchange, ImplicitAPI):
3805
3811
  'lastUpdateTimestamp': updateTimestamp,
3806
3812
  'symbol': market['symbol'],
3807
3813
  'type': self.safe_string(order, 'orderType'),
3808
- 'side': self.safe_string(order, 'side'),
3814
+ 'side': side,
3809
3815
  'price': price,
3810
3816
  'amount': size,
3811
3817
  'cost': self.safe_string_2(order, 'quoteVolume', 'quoteSize'),
@@ -3824,7 +3830,7 @@ class bitget(Exchange, ImplicitAPI):
3824
3830
  'trades': None,
3825
3831
  }, market)
3826
3832
 
3827
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
3833
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
3828
3834
  """
3829
3835
  create a market buy order by providing the symbol and cost
3830
3836
  :see: https://www.bitget.com/api-doc/spot/trade/Place-Order
@@ -4194,7 +4200,7 @@ class bitget(Exchange, ImplicitAPI):
4194
4200
  both = self.array_concat(orderInfo, failure)
4195
4201
  return self.parse_orders(both, market)
4196
4202
 
4197
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
4203
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
4198
4204
  """
4199
4205
  edit a trade order
4200
4206
  :see: https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
@@ -4246,7 +4252,7 @@ class bitget(Exchange, ImplicitAPI):
4246
4252
  takeProfit = self.safe_value(params, 'takeProfit')
4247
4253
  isStopLoss = stopLoss is not None
4248
4254
  isTakeProfit = takeProfit is not None
4249
- trailingTriggerPrice = self.safe_string(params, 'trailingTriggerPrice', price)
4255
+ trailingTriggerPrice = self.safe_string(params, 'trailingTriggerPrice', self.number_to_string(price))
4250
4256
  trailingPercent = self.safe_string_2(params, 'trailingPercent', 'newCallbackRatio')
4251
4257
  isTrailingPercentOrder = trailingPercent is not None
4252
4258
  if self.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1:
@@ -6496,7 +6502,7 @@ class bitget(Exchange, ImplicitAPI):
6496
6502
  #
6497
6503
  return response
6498
6504
 
6499
- async def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
6505
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
6500
6506
  """
6501
6507
  set margin mode to 'cross' or 'isolated'
6502
6508
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
@@ -6545,7 +6551,7 @@ class bitget(Exchange, ImplicitAPI):
6545
6551
  #
6546
6552
  return response
6547
6553
 
6548
- async def set_position_mode(self, hedged, symbol: Str = None, params={}):
6554
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
6549
6555
  """
6550
6556
  set hedged to True or False for a market
6551
6557
  :see: https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
@@ -6707,7 +6713,7 @@ class bitget(Exchange, ImplicitAPI):
6707
6713
  data = self.safe_value(response, 'data', [])
6708
6714
  return self.parse_transfers(data, currency, since, limit)
6709
6715
 
6710
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
6716
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
6711
6717
  """
6712
6718
  transfer currency internally between wallets on the same account
6713
6719
  :see: https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
@@ -7712,6 +7718,9 @@ class bitget(Exchange, ImplicitAPI):
7712
7718
  else:
7713
7719
  if params:
7714
7720
  queryInner = '?' + self.urlencode(self.keysort(params))
7721
+ # check #21169 pr
7722
+ if queryInner.find('%24') > -1:
7723
+ queryInner = queryInner.replace('%24', '$')
7715
7724
  url += queryInner
7716
7725
  auth += queryInner
7717
7726
  signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'base64')
@@ -2181,7 +2181,7 @@ class bitmart(Exchange, ImplicitAPI):
2181
2181
  statuses = self.safe_value(statusesByType, type, {})
2182
2182
  return self.safe_string(statuses, status, status)
2183
2183
 
2184
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
2184
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2185
2185
  """
2186
2186
  create a market buy order by providing the symbol and cost
2187
2187
  :see: https://developer-pro.bitmart.com/en/spot/#new-order-v2-signed
@@ -3441,7 +3441,7 @@ class bitmart(Exchange, ImplicitAPI):
3441
3441
  result.append(self.parse_isolated_borrow_rate(symbol))
3442
3442
  return result
3443
3443
 
3444
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
3444
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
3445
3445
  """
3446
3446
  transfer currency internally between wallets on the same account, currently only supports transfer between spot and margin
3447
3447
  :see: https://developer-pro.bitmart.com/en/spot/#margin-asset-transfer-signed
@@ -1827,7 +1827,7 @@ class bitmex(Exchange, ImplicitAPI):
1827
1827
  response = await self.privatePostOrder(self.extend(request, params))
1828
1828
  return self.parse_order(response, market)
1829
1829
 
1830
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1830
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1831
1831
  await self.load_markets()
1832
1832
  request = {}
1833
1833
  trailingAmount = self.safe_string_2(params, 'trailingAmount', 'pegOffsetValue')
@@ -2423,7 +2423,7 @@ class bitmex(Exchange, ImplicitAPI):
2423
2423
  }
2424
2424
  return await self.privatePostPositionLeverage(self.extend(request, params))
2425
2425
 
2426
- async def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
2426
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
2427
2427
  """
2428
2428
  set margin mode to 'cross' or 'isolated'
2429
2429
  :see: https://www.bitmex.com/api/explorer/#not /Position/Position_isolateMargin
@@ -1801,7 +1801,7 @@ class bitrue(Exchange, ImplicitAPI):
1801
1801
  'trades': fills,
1802
1802
  }, market)
1803
1803
 
1804
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1804
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1805
1805
  """
1806
1806
  create a market buy order by providing the symbol and cost
1807
1807
  :see: https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
@@ -2779,7 +2779,7 @@ class bitrue(Exchange, ImplicitAPI):
2779
2779
  data = self.safe_value(response, 'data', {})
2780
2780
  return self.parse_transfers(data, currency, since, limit)
2781
2781
 
2782
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2782
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2783
2783
  """
2784
2784
  transfer currency internally between wallets on the same account
2785
2785
  :see: https://www.bitrue.com/api-docs#new-future-account-transfer-user_data-hmac-sha256