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
ccxt/bingx.py CHANGED
@@ -153,6 +153,7 @@ class bingx(Exchange, ImplicitAPI):
153
153
  'trade/order': 3,
154
154
  'trade/cancel': 3,
155
155
  'trade/batchOrders': 3,
156
+ 'trade/order/cancelReplace': 3,
156
157
  'trade/cancelOrders': 3,
157
158
  'trade/cancelOpenOrders': 3,
158
159
  },
@@ -174,12 +175,19 @@ class bingx(Exchange, ImplicitAPI):
174
175
  },
175
176
  'swap': {
176
177
  'v1': {
178
+ 'public': {
179
+ 'get': {
180
+ 'ticker/price': 1,
181
+ },
182
+ },
177
183
  'private': {
178
184
  'get': {
179
185
  'positionSide/dual': 1,
180
186
  'market/markPriceKlines': 1,
187
+ 'trade/batchCancelReplace': 1,
181
188
  },
182
189
  'post': {
190
+ 'trade/cancelReplace': 1,
183
191
  'positionSide/dual': 1,
184
192
  },
185
193
  },
@@ -1645,7 +1653,7 @@ class bingx(Exchange, ImplicitAPI):
1645
1653
  'takeProfitPrice': None,
1646
1654
  })
1647
1655
 
1648
- def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost, params={}):
1656
+ def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1649
1657
  """
1650
1658
  create a market order by providing the symbol, side and cost
1651
1659
  :param str symbol: unified symbol of the market to create an order in
@@ -1657,7 +1665,7 @@ class bingx(Exchange, ImplicitAPI):
1657
1665
  params['quoteOrderQty'] = cost
1658
1666
  return self.create_order(symbol, 'market', side, cost, None, params)
1659
1667
 
1660
- def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1668
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1661
1669
  """
1662
1670
  create a market buy order by providing the symbol and cost
1663
1671
  :param str symbol: unified symbol of the market to create an order in
@@ -1668,7 +1676,7 @@ class bingx(Exchange, ImplicitAPI):
1668
1676
  params['quoteOrderQty'] = cost
1669
1677
  return self.create_order(symbol, 'market', 'buy', cost, None, params)
1670
1678
 
