ccxt 4.3.4__py2.py3-none-any.whl → 4.3.6__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.
Files changed (55) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +1 -0
  3. ccxt/abstract/binancecoinm.py +1 -0
  4. ccxt/abstract/binanceus.py +1 -0
  5. ccxt/abstract/binanceusdm.py +1 -0
  6. ccxt/abstract/bingx.py +1 -0
  7. ccxt/abstract/whitebit.py +22 -1
  8. ccxt/abstract/woo.py +1 -0
  9. ccxt/async_support/__init__.py +1 -1
  10. ccxt/async_support/base/exchange.py +227 -36
  11. ccxt/async_support/binance.py +21 -14
  12. ccxt/async_support/bingx.py +40 -0
  13. ccxt/async_support/bitmex.py +22 -0
  14. ccxt/async_support/bybit.py +81 -1
  15. ccxt/async_support/coinbase.py +4 -4
  16. ccxt/async_support/coinex.py +29 -32
  17. ccxt/async_support/cryptocom.py +30 -1
  18. ccxt/async_support/htx.py +26 -0
  19. ccxt/async_support/hyperliquid.py +37 -0
  20. ccxt/async_support/kraken.py +27 -0
  21. ccxt/async_support/krakenfutures.py +26 -0
  22. ccxt/async_support/kucoin.py +52 -4
  23. ccxt/async_support/kucoinfutures.py +2 -2
  24. ccxt/async_support/okx.py +104 -1
  25. ccxt/async_support/whitebit.py +149 -2
  26. ccxt/async_support/woo.py +27 -0
  27. ccxt/base/exchange.py +233 -4
  28. ccxt/binance.py +21 -14
  29. ccxt/bingx.py +40 -0
  30. ccxt/bitmex.py +22 -0
  31. ccxt/bybit.py +81 -1
  32. ccxt/coinbase.py +4 -4
  33. ccxt/coinex.py +29 -32
  34. ccxt/cryptocom.py +30 -1
  35. ccxt/htx.py +26 -0
  36. ccxt/hyperliquid.py +37 -0
  37. ccxt/kraken.py +27 -0
  38. ccxt/krakenfutures.py +26 -0
  39. ccxt/kucoin.py +52 -4
  40. ccxt/kucoinfutures.py +2 -2
  41. ccxt/okx.py +104 -1
  42. ccxt/pro/__init__.py +1 -1
  43. ccxt/pro/binance.py +410 -73
  44. ccxt/pro/bitget.py +1 -1
  45. ccxt/pro/cex.py +1 -1
  46. ccxt/pro/lbank.py +1 -1
  47. ccxt/pro/woo.py +0 -1
  48. ccxt/test/test_async.py +17 -17
  49. ccxt/test/test_sync.py +17 -17
  50. ccxt/whitebit.py +149 -2
  51. ccxt/woo.py +27 -0
  52. {ccxt-4.3.4.dist-info → ccxt-4.3.6.dist-info}/METADATA +4 -4
  53. {ccxt-4.3.4.dist-info → ccxt-4.3.6.dist-info}/RECORD +55 -55
  54. {ccxt-4.3.4.dist-info → ccxt-4.3.6.dist-info}/WHEEL +0 -0
  55. {ccxt-4.3.4.dist-info → ccxt-4.3.6.dist-info}/top_level.txt +0 -0
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.4'
7
+ __version__ = '4.3.6'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -3735,6 +3735,9 @@ class Exchange(object):
3735
3735
  def fetch_position(self, symbol: str, params={}):
3736
3736
  raise NotSupported(self.id + ' fetchPosition() is not supported yet')
3737
3737
 
3738
+ def fetch_position_ws(self, symbol: str, params={}):
3739
+ raise NotSupported(self.id + ' fetchPositionWs() is not supported yet')
3740
+
3738
3741
  def watch_position(self, symbol: Str = None, params={}):
3739
3742
  raise NotSupported(self.id + ' watchPosition() is not supported yet')
3740
3743
 
