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
@@ -2093,8 +2093,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
2093
2093
  # symbol(str) [optional] Symbol of the contract
2094
2094
  # side(str) [optional] buy or sell
2095
2095
  # type(str) [optional] limit, market, limit_stop or market_stop
2096
- # startAt(long) [optional] Start time(milisecond)
2097
- # endAt(long) [optional] End time(milisecond)
2096
+ # startAt(long) [optional] Start time(millisecond)
2097
+ # endAt(long) [optional] End time(millisecond)
2098
2098
  }
2099
2099
  market = None
2100
2100
  if symbol is not None:
ccxt/async_support/okx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.okx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from typing import Any
13
13
  from ccxt.base.errors import ExchangeError
@@ -55,8 +55,10 @@ class okx(Exchange, ImplicitAPI):
55
55
  'option': True,
56
56
  'addMargin': True,
57
57
  'cancelAllOrders': False,
58
+ 'cancelAllOrdersAfter': True,
58
59
  'cancelOrder': True,
59
60
  'cancelOrders': True,
61
+ 'cancelOrdersForSymbols': True,
60
62
  'closeAllPositions': False,
61
63
  'closePosition': True,
62
64
  'createConvertTrade': True,
@@ -3084,6 +3086,107 @@ class okx(Exchange, ImplicitAPI):
3084
3086
  ordersData = self.safe_list(response, 'data', [])
3085
3087
  return self.parse_orders(ordersData, market, None, None, params)
3086
3088
 
3089
+ async def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
3090
+ """
3091
+ cancel multiple orders for multiple symbols
3092
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
3093
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
3094
+ :param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol
3095
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3096
+ :param boolean [params.trigger]: whether the order is a stop/trigger order
3097
+ :param boolean [params.trailing]: set to True if you want to cancel trailing orders
3098
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3099
+ """
3100
+ await self.load_markets()
3101
+ request = []
3102
+ options = self.safe_dict(self.options, 'cancelOrders', {})
3103
+ defaultMethod = self.safe_string(options, 'method', 'privatePostTradeCancelBatchOrders')
3104
+ method = self.safe_string(params, 'method', defaultMethod)
3105
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
3106
+ trailing = self.safe_bool(params, 'trailing', False)
3107
+ isStopOrTrailing = stop or trailing
3108
+ if isStopOrTrailing:
3109
+ method = 'privatePostTradeCancelAlgos'
3110
+ for i in range(0, len(orders)):
3111
+ order = orders[i]
3112
+ id = self.safe_string(order, 'id')
3113
+ clientOrderId = self.safe_string_2(order, 'clOrdId', 'clientOrderId')
3114
+ symbol = self.safe_string(order, 'symbol')
3115
+ market = self.market(symbol)
3116
+ idKey = 'ordId'
3117
+ if isStopOrTrailing:
3118
+ idKey = 'algoId'
3119
+ elif clientOrderId is not None:
3120
+ idKey = 'clOrdId'
3121
+ requestItem = {
3122
+ 'instId': market['id'],
3123
+ }
3124
+ requestItem[idKey] = clientOrderId if (clientOrderId is not None) else id
3125
+ request.append(requestItem)
3126
+ response = None
3127
+ if method == 'privatePostTradeCancelAlgos':
3128
+ response = await self.privatePostTradeCancelAlgos(request) # * dont self.extend with params, otherwise ARRAY will be turned into OBJECT
3129
+ else:
3130
+ response = await self.privatePostTradeCancelBatchOrders(request) # * dont self.extend with params, otherwise ARRAY will be turned into OBJECT
3131
+ #
3132
+ # {
3133
+ # "code": "0",
3134
+ # "data": [
3135
+ # {
3136
+ # "clOrdId": "e123456789ec4dBC1123456ba123b45e",
3137
+ # "ordId": "405071912345641543",
3138
+ # "sCode": "0",
3139
+ # "sMsg": ""
3140
+ # },
3141
+ # ...
3142
+ # ],
3143
+ # "msg": ""
3144
+ # }
3145
+ #
3146
+ # Algo order
3147
+ #
3148
+ # {
3149
+ # "code": "0",
3150
+ # "data": [
3151
+ # {
3152
+ # "algoId": "431375349042380800",
3153
+ # "sCode": "0",
3154
+ # "sMsg": ""
3155
+ # }
3156
+ # ],
3157
+ # "msg": ""
3158
+ # }
3159
+ #
3160
+ ordersData = self.safe_list(response, 'data', [])
3161
+ return self.parse_orders(ordersData, None, None, None, params)
3162
+
3163
+ async def cancel_all_orders_after(self, timeout: Int, params={}):
3164
+ """
3165
+ dead man's switch, cancel all orders after the given timeout
3166
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
3167
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
3168
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3169
+ :returns dict: the api result
3170
+ """
3171
+ await self.load_markets()
3172
+ request: dict = {
3173
+ 'timeOut': self.parse_to_int(timeout / 1000) if (timeout > 0) else 0,
3174
+ }
3175
+ response = await self.privatePostTradeCancelAllAfter(self.extend(request, params))
3176
+ #
3177
+ # {
3178
+ # "code":"0",
3179
+ # "msg":"",
3180
+ # "data":[
3181
+ # {
3182
+ # "triggerTime":"1587971460",
3183
+ # "ts":"1587971400"
3184
+ # }
3185
+ # ]
3186
+ # }
3187
+ #
3188
+ return response
3189
+
3087
3190
  def parse_order_status(self, status):