1671
- def create_market_sell_order_with_cost(self, symbol: str, cost, params={}):
1679
+ def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
1672
1680
  """
1673
1681
  create a market sell order by providing the symbol and cost
1674
1682
  :param str symbol: unified symbol of the market to create an order in
@@ -2116,21 +2124,102 @@ class bingx(Exchange, ImplicitAPI):
2116
2124
  # reduceOnly: False
2117
2125
  # }
2118
2126
  #
2127
+ # editOrder(swap)
2128
+ #
2129
+ # {
2130
+ # cancelResult: 'true',
2131
+ # cancelMsg: '',
2132
+ # cancelResponse: {
2133
+ # cancelClientOrderId: '',
2134
+ # cancelOrderId: '1755336244265705472',
2135
+ # symbol: 'SOL-USDT',
2136
+ # orderId: '1755336244265705472',
2137
+ # side: 'SELL',
2138
+ # positionSide: 'SHORT',
2139
+ # type: 'LIMIT',
2140
+ # origQty: '1',
2141
+ # price: '100.000',
2142
+ # executedQty: '0',
2143
+ # avgPrice: '0.000',
2144
+ # cumQuote: '0',
2145
+ # stopPrice: '',
2146
+ # profit: '0.0000',
2147
+ # commission: '0.000000',
2148
+ # status: 'PENDING',
2149
+ # time: '1707339747860',
2150
+ # updateTime: '1707339747860',
2151
+ # clientOrderId: '',
2152
+ # leverage: '20X',
2153
+ # workingType: 'MARK_PRICE',
2154
+ # onlyOnePosition: False,
2155
+ # reduceOnly: False
2156
+ # },
2157
+ # replaceResult: 'true',
2158
+ # replaceMsg: '',
2159
+ # newOrderResponse: {
2160
+ # orderId: '1755338440612995072',
2161
+ # symbol: 'SOL-USDT',
2162
+ # positionSide: 'SHORT',
2163
+ # side: 'SELL',
2164
+ # type: 'LIMIT',
2165
+ # price: '99',
2166
+ # quantity: '2',
2167
+ # stopPrice: '0',
2168
+ # workingType: 'MARK_PRICE',
2169
+ # clientOrderID: '',
2170
+ # timeInForce: 'GTC',
2171
+ # priceRate: '0',
2172
+ # stopLoss: '',
2173
+ # takeProfit: '',
2174
+ # reduceOnly: False
2175
+ # }
2176
+ # }
2177
+ #
2178
+ # editOrder(spot)
2179
+ #
2180
+ # {
2181
+ # cancelResult: {code: '0', msg: '', result: True},
2182
+ # openResult: {code: '0', msg: '', result: True},
2183
+ # orderOpenResponse: {
2184
+ # symbol: 'SOL-USDT',
2185
+ # orderId: '1755334007697866752',
2186
+ # transactTime: '1707339214620',
2187
+ # price: '99',
2188
+ # stopPrice: '0',
2189
+ # origQty: '0.2',
2190
+ # executedQty: '0',
2191
+ # cummulativeQuoteQty: '0',
2192
+ # status: 'PENDING',
2193
+ # type: 'LIMIT',
2194
+ # side: 'SELL',
2195
+ # clientOrderID: ''
2196
+ # },
2197
+ # orderCancelResponse: {
2198
+ # symbol: 'SOL-USDT',
2199
+ # orderId: '1755117055251480576',
2200
+ # price: '100',
2201
+ # stopPrice: '0',
2202
+ # origQty: '0.2',
2203
+ # executedQty: '0',
2204
+ # cummulativeQuoteQty: '0',
2205
+ # status: 'CANCELED',
2206
+ # type: 'LIMIT',
2207
+ # side: 'SELL'
2208
+ # }
2209
+ # }
2210
+ #
2211
+ info = order
2212
+ newOrder = self.safe_dict_2(order, 'newOrderResponse', 'orderOpenResponse')
2213
+ if newOrder is not None:
2214
+ order = newOrder
2119
2215
  positionSide = self.safe_string_2(order, 'positionSide', 'ps')
2120
2216
  marketType = 'spot' if (positionSide is None) else 'swap'
2121
2217
  marketId = self.safe_string_2(order, 'symbol', 's')
2122
2218
  if market is None:
2123
2219
  market = self.safe_market(marketId, None, None, marketType)
2124
- symbol = self.safe_symbol(marketId, market, '-', marketType)
2125
- orderId = self.safe_string_2(order, 'orderId', 'i')
2126
2220
  side = self.safe_string_lower_2(order, 'side', 'S')
2127
- type = self.safe_string_lower_2(order, 'type', 'o')
2128
2221
  timestamp = self.safe_integer_n(order, ['time', 'transactTime', 'E'])
2129
2222
  lastTradeTimestamp = self.safe_integer_2(order, 'updateTime', 'T')
2130
- price = self.safe_string_2(order, 'price', 'p')
2131
- average = self.safe_string_2(order, 'avgPrice', 'ap')
2132
- amount = self.safe_string_2(order, 'origQty', 'q')
2133
- filled = self.safe_string_2(order, 'executedQty', 'z')
2134
2223
  statusId = self.safe_string_2(order, 'status', 'X')
2135
2224
  feeCurrencyCode = self.safe_string_2(order, 'feeAsset', 'N')
2136
2225
  feeCost = self.safe_string_n(order, ['fee', 'commission', 'n'])
@@ -2142,11 +2231,6 @@ class bingx(Exchange, ImplicitAPI):
2142
2231
  feeCurrencyCode = market['quote']
2143
2232
  else:
2144
2233
  feeCurrencyCode = market['quote']
2145
- fee = {
2146
- 'currency': feeCurrencyCode,
2147
- 'cost': Precise.string_abs(feeCost),
2148
- }
2149
- clientOrderId = self.safe_string_n(order, ['clientOrderID', 'origClientOrderId', 'c'])
2150
2234
  stopLoss = self.safe_value(order, 'stopLoss')
2151
2235
  stopLossPrice = None
2152
2236
  if (stopLoss is not None) and (stopLoss != ''):
@@ -2166,31 +2250,35 @@ class bingx(Exchange, ImplicitAPI):
2166
2250
  takeProfit = self.parse_json(takeProfit)
2167
2251
  takeProfitPrice = self.safe_number(takeProfit, 'stopPrice')
2168
2252
  return self.safe_order({
2169
- 'info': order,
2170
- 'id': orderId,
2171
- 'clientOrderId': clientOrderId,
2253
+ 'info': info,
2254
+ 'id': self.safe_string_2(order, 'orderId', 'i'),
2255
+ 'clientOrderId': self.safe_string_n(order, ['clientOrderID', 'origClientOrderId', 'c']),
2256
+ 'symbol': self.safe_symbol(marketId, market, '-', marketType),
2172
2257
  'timestamp': timestamp,
2173
2258
  'datetime': self.iso8601(timestamp),
2174
2259
  'lastTradeTimestamp': lastTradeTimestamp,
2175
2260
  'lastUpdateTimestamp': self.safe_integer(order, 'updateTime'),
2176
- 'symbol': symbol,
2177
- 'type': type,
2178
- 'timeInForce': None,
2261
+ 'type': self.safe_string_lower_2(order, 'type', 'o'),
2262
+ 'timeInForce': self.safe_string(order, 'timeInForce'),
2179
2263
  'postOnly': None,
2180
2264
  'side': self.parse_order_side(side),
2181
- 'price': price,
2265
+ 'price': self.safe_string_2(order, 'price', 'p'),
2182
2266
  'stopPrice': self.safe_number(order, 'stopPrice'),
2183
2267
  'triggerPrice': self.safe_number(order, 'stopPrice'),
2184
2268
  'stopLossPrice': stopLossPrice,
2185
2269
  'takeProfitPrice': takeProfitPrice,
2186
- 'average': average,
2270
+ 'average': self.safe_string_2(order, 'avgPrice', 'ap'),
2187
2271
  'cost': None,
2188
- 'amount': amount,
2189
- 'filled': filled,
2272
+ 'amount': self.safe_string_n(order, ['origQty', 'q', 'quantity']),
2273
+ 'filled': self.safe_string_2(order, 'executedQty', 'z'),
2190
2274
  'remaining': None,
2191
2275
  'status': self.parse_order_status(statusId),
2192
- 'fee': fee,
2276
+ 'fee': {
2277
+ 'currency': feeCurrencyCode,
2278
+ 'cost': Precise.string_abs(feeCost),
2279
+ },
2193
2280
  'trades': None,
2281
+ 'reduceOnly': self.safe_bool(order, 'reduceOnly'),
2194
2282
  }, market)
2195
2283
 
2196
2284
  def parse_order_status(self, status):
@@ -2682,7 +2770,7 @@ class bingx(Exchange, ImplicitAPI):
2682
2770
  orders = self.safe_value(data, 'orders', [])
2683
2771
  return self.parse_orders(orders, market, since, limit)
2684
2772
 
2685
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2773
+ def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2686
2774
  """