@@ -3753,9 +3756,21 @@ class Exchange(object):
3753
3756
  """
3754
3757
  raise NotSupported(self.id + ' fetchPositionsForSymbol() is not supported yet')
3755
3758
 
3759
+ def fetch_positions_for_symbol_ws(self, symbol: str, params={}):
3760
+ """
3761
+ fetches all open positions for specific symbol, unlike fetchPositions(which is designed to work with multiple symbols) so self method might be preffered for one-market position, because of less rate-limit consumption and speed
3762
+ :param str symbol: unified market symbol
3763
+ :param dict params: extra parameters specific to the endpoint
3764
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>` with maximum 3 items - possible one position for "one-way" mode, and possible two positions(long & short) for "two-way"(a.k.a. hedge) mode
3765
+ """
3766
+ raise NotSupported(self.id + ' fetchPositionsForSymbol() is not supported yet')
3767
+
3756
3768
  def fetch_positions(self, symbols: List[str] = None, params={}):
3757
3769
  raise NotSupported(self.id + ' fetchPositions() is not supported yet')
3758
3770
 
3771
+ def fetch_positions_ws(self, symbols: List[str] = None, params={}):
3772
+ raise NotSupported(self.id + ' fetchPositions() is not supported yet')
3773
+
3759
3774
  def fetch_positions_risk(self, symbols: List[str] = None, params={}):
3760
3775
  raise NotSupported(self.id + ' fetchPositionsRisk() is not supported yet')
3761
3776
 
@@ -4069,12 +4084,29 @@ class Exchange(object):
4069
4084
  else:
4070
4085
  raise NotSupported(self.id + ' fetchTicker() is not supported yet')
4071
4086
 
4087
+ def fetch_ticker_ws(self, symbol: str, params={}):
4088
+ if self.has['fetchTickersWs']:
4089
+ self.load_markets()
4090
+ market = self.market(symbol)
4091
+ symbol = market['symbol']
4092
+ tickers = self.fetchTickerWs(symbol, params)
4093
+ ticker = self.safe_dict(tickers, symbol)
4094
+ if ticker is None:
4095
+ raise NullResponse(self.id + ' fetchTickers() could not find a ticker for ' + symbol)
4096
+ else:
4097
+ return ticker
4098
+ else:
4099
+ raise NotSupported(self.id + ' fetchTicker() is not supported yet')
4100
+
4072
4101
  def watch_ticker(self, symbol: str, params={}):
4073
4102
  raise NotSupported(self.id + ' watchTicker() is not supported yet')
4074
4103
 
4075
4104
  def fetch_tickers(self, symbols: List[str] = None, params={}):
4076
4105
  raise NotSupported(self.id + ' fetchTickers() is not supported yet')
4077
4106
 
4107
+ def fetch_tickers_ws(self, symbols: List[str] = None, params={}):
4108
+ raise NotSupported(self.id + ' fetchTickers() is not supported yet')
4109
+
4078
4110
  def fetch_order_books(self, symbols: List[str] = None, limit: Int = None, params={}):
4079
4111
  raise NotSupported(self.id + ' fetchOrderBooks() is not supported yet')
4080
4112
 
@@ -4124,6 +4156,28 @@ class Exchange(object):
4124
4156
  return self.create_order(symbol, type, side, amount, price, params)
4125
4157
  raise NotSupported(self.id + ' createTrailingAmountOrder() is not supported yet')
4126
4158
 
4159
+ def create_trailing_amount_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingAmount=None, trailingTriggerPrice=None, params={}):
4160
+ """
4161
+ create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
4162
+ :param str symbol: unified symbol of the market to create an order in
4163
+ :param str type: 'market' or 'limit'
4164
+ :param str side: 'buy' or 'sell'
4165
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
4166
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
4167
+ :param float trailingAmount: the quote amount to trail away from the current market price
4168
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
4169
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4170
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4171
+ """
4172
+ if trailingAmount is None:
4173
+ raise ArgumentsRequired(self.id + ' createTrailingAmountOrderWs() requires a trailingAmount argument')
4174
+ params['trailingAmount'] = trailingAmount
4175
+ if trailingTriggerPrice is not None:
4176
+ params['trailingTriggerPrice'] = trailingTriggerPrice
4177
+ if self.has['createTrailingAmountOrderWs']:
4178
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4179
+ raise NotSupported(self.id + ' createTrailingAmountOrderWs() is not supported yet')
4180
+
4127
4181
  def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}):
4128
4182
  """
4129
4183
  create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
@@ -4146,6 +4200,28 @@ class Exchange(object):
4146
4200
  return self.create_order(symbol, type, side, amount, price, params)
4147
4201
  raise NotSupported(self.id + ' createTrailingPercentOrder() is not supported yet')
4148
4202
 
4203
+ def create_trailing_percent_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}):
4204
+ """
4205
+ create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
4206
+ :param str symbol: unified symbol of the market to create an order in
4207
+ :param str type: 'market' or 'limit'
4208
+ :param str side: 'buy' or 'sell'
4209
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
4210
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
4211
+ :param float trailingPercent: the percent to trail away from the current market price
4212
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
4213
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4214
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4215
+ """
4216
+ if trailingPercent is None:
4217
+ raise ArgumentsRequired(self.id + ' createTrailingPercentOrderWs() requires a trailingPercent argument')
4218
+ params['trailingPercent'] = trailingPercent
4219
+ if trailingTriggerPrice is not None:
4220
+ params['trailingTriggerPrice'] = trailingTriggerPrice
4221
+ if self.has['createTrailingPercentOrderWs']:
4222
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4223
+ raise NotSupported(self.id + ' createTrailingPercentOrderWs() is not supported yet')
4224
+
4149
4225
  def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
4150
4226
  """
4151
4227
  create a market order by providing the symbol, side and cost
@@ -4183,6 +4259,19 @@ class Exchange(object):
4183
4259
  return self.create_order(symbol, 'market', 'sell', cost, 1, params)
4184
4260
  raise NotSupported(self.id + ' createMarketSellOrderWithCost() is not supported yet')
4185
4261
 
4262
+ def create_market_order_with_cost_ws(self, symbol: str, side: OrderSide, cost: float, params={}):
4263
+ """
4264
+ create a market order by providing the symbol, side and cost
4265
+ :param str symbol: unified symbol of the market to create an order in
4266
+ :param str side: 'buy' or 'sell'
4267
+ :param float cost: how much you want to trade in units of the quote currency
4268
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4269
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4270
+ """
4271
+ if self.has['createMarketOrderWithCostWs'] or (self.has['createMarketBuyOrderWithCostWs'] and self.has['createMarketSellOrderWithCostWs']):
4272
+ return self.createOrderWs(symbol, 'market', side, cost, 1, params)
4273
+ raise NotSupported(self.id + ' createMarketOrderWithCostWs() is not supported yet')
4274
+
4186
4275
  def create_trigger_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, triggerPrice: Num = None, params={}):
4187
4276
  """
4188
4277
  create a trigger stop order(type 1)
@@ -4202,6 +4291,25 @@ class Exchange(object):
4202
4291
  return self.create_order(symbol, type, side, amount, price, params)
4203
4292
  raise NotSupported(self.id + ' createTriggerOrder() is not supported yet')
4204
4293
 
4294
+ def create_trigger_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, triggerPrice: Num = None, params={}):
4295
+ """
4296
+ create a trigger stop order(type 1)
4297
+ :param str symbol: unified symbol of the market to create an order in
4298
+ :param str type: 'market' or 'limit'
4299
+ :param str side: 'buy' or 'sell'
4300
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
4301
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
4302
+ :param float triggerPrice: the price to trigger the stop order, in units of the quote currency
4303
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4304
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4305
+ """
4306
+ if triggerPrice is None:
4307
+ raise ArgumentsRequired(self.id + ' createTriggerOrderWs() requires a triggerPrice argument')
4308
+ params['triggerPrice'] = triggerPrice
4309
+ if self.has['createTriggerOrderWs']:
4310
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4311
+ raise NotSupported(self.id + ' createTriggerOrderWs() is not supported yet')
4312
+
4205
4313
  def create_stop_loss_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopLossPrice: Num = None, params={}):
4206
4314
  """
4207
4315
  create a trigger stop loss order(type 2)
@@ -4221,6 +4329,25 @@ class Exchange(object):
4221
4329
  return self.create_order(symbol, type, side, amount, price, params)
4222
4330
  raise NotSupported(self.id + ' createStopLossOrder() is not supported yet')
4223
4331
 
4332
+ def create_stop_loss_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopLossPrice: Num = None, params={}):
4333
+ """
4334
+ create a trigger stop loss order(type 2)
4335
+ :param str symbol: unified symbol of the market to create an order in
4336
+ :param str type: 'market' or 'limit'
4337
+ :param str side: 'buy' or 'sell'
4338
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
4339
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
4340
+ :param float stopLossPrice: the price to trigger the stop loss order, in units of the quote currency
4341
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4342
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4343
+ """
4344
+ if stopLossPrice is None:
4345
+ raise ArgumentsRequired(self.id + ' createStopLossOrderWs() requires a stopLossPrice argument')
4346
+ params['stopLossPrice'] = stopLossPrice
4347
+ if self.has['createStopLossOrderWs']:
4348
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4349
+ raise NotSupported(self.id + ' createStopLossOrderWs() is not supported yet')
4350
+
4224
4351
  def create_take_profit_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfitPrice: Num = None, params={}):
4225
4352
  """
4226
4353
  create a trigger take profit order(type 2)
@@ -4240,6 +4367,25 @@ class Exchange(object):
4240
4367
  return self.create_order(symbol, type, side, amount, price, params)
4241
4368
  raise NotSupported(self.id + ' createTakeProfitOrder() is not supported yet')
4242
4369
 
4370
+ def create_take_profit_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfitPrice: Num = None, params={}):
4371
+ """
4372
+ create a trigger take profit order(type 2)
4373
+ :param str symbol: unified symbol of the market to create an order in
4374
+ :param str type: 'market' or 'limit'
4375
+ :param str side: 'buy' or 'sell'
4376
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
4377
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
4378
+ :param float takeProfitPrice: the price to trigger the take profit order, in units of the quote currency
4379
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4380
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4381
+ """
4382
+ if takeProfitPrice is None:
4383
+ raise ArgumentsRequired(self.id + ' createTakeProfitOrderWs() requires a takeProfitPrice argument')
4384
+ params['takeProfitPrice'] = takeProfitPrice
4385
+ if self.has['createTakeProfitOrderWs']:
4386
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4387
+ raise NotSupported(self.id + ' createTakeProfitOrderWs() is not supported yet')
4388
+
4243
4389
  def create_order_with_take_profit_and_stop_loss(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfit: Num = None, stopLoss: Num = None, params={}):
4244
4390
  """
4245
4391
  create an order with a stop loss or take profit attached(type 3)
@@ -4261,6 +4407,12 @@ class Exchange(object):
4261
4407
  :param float [params.stopLossAmount]: *not available on all exchanges* the amount for a stop loss
4262
4408
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4263
4409
  """
4410
+ params = self.set_take_profit_and_stop_loss_params(symbol, type, side, amount, price, takeProfit, stopLoss, params)
4411
+ if self.has['createOrderWithTakeProfitAndStopLoss']:
4412
+ return self.create_order(symbol, type, side, amount, price, params)
4413
+ raise NotSupported(self.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet')
4414
+
4415
+ def set_take_profit_and_stop_loss_params(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfit: Num = None, stopLoss: Num = None, params={}):
4264
4416
  if (takeProfit is None) and (stopLoss is None):
4265
4417
  raise ArgumentsRequired(self.id + ' createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument')
4266
4418
  if takeProfit is not None:
@@ -4296,9 +4448,33 @@ class Exchange(object):
4296
4448
  if stopLossAmount is not None:
4297
4449
  params['stopLoss']['amount'] = self.parse_to_numeric(stopLossAmount)
4298
4450
  params = self.omit(params, ['takeProfitType', 'takeProfitPriceType', 'takeProfitLimitPrice', 'takeProfitAmount', 'stopLossType', 'stopLossPriceType', 'stopLossLimitPrice', 'stopLossAmount'])
4299
- if self.has['createOrderWithTakeProfitAndStopLoss']:
4300
- return self.create_order(symbol, type, side, amount, price, params)
4301
- raise NotSupported(self.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet')
4451
+ return params
4452
+
4453
+ def create_order_with_take_profit_and_stop_loss_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfit: Num = None, stopLoss: Num = None, params={}):
4454
+ """
4455
+ create an order with a stop loss or take profit attached(type 3)
4456
+ :param str symbol: unified symbol of the market to create an order in
4457
+ :param str type: 'market' or 'limit'
4458
+ :param str side: 'buy' or 'sell'
4459
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
4460
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
4461
+ :param float [takeProfit]: the take profit price, in units of the quote currency
4462
+ :param float [stopLoss]: the stop loss price, in units of the quote currency
4463
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4464
+ :param str [params.takeProfitType]: *not available on all exchanges* 'limit' or 'market'
4465
+ :param str [params.stopLossType]: *not available on all exchanges* 'limit' or 'market'
4466
+ :param str [params.takeProfitPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
4467
+ :param str [params.stopLossPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
4468
+ :param float [params.takeProfitLimitPrice]: *not available on all exchanges* limit price for a limit take profit order
4469
+ :param float [params.stopLossLimitPrice]: *not available on all exchanges* stop loss for a limit stop loss order
4470
+ :param float [params.takeProfitAmount]: *not available on all exchanges* the amount for a take profit
4471
+ :param float [params.stopLossAmount]: *not available on all exchanges* the amount for a stop loss
4472
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4473
+ """
4474
+ params = self.set_take_profit_and_stop_loss_params(symbol, type, side, amount, price, takeProfit, stopLoss, params)
4475
+ if self.has['createOrderWithTakeProfitAndStopLossWs']:
4476
+ return self.createOrderWs(symbol, type, side, amount, price, params)
4477
+ raise NotSupported(self.id + ' createOrderWithTakeProfitAndStopLossWs() is not supported yet')
4302
4478
 
4303
4479
  def create_orders(self, orders: List[OrderRequest], params={}):
4304
4480
  raise NotSupported(self.id + ' createOrders() is not supported yet')
@@ -4318,6 +4494,9 @@ class Exchange(object):
4318
4494
  def cancel_all_orders(self, symbol: Str = None, params={}):
4319
4495
  raise NotSupported(self.id + ' cancelAllOrders() is not supported yet')
4320
4496
 
4497
+ def cancel_all_orders_after(self, timeout: Int, params={}):
4498
+ raise NotSupported(self.id + ' cancelAllOrdersAfter() is not supported yet')
4499
+
4321
4500
  def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
4322
4501
  raise NotSupported(self.id + ' cancelOrdersForSymbols() is not supported yet')
4323
4502
 
@@ -4512,21 +4691,39 @@ class Exchange(object):
4512
4691
  def create_limit_order(self, symbol: str, side: OrderSide, amount: float, price: float, params={}):
4513
4692
  return self.create_order(symbol, 'limit', side, amount, price, params)
4514
4693
 
4694
+ def create_limit_order_ws(self, symbol: str, side: OrderSide, amount: float, price: float, params={}):
4695
+ return self.createOrderWs(symbol, 'limit', side, amount, price, params)
4696
+
4515
4697
  def create_market_order(self, symbol: str, side: OrderSide, amount: float, price: Num = None, params={}):
4516
4698
  return self.create_order(symbol, 'market', side, amount, price, params)
4517
4699
 
4700
+ def create_market_order_ws(self, symbol: str, side: OrderSide, amount: float, price: Num = None, params={}):
4701
+ return self.createOrderWs(symbol, 'market', side, amount, price, params)
4702
+
4518
4703
  def create_limit_buy_order(self, symbol: str, amount: float, price: float, params={}):
4519
4704
  return self.create_order(symbol, 'limit', 'buy', amount, price, params)
4520
4705
 
4706
+ def create_limit_buy_order_ws(self, symbol: str, amount: float, price: float, params={}):
4707
+ return self.createOrderWs(symbol, 'limit', 'buy', amount, price, params)
4708
+
4521
4709
  def create_limit_sell_order(self, symbol: str, amount: float, price: float, params={}):
4522
4710
  return self.create_order(symbol, 'limit', 'sell', amount, price, params)
4523
4711
 
4712
+ def create_limit_sell_order_ws(self, symbol: str, amount: float, price: float, params={}):
4713
+ return self.createOrderWs(symbol, 'limit', 'sell', amount, price, params)
4714
+
4524
4715
  def create_market_buy_order(self, symbol: str, amount: float, params={}):
4525
4716
  return self.create_order(symbol, 'market', 'buy', amount, None, params)
4526
4717
 
4718
+ def create_market_buy_order_ws(self, symbol: str, amount: float, params={}):
4719
+ return self.createOrderWs(symbol, 'market', 'buy', amount, None, params)
4720
+
4527
4721
  def create_market_sell_order(self, symbol: str, amount: float, params={}):
4528
4722
  return self.create_order(symbol, 'market', 'sell', amount, None, params)
4529
4723
 
4724
+ def create_market_sell_order_ws(self, symbol: str, amount: float, params={}):
4725
+ return self.createOrderWs(symbol, 'market', 'sell', amount, None, params)
4726
+
4530
4727
  def cost_to_precision(self, symbol: str, cost):
4531
4728
  market = self.market(symbol)
4532
4729
  return self.decimal_to_precision(cost, TRUNCATE, market['precision']['price'], self.precisionMode, self.paddingMode)
@@ -4643,12 +4840,24 @@ class Exchange(object):
4643
4840
  query = self.extend(params, {'postOnly': True})
4644
4841
  return self.create_order(symbol, type, side, amount, price, query)
4645
4842
 
4843
+ def create_post_only_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4844
+ if not self.has['createPostOnlyOrderWs']:
4845
+ raise NotSupported(self.id + 'createPostOnlyOrderWs() is not supported yet')
4846
+ query = self.extend(params, {'postOnly': True})
4847
+ return self.createOrderWs(symbol, type, side, amount, price, query)
4848
+
4646
4849
  def create_reduce_only_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4647
4850
  if not self.has['createReduceOnlyOrder']:
4648
4851
  raise NotSupported(self.id + 'createReduceOnlyOrder() is not supported yet')
4649
4852
  query = self.extend(params, {'reduceOnly': True})
4650
4853
  return self.create_order(symbol, type, side, amount, price, query)
4651
4854
 
4855
+ def create_reduce_only_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4856
+ if not self.has['createReduceOnlyOrderWs']:
4857
+ raise NotSupported(self.id + 'createReduceOnlyOrderWs() is not supported yet')
4858
+ query = self.extend(params, {'reduceOnly': True})
4859
+ return self.createOrderWs(symbol, type, side, amount, price, query)
4860
+
4652
4861
  def create_stop_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopPrice: Num = None, params={}):
4653
4862
  if not self.has['createStopOrder']:
4654
4863
  raise NotSupported(self.id + ' createStopOrder() is not supported yet')
@@ -4657,18 +4866,38 @@ class Exchange(object):
4657
4866
  query = self.extend(params, {'stopPrice': stopPrice})
4658
4867
  return self.create_order(symbol, type, side, amount, price, query)
4659
4868
 
4869
+ def create_stop_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopPrice: Num = None, params={}):
4870
+ if not self.has['createStopOrderWs']:
4871
+ raise NotSupported(self.id + ' createStopOrderWs() is not supported yet')
4872
+ if stopPrice is None:
4873
+ raise ArgumentsRequired(self.id + ' createStopOrderWs() requires a stopPrice argument')
4874
+ query = self.extend(params, {'stopPrice': stopPrice})
4875
+ return self.createOrderWs(symbol, type, side, amount, price, query)
4876
+
4660
4877
  def create_stop_limit_order(self, symbol: str, side: OrderSide, amount: float, price: float, stopPrice: float, params={}):
4661
4878
  if not self.has['createStopLimitOrder']:
4662
4879
  raise NotSupported(self.id + ' createStopLimitOrder() is not supported yet')
4663
4880
  query = self.extend(params, {'stopPrice': stopPrice})
4664
4881
  return self.create_order(symbol, 'limit', side, amount, price, query)
4665
4882
 
4883
+ def create_stop_limit_order_ws(self, symbol: str, side: OrderSide, amount: float, price: float, stopPrice: float, params={}):
4884
+ if not self.has['createStopLimitOrderWs']:
4885
+ raise NotSupported(self.id + ' createStopLimitOrderWs() is not supported yet')
4886
+ query = self.extend(params, {'stopPrice': stopPrice})
4887
+ return self.createOrderWs(symbol, 'limit', side, amount, price, query)
4888
+
4666
4889
  def create_stop_market_order(self, symbol: str, side: OrderSide, amount: float, stopPrice: float, params={}):
4667
4890
  if not self.has['createStopMarketOrder']:
4668
4891
  raise NotSupported(self.id + ' createStopMarketOrder() is not supported yet')
4669
4892
  query = self.extend(params, {'stopPrice': stopPrice})
4670
4893
  return self.create_order(symbol, 'market', side, amount, None, query)
4671
4894
 
4895
+ def create_stop_market_order_ws(self, symbol: str, side: OrderSide, amount: float, stopPrice: float, params={}):
4896
+ if not self.has['createStopMarketOrderWs']:
4897
+ raise NotSupported(self.id + ' createStopMarketOrderWs() is not supported yet')
4898
+ query = self.extend(params, {'stopPrice': stopPrice})
4899
+ return self.createOrderWs(symbol, 'market', side, amount, None, query)
4900
+
4672
4901
  def safe_currency_code(self, currencyId: Str, currency: Currency = None):
4673
4902
  currency = self.safe_currency(currencyId, currency)
4674
4903
  return currency['code']
ccxt/binance.py CHANGED
@@ -343,6 +343,7 @@ class binance(Exchange, ImplicitAPI):
343
343
  'capital/deposit/subAddress': 0.1,
344
344
  'capital/deposit/subHisrec': 0.1,
345
345
  'capital/withdraw/history': 1800, # Weight(IP): 18000 => cost = 0.1 * 18000 = 1800
346
+ 'capital/withdraw/address/list': 10,
346
347
  'capital/contract/convertible-coins': 4.0002, # Weight(UID): 600 => cost = 0.006667 * 600 = 4.0002
347
348
  'convert/tradeFlow': 20.001, # Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
348
349
  'convert/exchangeInfo': 50,
@@ -3987,6 +3988,7 @@ class binance(Exchange, ImplicitAPI):
3987
3988
  :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
3988
3989
  :param dict [params]: extra parameters specific to the exchange API endpoint
3989
3990
  :param str [params.subType]: "linear" or "inverse"
3991
+ :param str [params.type]: 'spot', 'option', use params["subType"] for swap and future markets
3990
3992
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
3991
3993
  """
3992
3994
  self.load_markets()
@@ -4741,6 +4743,24 @@ class binance(Exchange, ImplicitAPI):
4741
4743
  params = self.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'newClientOrderId', 'clientOrderId', 'postOnly'])
4742
4744
  return self.extend(request, params)
4743
4745
 
4746
+ def edit_contract_order_request(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4747
+ market = self.market(symbol)
4748
+ if not market['contract']:
4749
+ raise NotSupported(self.id + ' editContractOrder() does not support ' + market['type'] + ' orders')
4750
+ request = {
4751
+ 'symbol': market['id'],
4752
+ 'side': side.upper(),
4753
+ }
4754
+ clientOrderId = self.safe_string_n(params, ['newClientOrderId', 'clientOrderId', 'origClientOrderId'])
4755
+ request['orderId'] = id
4756
+ request['quantity'] = self.amount_to_precision(symbol, amount)
4757
+ if price is not None:
4758
+ request['price'] = self.price_to_precision(symbol, price)
4759
+ if clientOrderId is not None:
4760
+ request['origClientOrderId'] = clientOrderId
4761
+ params = self.omit(params, ['clientOrderId', 'newClientOrderId'])
4762
+ return request
4763
+
4744
4764
  def edit_contract_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4745
4765
  """
4746
4766
  edit a trade order
@@ -4757,20 +4777,7 @@ class binance(Exchange, ImplicitAPI):
4757
4777
  """
4758
4778
  self.load_markets()
4759
4779
  market = self.market(symbol)
4760
- if not market['contract']:
4761
- raise NotSupported(self.id + ' editContractOrder() does not support ' + market['type'] + ' orders')
4762
- request = {
4763
- 'symbol': market['id'],
4764
- 'side': side.upper(),
4765
- }
4766
- clientOrderId = self.safe_string_n(params, ['newClientOrderId', 'clientOrderId', 'origClientOrderId'])
4767
- request['orderId'] = id
4768
- request['quantity'] = self.amount_to_precision(symbol, amount)
4769
- if price is not None:
4770
- request['price'] = self.price_to_precision(symbol, price)
4771
- if clientOrderId is not None:
4772
- request['origClientOrderId'] = clientOrderId
4773
- params = self.omit(params, ['clientOrderId', 'newClientOrderId'])
4780
+ request = self.edit_contract_order_request(id, symbol, type, side, amount, price, params)
4774
4781
  response = None
4775
4782
  if market['linear']:
4776
4783
  response = self.fapiPrivatePutOrder(self.extend(request, params))
ccxt/bingx.py CHANGED
@@ -46,6 +46,7 @@ class bingx(Exchange, ImplicitAPI):
46
46
  'option': False,
47
47
  'addMargin': True,
48
48
  'cancelAllOrders': True,
49
+ 'cancelAllOrdersAfter': True,
49
50
  'cancelOrder': True,
50
51
  'cancelOrders': True,
51
52
  'closeAllPositions': True,
@@ -242,6 +243,7 @@ class bingx(Exchange, ImplicitAPI):
242
243
  'trade/order': 3,
243
244
  'trade/batchOrders': 3,
244
245
  'trade/closeAllPositions': 3,
246
+ 'trade/cancelAllAfter': 3,
245
247
  'trade/marginType': 3,
246
248
  'trade/leverage': 3,
247
249
  'trade/positionMargin': 3,
@@ -2581,6 +2583,44 @@ class bingx(Exchange, ImplicitAPI):
2581
2583
  #
2582
2584
  return response
2583
2585
 
2586
+ def cancel_all_orders_after(self, timeout: Int, params={}):
2587
+ """
2588
+ dead man's switch, cancel all orders after the given timeout
2589
+ :see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20all%20orders%20in%20countdown
2590
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20all%20orders%20in%20countdown
2591
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
2592
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2593
+ :param str [params.type]: spot or swap market
2594
+ :returns dict: the api result
2595
+ """
2596
+ self.load_markets()
2597
+ isActive = (timeout > 0)
2598
+ request: dict = {
2599
+ 'type': 'ACTIVATE' if (isActive) else 'CLOSE',
2600
+ 'timeOut': (self.parse_to_int(timeout / 1000)) if (isActive) else 0,
2601
+ }
2602
+ response = None
2603
+ type = None
2604
+ type, params = self.handle_market_type_and_params('cancelAllOrdersAfter', None, params)
2605
+ if type == 'spot':
2606
+ response = self.spotV1PrivatePostTradeCancelAllAfter(self.extend(request, params))
2607
+ elif type == 'swap':
2608
+ response = self.swapV2PrivatePostTradeCancelAllAfter(self.extend(request, params))
2609
+ else:
2610
+ raise NotSupported(self.id + ' cancelAllOrdersAfter() is not supported for ' + type + ' markets')
2611
+ #
2612
+ # {
2613
+ # code: '0',
2614
+ # msg: '',
2615
+ # data: {
2616
+ # triggerTime: '1712645434',
2617
+ # status: 'ACTIVATED',
2618
+ # note: 'All your perpetual pending orders will be closed automatically at 2024-04-09 06:50:34 UTC(+0),before that you can cancel the timer, or self.extend triggerTime time by self request'
2619
+ # }
2620
+ # }
2621
+ #
2622
+ return response
2623
+
2584
2624
  def fetch_order(self, id: str, symbol: Str = None, params={}):
2585
2625
  """
2586
2626
  fetches information on an order made by the user
ccxt/bitmex.py CHANGED
@@ -48,6 +48,7 @@ class bitmex(Exchange, ImplicitAPI):
48
48
  'option': False,
49
49
  'addMargin': None,
50
50
  'cancelAllOrders': True,
51
+ 'cancelAllOrdersAfter': True,
51
52
  'cancelOrder': True,
52
53
  'cancelOrders': True,
53
54
  'closeAllPositions': False,
@@ -1979,6 +1980,27 @@ class bitmex(Exchange, ImplicitAPI):
1979
1980
  #
1980
1981
  return self.parse_orders(response, market)
1981
1982
 
1983
+ def cancel_all_orders_after(self, timeout: Int, params={}):
1984
+ """
1985
+ dead man's switch, cancel all orders after the given timeout
1986
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_cancelAllAfter
1987
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1988
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1989
+ :returns dict: the api result
1990
+ """
1991
+ self.load_markets()
1992
+ request: dict = {
1993
+ 'timeout': self.parse_to_int(timeout / 1000) if (timeout > 0) else 0,
1994
+ }
1995
+ response = self.privatePostOrderCancelAllAfter(self.extend(request, params))
1996
+ #
1997
+ # {
1998
+ # now: '2024-04-09T09:01:56.560Z',
1999
+ # cancelTime: '2024-04-09T09:01:56.660Z'
2000
+ # }
2001
+ #
2002
+ return response
2003
+
1982
2004
  def fetch_leverages(self, symbols: List[str] = None, params={}) -> Leverages:
1983
2005
  """
1984
2006
  fetch the set leverage for all contract markets
ccxt/bybit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -49,6 +49,8 @@ class bybit(Exchange, ImplicitAPI):
49
49
  'borrowCrossMargin': True,
50
50
  'cancelAllOrders': True,
51
51
  'cancelOrder': True,
52
+ 'cancelOrders': True,
53
+ 'cancelOrdersForSymbols': True,
52
54
  'closeAllPositions': False,
53
55
  'closePosition': False,
54
56
  'createMarketBuyOrderWithCost': True,
@@ -4088,6 +4090,84 @@ class bybit(Exchange, ImplicitAPI):
4088
4090
  row = self.safe_list(result, 'list', [])
4089
4091
  return self.parse_orders(row, market)
4090
4092
 
4093
+ def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
4094
+ """
4095
+ cancel multiple orders for multiple symbols
4096
+ :see: https://bybit-exchange.github.io/docs/v5/order/batch-cancel
4097
+ :param str[] ids: order ids
4098
+ :param str symbol: unified symbol of the market the order was made in
4099
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4100
+ :param str[] [params.clientOrderIds]: client order ids
4101
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4102
+ """
4103
+ self.load_markets()
4104
+ ordersRequests = []
4105
+ category = None
4106
+ for i in range(0, len(orders)):
4107
+ order = orders[i]
4108
+ symbol = self.safe_string(order, 'symbol')
4109
+ market = self.market(symbol)
4110
+ currentCategory = None
4111
+ currentCategory, params = self.get_bybit_type('cancelOrders', market, params)
4112
+ if currentCategory == 'inverse':
4113
+ raise NotSupported(self.id + ' cancelOrdersForSymbols does not allow inverse orders')
4114
+ if (category is not None) and (category != currentCategory):
4115
+ raise ExchangeError(self.id + ' cancelOrdersForSymbols requires all orders to be of the same category(linear, spot or option))')
4116
+ category = currentCategory
4117
+ id = self.safe_string(order, 'id')
4118
+ clientOrderId = self.safe_string(order, 'clientOrderId')
4119
+ idKey = 'orderId'
4120
+ if clientOrderId is not None:
4121
+ idKey = 'orderLinkId'
4122
+ orderItem = {
4123
+ 'symbol': market['id'],
4124
+ }
4125
+ orderItem[idKey] = id if (idKey == 'orderId') else clientOrderId
4126
+ ordersRequests.append(orderItem)
4127
+ request = {
4128
+ 'category': category,
4129
+ 'request': ordersRequests,
4130
+ }
4131
+ response = self.privatePostV5OrderCancelBatch(self.extend(request, params))
4132
+ #
4133
+ # {
4134
+ # "retCode": "0",
4135
+ # "retMsg": "OK",
4136
+ # "result": {
4137
+ # "list": [
4138
+ # {
4139
+ # "category": "spot",
4140
+ # "symbol": "BTCUSDT",
4141
+ # "orderId": "1636282505818800896",
4142
+ # "orderLinkId": "1636282505818800897"
4143
+ # },
4144
+ # {
4145
+ # "category": "spot",
4146
+ # "symbol": "BTCUSDT",
4147
+ # "orderId": "1636282505818800898",
4148
+ # "orderLinkId": "1636282505818800899"
4149
+ # }
4150
+ # ]
4151
+ # },
4152
+ # "retExtInfo": {
4153
+ # "list": [
4154
+ # {
4155
+ # "code": "0",
4156
+ # "msg": "OK"
4157
+ # },
4158
+ # {
4159
+ # "code": "0",
4160
+ # "msg": "OK"
4161
+ # }
4162
+ # ]
4163
+ # },
4164
+ # "time": "1709796158501"
4165
+ # }
4166
+ #
4167
+ result = self.safe_dict(response, 'result', {})
4168
+ row = self.safe_list(result, 'list', [])
4169
+ return self.parse_orders(row, None)
4170
+
4091
4171
  def cancel_all_usdc_orders(self, symbol: Str = None, params={}):
4092
4172
  if symbol is None:
4093
4173
  raise ArgumentsRequired(self.id + ' cancelAllUsdcOrders() requires a symbol argument')