3088
3191
  statuses = {
3089
3192
  'canceled': 'canceled',
@@ -41,7 +41,8 @@ class whitebit(Exchange, ImplicitAPI):
41
41
  'swap': False,
42
42
  'future': False,
43
43
  'option': False,
44
- 'cancelAllOrders': False,
44
+ 'cancelAllOrders': True,
45
+ 'cancelAllOrdersAfter': True,
45
46
  'cancelOrder': True,
46
47
  'cancelOrders': False,
47
48
  'createOrder': True,
@@ -186,11 +187,13 @@ class whitebit(Exchange, ImplicitAPI):
186
187
  'ping',
187
188
  'markets',
188
189
  'futures',
190
+ 'platform/status',
189
191
  ],
190
192
  },
191
193
  'private': {
192
194
  'post': [
193
195
  'collateral-account/balance',
196
+ 'collateral-account/balance-summary',
194
197
  'collateral-account/positions/history',
195
198
  'collateral-account/leverage',
196
199
  'collateral-account/positions/open',
@@ -207,21 +210,40 @@ class whitebit(Exchange, ImplicitAPI):
207
210
  'main-account/withdraw',
208
211
  'main-account/withdraw-pay',
209
212
  'main-account/transfer',
213
+ 'main-account/smart/plans',
214
+ 'main-account/smart/investment',
215
+ 'main-account/smart/investment/close',
216
+ 'main-account/smart/investments',
217
+ 'main-account/fee',
218
+ 'main-account/smart/interest-payment-history',
210
219
  'trade-account/balance',
211
220
  'trade-account/executed-history',
212
221
  'trade-account/order',
213
222
  'trade-account/order/history',
214
223
  'order/collateral/limit',
215
224
  'order/collateral/market',
216
- 'order/collateral/trigger_market',
225
+ 'order/collateral/stop-limit',
226
+ 'order/collateral/trigger-market',
217
227
  'order/new',
218
228
  'order/market',
219
229
  'order/stock_market',
220
230
  'order/stop_limit',
221
231
  'order/stop_market',
222
232
  'order/cancel',
233
+ 'order/cancel/all',
234
+ 'order/kill-switch',
235
+ 'order/kill-switch/status',
236
+ 'order/bulk',
237
+ 'order/modify',
223
238
  'orders',
239
+ 'oco-orders',
240
+ 'order/collateral/oco',
241
+ 'order/oco-cancel',
242
+ 'order/oto-cancel',
224
243
  'profile/websocket_token',
244
+ 'convert/estimate',
245
+ 'convert/confirm',
246
+ 'convert/history',
225
247
  ],
226
248
  },
227
249
  },
@@ -1203,6 +1225,58 @@ class whitebit(Exchange, ImplicitAPI):
1203
1225
  response = await self.v4PrivatePostOrderStockMarket(self.extend(request, params))