2687
2775
  transfer currency internally between wallets on the same account
2688
2776
  :see: https://bingx-api.github.io/docs/#/spot/account-api.html#User%20Universal%20Transfer
@@ -3560,7 +3648,7 @@ class bingx(Exchange, ImplicitAPI):
3560
3648
  positions.append(position)
3561
3649
  return positions
3562
3650
 
3563
- def set_position_mode(self, hedged, symbol: Str = None, params={}):
3651
+ def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
3564
3652
  """
3565
3653
  set hedged to True or False for a market
3566
3654
  :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode
@@ -3587,6 +3675,140 @@ class bingx(Exchange, ImplicitAPI):
3587
3675
  #
3588
3676
  return self.swapV1PrivatePostPositionSideDual(self.extend(request, params))
3589
3677
 
3678
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}) -> Order:
3679
+ """
3680
+ cancels an order and places a new order
3681
+ :see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order # spot
3682
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order # swap
3683
+ :param str id: order id
3684
+ :param str symbol: unified symbol of the market to create an order in
3685
+ :param str type: 'market' or 'limit'
3686
+ :param str side: 'buy' or 'sell'
3687
+ :param float amount: how much of the currency you want to trade in units of the base currency
3688
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
3689
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3690
+ :param str [params.stopPrice]: Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
3691
+ :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
3692
+ :param float [params.takeProfit.triggerPrice]: take profit trigger price
3693
+ :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
3694
+ :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3695
+ *
3696
+ * EXCHANGE SPECIFIC PARAMETERS
3697
+ :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
3698
+ :param str [params.cancelRestrictions]: cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
3699
+ :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
3700
+ :param float [params.quoteOrderQty]: order amount
3701
+ :param str [params.newClientOrderId]: custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
3702
+ :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
3703
+ :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
3704
+ :param float [params.priceRate]: *contract only* for type TRAILING_STOP_Market, Max = 1
3705
+ :param str [params.workingType]: *contract only* StopPrice trigger price types, MARK_PRICE(default), CONTRACT_PRICE, or INDEX_PRICE
3706
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3707
+ """
3708
+ self.load_markets()
3709
+ market = self.market(symbol)
3710
+ request = self.create_order_request(symbol, type, side, amount, price, params)
3711
+ request['cancelOrderId'] = id
3712
+ request['cancelReplaceMode'] = 'STOP_ON_FAILURE'
3713
+ response = None
3714
+ if market['swap']:
3715
+ response = self.swapV1PrivatePostTradeCancelReplace(self.extend(request, params))
3716
+ #
3717
+ # {
3718
+ # code: '0',
3719
+ # msg: '',
3720
+ # data: {
3721
+ # cancelResult: 'true',
3722
+ # cancelMsg: '',
3723
+ # cancelResponse: {
3724
+ # cancelClientOrderId: '',
3725
+ # cancelOrderId: '1755336244265705472',
3726
+ # symbol: 'SOL-USDT',
3727
+ # orderId: '1755336244265705472',
3728
+ # side: 'SELL',
3729
+ # positionSide: 'SHORT',
3730
+ # type: 'LIMIT',
3731
+ # origQty: '1',
3732
+ # price: '100.000',
3733
+ # executedQty: '0',
3734
+ # avgPrice: '0.000',
3735
+ # cumQuote: '0',
3736
+ # stopPrice: '',
3737
+ # profit: '0.0000',
3738
+ # commission: '0.000000',
3739
+ # status: 'PENDING',
3740
+ # time: '1707339747860',
3741
+ # updateTime: '1707339747860',
3742
+ # clientOrderId: '',
3743
+ # leverage: '20X',
3744
+ # workingType: 'MARK_PRICE',
3745
+ # onlyOnePosition: False,
3746
+ # reduceOnly: False
3747
+ # },
3748
+ # replaceResult: 'true',
3749
+ # replaceMsg: '',
3750
+ # newOrderResponse: {
3751
+ # orderId: '1755338440612995072',
3752
+ # symbol: 'SOL-USDT',
3753
+ # positionSide: 'SHORT',
3754
+ # side: 'SELL',
3755
+ # type: 'LIMIT',
3756
+ # price: '99',
3757
+ # quantity: '2',
3758
+ # stopPrice: '0',
3759
+ # workingType: 'MARK_PRICE',
3760
+ # clientOrderID: '',
3761
+ # timeInForce: 'GTC',
3762
+ # priceRate: '0',
3763
+ # stopLoss: '',
3764
+ # takeProfit: '',
3765
+ # reduceOnly: False
3766
+ # }
3767
+ # }
3768
+ # }
3769
+ #
3770
+ else:
3771
+ response = self.spotV1PrivatePostTradeOrderCancelReplace(self.extend(request, params))
3772
+ #
3773
+ # {
3774
+ # code: '0',
3775
+ # msg: '',
3776
+ # debugMsg: '',
3777
+ # data: {
3778
+ # cancelResult: {code: '0', msg: '', result: True},
3779
+ # openResult: {code: '0', msg: '', result: True},
3780
+ # orderOpenResponse: {
3781
+ # symbol: 'SOL-USDT',
3782
+ # orderId: '1755334007697866752',
3783
+ # transactTime: '1707339214620',
3784
+ # price: '99',
3785
+ # stopPrice: '0',
3786
+ # origQty: '0.2',
3787
+ # executedQty: '0',
3788
+ # cummulativeQuoteQty: '0',
3789
+ # status: 'PENDING',
3790
+ # type: 'LIMIT',
3791
+ # side: 'SELL',
3792
+ # clientOrderID: ''
3793
+ # },
3794
+ # orderCancelResponse: {
3795
+ # symbol: 'SOL-USDT',
3796
+ # orderId: '1755117055251480576',
3797
+ # price: '100',
3798
+ # stopPrice: '0',
3799
+ # origQty: '0.2',
3800
+ # executedQty: '0',
3801
+ # cummulativeQuoteQty: '0',
3802
+ # status: 'CANCELED',
3803
+ # type: 'LIMIT',
3804
+ # side: 'SELL'
3805
+ # }
3806
+ # }
3807
+ # }
3808
+ #
3809
+ data = self.safe_dict(response, 'data')
3810
+ return self.parse_order(data, market)
3811
+
3590
3812
  def sign(self, path, section='public', method='GET', params={}, headers=None, body=None):
3591
3813
  type = section[0]
3592
3814
  version = section[1]
ccxt/bitfinex.py CHANGED
@@ -409,7 +409,7 @@ class bitfinex(Exchange, ImplicitAPI):
409
409
  },
410
410
  })
411
411
 
412
- def fetch_transaction_fees(self, codes=None, params={}):
412
+ 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
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
731
+ 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 = self.privatePostOrderNew(self.extend(request, params))
1057
1057
  return self.parse_order(response, market)
1058
1058
 
1059
- def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1059
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1060
1060
  self.load_markets()
1061
1061
  order = {
1062
1062
  'order_id': int(id),
ccxt/bitfinex2.py CHANGED
@@ -864,7 +864,7 @@ class bitfinex2(Exchange, ImplicitAPI):
864
864
  result[code] = account
865
865
  return self.safe_balance(result)
866
866
 
867
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
867
+ 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
- def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
3366
+ 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
ccxt/bitget.py CHANGED
@@ -3794,6 +3794,12 @@ class bitget(Exchange, ImplicitAPI):
3794
3794
  else:
3795
3795
  size = self.safe_string(order, 'size')
3796
3796
  filled = self.safe_string(order, 'baseVolume')
3797
+ side = self.safe_string(order, 'side')
3798
+ posMode = self.safe_string(order, 'posMode')
3799
+ if posMode == 'hedge_mode' and reduceOnly:
3800
+ side = 'sell' if (side == 'buy') else 'buy'
3801
+ # 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
3802
+ # so the side of the reduceOnly order is inversed
3797
3803
  return self.safe_order({
3798
3804
  'info': order,
3799
3805
  'id': self.safe_string_2(order, 'orderId', 'data'),
@@ -3804,7 +3810,7 @@ class bitget(Exchange, ImplicitAPI):
3804
3810
  'lastUpdateTimestamp': updateTimestamp,
3805
3811
  'symbol': market['symbol'],
3806
3812
  'type': self.safe_string(order, 'orderType'),
3807
- 'side': self.safe_string(order, 'side'),
3813
+ 'side': side,
3808
3814
  'price': price,
3809
3815
  'amount': size,
3810
3816
  'cost': self.safe_string_2(order, 'quoteVolume', 'quoteSize'),
@@ -3823,7 +3829,7 @@ class bitget(Exchange, ImplicitAPI):
3823
3829
  'trades': None,
3824
3830
  }, market)
3825
3831
 
3826
- def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
3832
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
3827
3833
  """
3828
3834
  create a market buy order by providing the symbol and cost
3829
3835
  :see: https://www.bitget.com/api-doc/spot/trade/Place-Order
@@ -4193,7 +4199,7 @@ class bitget(Exchange, ImplicitAPI):
4193
4199
  both = self.array_concat(orderInfo, failure)
4194
4200
  return self.parse_orders(both, market)
4195
4201
 
4196
- def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
4202
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
4197
4203
  """
4198
4204
  edit a trade order
4199
4205
  :see: https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
@@ -4245,7 +4251,7 @@ class bitget(Exchange, ImplicitAPI):
4245
4251
  takeProfit = self.safe_value(params, 'takeProfit')
4246
4252
  isStopLoss = stopLoss is not None
4247
4253
  isTakeProfit = takeProfit is not None
4248
- trailingTriggerPrice = self.safe_string(params, 'trailingTriggerPrice', price)
4254
+ trailingTriggerPrice = self.safe_string(params, 'trailingTriggerPrice', self.number_to_string(price))
4249
4255
  trailingPercent = self.safe_string_2(params, 'trailingPercent', 'newCallbackRatio')
4250
4256
  isTrailingPercentOrder = trailingPercent is not None
4251
4257
  if self.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1:
@@ -6495,7 +6501,7 @@ class bitget(Exchange, ImplicitAPI):
6495
6501
  #
6496
6502
  return response
6497
6503
 
6498
- def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
6504
+ def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
6499
6505
  """