1204
1226
  return self.parse_order(response)
1205
1227
 
1228
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1229
+ """
1230
+ edit a trade order
1231
+ :see: https://docs.whitebit.com/private/http-trade-v4/#modify-order
1232
+ :param str id: cancel order id
1233
+ :param str symbol: unified symbol of the market to create an order in
1234
+ :param str type: 'market' or 'limit'
1235
+ :param str side: 'buy' or 'sell'
1236
+ :param float amount: how much of currency you want to trade in units of base currency
1237
+ :param float price: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
1238
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1239
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1240
+ """
1241
+ if id is None:
1242
+ raise ArgumentsRequired(self.id + ' editOrder() requires a id argument')
1243
+ if symbol is None:
1244
+ raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
1245
+ await self.load_markets()
1246
+ market = self.market(symbol)
1247
+ request = {
1248
+ 'orderId': id,
1249
+ 'market': market['id'],
1250
+ }
1251
+ clientOrderId = self.safe_string_2(params, 'clOrdId', 'clientOrderId')
1252
+ if clientOrderId is not None:
1253
+ # Update clientOrderId of the order
1254
+ request['clientOrderId'] = clientOrderId
1255
+ isLimitOrder = type == 'limit'
1256
+ stopPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'activation_price'])
1257
+ isStopOrder = (stopPrice is not None)
1258
+ params = self.omit(params, ['clOrdId', 'clientOrderId', 'triggerPrice', 'stopPrice'])
1259
+ if isStopOrder:
1260
+ request['activation_price'] = self.price_to_precision(symbol, stopPrice)
1261
+ if isLimitOrder:
1262
+ # stop limit order
1263
+ request['amount'] = self.amount_to_precision(symbol, amount)
1264
+ request['price'] = self.price_to_precision(symbol, price)
1265
+ else:
1266
+ # stop market order
1267
+ if side == 'buy':
1268
+ # Use total parameter instead of amount for modify buy stop market order
1269
+ request['total'] = self.amount_to_precision(symbol, amount)
1270
+ else:
1271
+ request['amount'] = self.amount_to_precision(symbol, amount)
1272
+ else:
1273
+ request['amount'] = self.amount_to_precision(symbol, amount)
1274
+ if isLimitOrder:
1275
+ # limit order
1276
+ request['price'] = self.price_to_precision(symbol, price)
1277
+ response = await self.v4PrivatePostOrderModify(self.extend(request, params))
1278
+ return self.parse_order(response)
1279
+
1206
1280
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
1207
1281
  """
1208
1282
  cancels an open order
@@ -1222,6 +1296,79 @@ class whitebit(Exchange, ImplicitAPI):
1222
1296
  }
1223
1297
  return await self.v4PrivatePostOrderCancel(self.extend(request, params))
1224
1298
 
1299
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
1300
+ """
1301
+ cancel all open orders
1302
+ :see: https://docs.whitebit.com/private/http-trade-v4/#cancel-all-orders
1303
+ :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
1304
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1305
+ :param str [params.type]: market type, ['swap', 'spot']
1306
+ :param boolean [params.isMargin]: cancel all margin orders
1307
+ :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1308
+ """
1309
+ await self.load_markets()
1310
+ market = None
1311
+ request = {}
1312
+ if symbol is not None:
1313
+ market = self.market(symbol)
1314
+ request['market'] = market['id']
1315
+ type = None
1316
+ type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
1317
+ requestType = []
1318
+ if type == 'spot':
1319
+ isMargin = None
1320
+ isMargin, params = self.handle_option_and_params(params, 'cancelAllOrders', 'isMargin', False)
1321
+ if isMargin:
1322
+ requestType.append('margin')
1323
+ else:
1324
+ requestType.append('spot')
1325
+ elif type == 'swap':
1326
+ requestType.append('futures')
1327
+ else:
1328
+ raise NotSupported(self.id + ' cancelAllOrders() does not support ' + type + ' type')
1329
+ request['type'] = requestType
1330
+ response = await self.v4PrivatePostOrderCancelAll(self.extend(request, params))
1331
+ #
1332
+ # []
1333
+ #
1334
+ return response
1335
+
1336
+ async def cancel_all_orders_after(self, timeout: Int, params={}):
1337
+ """
1338
+ dead man's switch, cancel all orders after the given timeout
1339
+ :see: https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
1340
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1341
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1342
+ :param str [params.types]: Order types value. Example: "spot", "margin", "futures" or None
1343
+ :param str [params.symbol]: symbol unified symbol of the market the order was made in
1344
+ :returns dict: the api result
1345
+ """
1346
+ await self.load_markets()
1347
+ symbol = self.safe_string(params, 'symbol')
1348
+ if symbol is None:
1349
+ raise ArgumentsRequired(self.id + ' cancelAllOrdersAfter() requires a symbol argument in params')
1350
+ market = self.market(symbol)
1351
+ params = self.omit(params, 'symbol')
1352
+ isBiggerThanZero = (timeout > 0)
1353
+ request: dict = {
1354
+ 'market': market['id'],
1355
+ # 'timeout': self.number_to_string(timeout / 1000) if (timeout > 0) else null,
1356
+ }
1357
+ if isBiggerThanZero:
1358
+ request['timeout'] = self.number_to_string(timeout / 1000)
1359
+ else:
1360
+ request['timeout'] = 'null'
1361
+ response = await self.v4PrivatePostOrderKillSwitch(self.extend(request, params))
1362
+ #
1363
+ # {
1364
+ # "market": "BTC_USDT", # currency market,
1365
+ # "startTime": 1662478154, # now timestamp,
1366
+ # "cancellationTime": 1662478154, # now + timer_value,
1367
+ # "types": ["spot", "margin"]
1368
+ # }
1369
+ #
1370
+ return response
1371
+
1225
1372
  def parse_balance(self, response) -> Balances:
1226
1373
  balanceKeys = list(response.keys())
1227
1374
  result = {}
ccxt/async_support/woo.py CHANGED
@@ -41,6 +41,7 @@ class woo(Exchange, ImplicitAPI):
41
41
  'option': False,
42
42
  'addMargin': False,
43
43
  'cancelAllOrders': True,
44
+ 'cancelAllOrdersAfter': True,
44
45
  'cancelOrder': True,
45
46
  'cancelWithdraw': False, # exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://kronosresearch.github.io/wootrade-documents/#cancel-withdraw-request
46
47
  'closeAllPositions': False,
@@ -208,6 +209,7 @@ class woo(Exchange, ImplicitAPI):
208
209
  },
209
210
  'post': {
210
211
  'order': 5, # 2 requests per 1 second per symbol
212
+ 'order/cancel_all_after': 1,
211
213
  'asset/main_sub_transfer': 30, # 20 requests per 60 seconds
212
214
  'asset/ltv': 30,
213
215
  'asset/withdraw': 30, # implemented in ccxt, disabled on the exchange side https://kronosresearch.github.io/wootrade-documents/#token-withdraw
@@ -1203,6 +1205,31 @@ class woo(Exchange, ImplicitAPI):
1203
1205
  #
1204
1206
  return response
1205
1207
 
1208
+ async def cancel_all_orders_after(self, timeout: Int, params={}):
1209
+ """
1210
+ dead man's switch, cancel all orders after the given timeout
1211
+ :see: https://docs.woo.org/#cancel-all-after
1212
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1213
+ :param boolean activated: countdown
1214
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1215
+ :returns dict: the api result
1216
+ """
1217
+ await self.load_markets()
1218
+ request: dict = {
1219
+ 'trigger_after': timeout if (timeout > 0) else 0,
1220
+ }
1221
+ response = await self.v1PrivatePostOrderCancelAllAfter(self.extend(request, params))
1222
+ #
1223
+ # {
1224
+ # "success": True,
1225
+ # "data": {
1226
+ # "expected_trigger_time": 1711534302938
1227
+ # },
1228
+ # "timestamp": 1711534302943
1229
+ # }
1230
+ #
1231
+ return response
1232
+
1206
1233
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
1207
1234
  """
1208
1235
  :see: https://docs.woo.org/#get-algo-order