6500
6506
  set margin mode to 'cross' or 'isolated'
6501
6507
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
@@ -6544,7 +6550,7 @@ class bitget(Exchange, ImplicitAPI):
6544
6550
  #
6545
6551
  return response
6546
6552
 
6547
- def set_position_mode(self, hedged, symbol: Str = None, params={}):
6553
+ def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
6548
6554
  """
6549
6555
  set hedged to True or False for a market
6550
6556
  :see: https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
@@ -6706,7 +6712,7 @@ class bitget(Exchange, ImplicitAPI):
6706
6712
  data = self.safe_value(response, 'data', [])
6707
6713
  return self.parse_transfers(data, currency, since, limit)
6708
6714
 
6709
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
6715
+ def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
6710
6716
  """
6711
6717
  transfer currency internally between wallets on the same account
6712
6718
  :see: https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
@@ -7711,6 +7717,9 @@ class bitget(Exchange, ImplicitAPI):
7711
7717
  else:
7712
7718
  if params:
7713
7719
  queryInner = '?' + self.urlencode(self.keysort(params))
7720
+ # check #21169 pr
7721
+ if queryInner.find('%24') > -1:
7722
+ queryInner = queryInner.replace('%24', '$')
7714
7723
  url += queryInner
7715
7724
  auth += queryInner
7716
7725
  signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'base64')
ccxt/bitmart.py CHANGED
@@ -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
- def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
2184
+ 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
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
3444
+ 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
ccxt/bitmex.py CHANGED
@@ -1827,7 +1827,7 @@ class bitmex(Exchange, ImplicitAPI):
1827
1827
  response = self.privatePostOrder(self.extend(request, params))
1828
1828
  return self.parse_order(response, market)
1829
1829
 
1830
- def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1830
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1831
1831
  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 self.privatePostPositionLeverage(self.extend(request, params))
2425
2425
 
2426
- def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
2426
+ 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
ccxt/bitrue.py CHANGED
@@ -1800,7 +1800,7 @@ class bitrue(Exchange, ImplicitAPI):
1800
1800
  'trades': fills,
1801
1801
  }, market)
1802
1802
 
1803
- def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1803
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1804
1804
  """
1805
1805
  create a market buy order by providing the symbol and cost
1806
1806
  :see: https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
@@ -2778,7 +2778,7 @@ class bitrue(Exchange, ImplicitAPI):
2778
2778
  data = self.safe_value(response, 'data', {})
2779
2779
  return self.parse_transfers(data, currency, since, limit)
2780
2780
 
2781
- def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2781
+ def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2782
2782
  """
2783
2783
  transfer currency internally between wallets on the same account
2784
2784
  :see: https://www.bitrue.com/api-docs#new-future-account-transfer-user_data-hmac-sha256