ccxt 4.3.10__py2.py3-none-any.whl → 4.3.12__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 (75) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/blofin.py +2 -0
  3. ccxt/async_support/__init__.py +1 -1
  4. ccxt/async_support/base/exchange.py +1 -1
  5. ccxt/async_support/bigone.py +22 -22
  6. ccxt/async_support/binance.py +7 -7
  7. ccxt/async_support/bingx.py +2 -2
  8. ccxt/async_support/bitget.py +10 -8
  9. ccxt/async_support/bitmart.py +7 -11
  10. ccxt/async_support/bitmex.py +2 -2
  11. ccxt/async_support/blofin.py +2 -0
  12. ccxt/async_support/bybit.py +75 -65
  13. ccxt/async_support/coinbase.py +8 -8
  14. ccxt/async_support/coinbaseinternational.py +2 -2
  15. ccxt/async_support/coinex.py +501 -445
  16. ccxt/async_support/coinlist.py +12 -12
  17. ccxt/async_support/coinmetro.py +2 -2
  18. ccxt/async_support/cryptocom.py +16 -16
  19. ccxt/async_support/digifinex.py +3 -3
  20. ccxt/async_support/gate.py +2 -2
  21. ccxt/async_support/hitbtc.py +3 -3
  22. ccxt/async_support/htx.py +6 -9
  23. ccxt/async_support/indodax.py +2 -2
  24. ccxt/async_support/kraken.py +3 -1
  25. ccxt/async_support/kucoin.py +4 -4
  26. ccxt/async_support/kucoinfutures.py +6 -6
  27. ccxt/async_support/mexc.py +5 -5
  28. ccxt/async_support/okx.py +9 -9
  29. ccxt/async_support/poloniexfutures.py +4 -4
  30. ccxt/async_support/probit.py +2 -2
  31. ccxt/async_support/whitebit.py +72 -1
  32. ccxt/async_support/woo.py +2 -2
  33. ccxt/base/exchange.py +14 -2
  34. ccxt/base/types.py +25 -0
  35. ccxt/bigone.py +22 -22
  36. ccxt/binance.py +7 -7
  37. ccxt/bingx.py +2 -2
  38. ccxt/bitget.py +10 -8
  39. ccxt/bitmart.py +7 -11
  40. ccxt/bitmex.py +2 -2
  41. ccxt/blofin.py +2 -0
  42. ccxt/bybit.py +75 -65
  43. ccxt/coinbase.py +8 -8
  44. ccxt/coinbaseinternational.py +2 -2
  45. ccxt/coinex.py +501 -445
  46. ccxt/coinlist.py +12 -12
  47. ccxt/coinmetro.py +2 -2
  48. ccxt/cryptocom.py +16 -16
  49. ccxt/digifinex.py +3 -3
  50. ccxt/gate.py +2 -2
  51. ccxt/hitbtc.py +3 -3
  52. ccxt/htx.py +6 -9
  53. ccxt/indodax.py +2 -2
  54. ccxt/kraken.py +3 -1
  55. ccxt/kucoin.py +4 -4
  56. ccxt/kucoinfutures.py +6 -6
  57. ccxt/mexc.py +5 -5
  58. ccxt/okx.py +9 -9
  59. ccxt/poloniexfutures.py +4 -4
  60. ccxt/pro/__init__.py +1 -1
  61. ccxt/pro/bitget.py +139 -87
  62. ccxt/pro/bybit.py +192 -12
  63. ccxt/pro/coinbase.py +90 -20
  64. ccxt/pro/mexc.py +21 -1
  65. ccxt/probit.py +2 -2
  66. ccxt/test/base/test_datetime.py +6 -0
  67. ccxt/test/base/test_ledger_entry.py +2 -2
  68. ccxt/whitebit.py +72 -1
  69. ccxt/woo.py +2 -2
  70. {ccxt-4.3.10.dist-info → ccxt-4.3.12.dist-info}/METADATA +4 -4
  71. {ccxt-4.3.10.dist-info → ccxt-4.3.12.dist-info}/RECORD +73 -75
  72. ccxt/async_support/flowbtc.py +0 -34
  73. ccxt/flowbtc.py +0 -34
  74. {ccxt-4.3.10.dist-info → ccxt-4.3.12.dist-info}/WHEEL +0 -0
  75. {ccxt-4.3.10.dist-info → ccxt-4.3.12.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, CrossBorrowRate, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -2418,9 +2418,9 @@ class bybit(Exchange, ImplicitAPI):
2418
2418
  request['category'] = type
2419
2419
  if since is not None:
2420
2420
  request['startTime'] = since
2421
- until = self.safe_integer_2(params, 'until', 'till') # unified in milliseconds
2421
+ until = self.safe_integer(params, 'until') # unified in milliseconds
2422
2422
  endTime = self.safe_integer(params, 'endTime', until) # exchange-specific in milliseconds
2423
- params = self.omit(params, ['endTime', 'till', 'until'])
2423
+ params = self.omit(params, ['endTime', 'until'])
2424
2424
  if endTime is not None:
2425
2425
  request['endTime'] = endTime
2426
2426
  else:
@@ -3811,40 +3811,8 @@ class bybit(Exchange, ImplicitAPI):
3811
3811
  result = self.safe_dict(response, 'result', {})
3812
3812
  return self.parse_order(result, market)
3813
3813
 
3814
- async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
3815
- """
3816
- edit a trade order
3817
- :see: https://bybit-exchange.github.io/docs/v5/order/amend-order
3818
- :see: https://bybit-exchange.github.io/docs/derivatives/unified/replace-order
3819
- :see: https://bybit-exchange.github.io/docs/api-explorer/derivatives/trade/contract/replace-order
3820
- :param str id: cancel order id
3821
- :param str symbol: unified symbol of the market to create an order in
3822
- :param str type: 'market' or 'limit'
3823
- :param str side: 'buy' or 'sell'
3824
- :param float amount: how much of currency you want to trade in units of base currency
3825
- :param float price: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
3826
- :param dict [params]: extra parameters specific to the exchange API endpoint
3827
- :param float [params.triggerPrice]: The price that a trigger order is triggered at
3828
- :param float [params.stopLossPrice]: The price that a stop loss order is triggered at
3829
- :param float [params.takeProfitPrice]: The price that a take profit order is triggered at
3830
- :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered
3831
- :param float [params.takeProfit.triggerPrice]: take profit trigger price
3832
- :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered
3833
- :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3834
- :param str [params.triggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for triggerPrice
3835
- :param str [params.slTriggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for stopLoss
3836
- :param str [params.tpTriggerby]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for takeProfit
3837
- :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3838
- """
3839
- if symbol is None:
3840
- raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
3841
- await self.load_markets()
3814
+ def edit_order_request(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
3842
3815
  market = self.market(symbol)
3843
- enableUnifiedMargin, enableUnifiedAccount = await self.is_unified_enabled()
3844
- isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
3845
- isUsdcSettled = market['settle'] == 'USDC'
3846
- if isUsdcSettled and not isUnifiedAccount:
3847
- return await self.edit_usdc_order(id, symbol, type, side, amount, price, params)
3848
3816
  request = {
3849
3817
  'symbol': market['id'],
3850
3818
  'orderId': id,
@@ -3905,6 +3873,43 @@ class bybit(Exchange, ImplicitAPI):
3905
3873
  if clientOrderId is not None:
3906
3874
  request['orderLinkId'] = clientOrderId
3907
3875
  params = self.omit(params, ['stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'clientOrderId', 'stopLoss', 'takeProfit'])
3876
+ return request
3877
+
3878
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
3879
+ """
3880
+ edit a trade order
3881
+ :see: https://bybit-exchange.github.io/docs/v5/order/amend-order
3882
+ :see: https://bybit-exchange.github.io/docs/derivatives/unified/replace-order
3883
+ :see: https://bybit-exchange.github.io/docs/api-explorer/derivatives/trade/contract/replace-order
3884
+ :param str id: cancel order id
3885
+ :param str symbol: unified symbol of the market to create an order in
3886
+ :param str type: 'market' or 'limit'
3887
+ :param str side: 'buy' or 'sell'
3888
+ :param float amount: how much of currency you want to trade in units of base currency
3889
+ :param float price: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
3890
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3891
+ :param float [params.triggerPrice]: The price that a trigger order is triggered at
3892
+ :param float [params.stopLossPrice]: The price that a stop loss order is triggered at
3893
+ :param float [params.takeProfitPrice]: The price that a take profit order is triggered at
3894
+ :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered
3895
+ :param float [params.takeProfit.triggerPrice]: take profit trigger price
3896
+ :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered
3897
+ :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3898
+ :param str [params.triggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for triggerPrice
3899
+ :param str [params.slTriggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for stopLoss
3900
+ :param str [params.tpTriggerby]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for takeProfit
3901
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3902
+ """
3903
+ await self.load_markets()
3904
+ if symbol is None:
3905
+ raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
3906
+ market = self.market(symbol)
3907
+ enableUnifiedMargin, enableUnifiedAccount = await self.is_unified_enabled()
3908
+ isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
3909
+ isUsdcSettled = market['settle'] == 'USDC'
3910
+ if isUsdcSettled and not isUnifiedAccount:
3911
+ return await self.edit_usdc_order(id, symbol, type, side, amount, price, params)
3912
+ request = self.edit_order_request(id, symbol, type, side, amount, price, params)
3908
3913
  response = await self.privatePostV5OrderAmend(self.extend(request, params))
3909
3914
  #
3910
3915
  # {
@@ -3960,26 +3965,8 @@ class bybit(Exchange, ImplicitAPI):
3960
3965
  result = self.safe_dict(response, 'result', {})
3961
3966
  return self.parse_order(result, market)
3962
3967
 
3963
- async def cancel_order(self, id: str, symbol: Str = None, params={}):
3964
- """
3965
- cancels an open order
3966
- :see: https://bybit-exchange.github.io/docs/v5/order/cancel-order
3967
- :param str id: order id
3968
- :param str symbol: unified symbol of the market the order was made in
3969
- :param dict [params]: extra parameters specific to the exchange API endpoint
3970
- :param boolean [params.stop]: *spot only* whether the order is a stop order
3971
- :param str [params.orderFilter]: *spot only* 'Order' or 'StopOrder' or 'tpslOrder'
3972
- :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3973
- """
3974
- if symbol is None:
3975
- raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
3976
- await self.load_markets()
3968
+ def cancel_order_request(self, id: str, symbol: Str = None, params={}):
3977
3969
  market = self.market(symbol)
3978
- enableUnifiedMargin, enableUnifiedAccount = await self.is_unified_enabled()
3979
- isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
3980
- isUsdcSettled = market['settle'] == 'USDC'
3981
- if isUsdcSettled and not isUnifiedAccount:
3982
- return await self.cancel_usdc_order(id, symbol, params)
3983
3970
  request = {
3984
3971
  'symbol': market['id'],
3985
3972
  # 'orderLinkId': 'string',
@@ -3989,7 +3976,7 @@ class bybit(Exchange, ImplicitAPI):
3989
3976
  }
3990
3977
  if market['spot']:
3991
3978
  # only works for spot market
3992
- isStop = self.safe_value_2(params, 'stop', 'trigger', False)
3979
+ isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
3993
3980
  params = self.omit(params, ['stop', 'trigger'])
3994
3981
  request['orderFilter'] = 'StopOrder' if isStop else 'Order'
3995
3982
  if id is not None: # The user can also use argument params["orderLinkId"]
@@ -4002,7 +3989,30 @@ class bybit(Exchange, ImplicitAPI):
4002
3989
  request['category'] = 'inverse'
4003
3990
  elif market['option']:
4004
3991
  request['category'] = 'option'
4005
- response = await self.privatePostV5OrderCancel(self.extend(request, params))
3992
+ return self.extend(request, params)
3993
+
3994
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
3995
+ """
3996
+ cancels an open order
3997
+ :see: https://bybit-exchange.github.io/docs/v5/order/cancel-order
3998
+ :param str id: order id
3999
+ :param str symbol: unified symbol of the market the order was made in
4000
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4001
+ :param boolean [params.stop]: *spot only* whether the order is a stop order
4002
+ :param str [params.orderFilter]: *spot only* 'Order' or 'StopOrder' or 'tpslOrder'
4003
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4004
+ """
4005
+ if symbol is None:
4006
+ raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
4007
+ await self.load_markets()
4008
+ market = self.market(symbol)
4009
+ enableUnifiedMargin, enableUnifiedAccount = await self.is_unified_enabled()
4010
+ isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
4011
+ isUsdcSettled = market['settle'] == 'USDC'
4012
+ if isUsdcSettled and not isUnifiedAccount:
4013
+ return await self.cancel_usdc_order(id, symbol, params)
4014
+ requestExtended = self.cancel_order_request(id, symbol, params)
4015
+ response = await self.privatePostV5OrderCancel(requestExtended)
4006
4016
  #
4007
4017
  # {
4008
4018
  # "retCode": 0,
@@ -4475,9 +4485,9 @@ class bybit(Exchange, ImplicitAPI):
4475
4485
  request['limit'] = limit
4476
4486
  if since is not None:
4477
4487
  request['startTime'] = since
4478
- until = self.safe_integer_2(params, 'until', 'till') # unified in milliseconds
4488
+ until = self.safe_integer(params, 'until') # unified in milliseconds
4479
4489
  endTime = self.safe_integer(params, 'endTime', until) # exchange-specific in milliseconds
4480
- params = self.omit(params, ['endTime', 'till', 'until'])
4490
+ params = self.omit(params, ['endTime', 'until'])
4481
4491
  if endTime is not None:
4482
4492
  request['endTime'] = endTime
4483
4493
  response = await self.privateGetV5OrderHistory(self.extend(request, params))
@@ -4633,9 +4643,9 @@ class bybit(Exchange, ImplicitAPI):
4633
4643
  request['limit'] = limit
4634
4644
  if since is not None:
4635
4645
  request['startTime'] = since
4636
- until = self.safe_integer_2(params, 'until', 'till') # unified in milliseconds
4646
+ until = self.safe_integer(params, 'until') # unified in milliseconds
4637
4647
  endTime = self.safe_integer(params, 'endTime', until) # exchange-specific in milliseconds
4638
- params = self.omit(params, ['endTime', 'till', 'until'])
4648
+ params = self.omit(params, ['endTime', 'until'])
4639
4649
  if endTime is not None:
4640
4650
  request['endTime'] = endTime
4641
4651
  response = await self.privateGetV5OrderHistory(self.extend(request, params))
@@ -5380,7 +5390,7 @@ class bybit(Exchange, ImplicitAPI):
5380
5390
  # 'coin': currency['id'],
5381
5391
  # 'currency': currency['id'], # alias
5382
5392
  # 'start_date': self.iso8601(since),
5383
- # 'end_date': self.iso8601(till),
5393
+ # 'end_date': self.iso8601(until),
5384
5394
  # 'wallet_fund_type': 'Deposit', # Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit
5385
5395
  # 'page': 1,
5386
5396
  # 'limit': 20, # max 50
@@ -6339,8 +6349,8 @@ class bybit(Exchange, ImplicitAPI):
6339
6349
  }
6340
6350
  if since is not None:
6341
6351
  request['startTime'] = since
6342
- until = self.safe_integer_2(params, 'until', 'till') # unified in milliseconds
6343
- params = self.omit(params, ['till', 'until'])
6352
+ until = self.safe_integer(params, 'until') # unified in milliseconds
6353
+ params = self.omit(params, ['until'])
6344
6354
  if until is not None:
6345
6355
  request['endTime'] = until
6346
6356
  if limit is not None:
@@ -6478,7 +6488,7 @@ class bybit(Exchange, ImplicitAPI):
6478
6488
  'info': interest,
6479
6489
  }, market)
6480
6490
 
6481
- async def fetch_cross_borrow_rate(self, code: str, params={}):
6491
+ async def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
6482
6492
  """
6483
6493
  fetch the rate of interest to borrow a currency for margin trading
6484
6494
  :see: https://bybit-exchange.github.io/docs/zh-TW/v5/spot-margin-normal/interest-quota
@@ -3110,9 +3110,9 @@ class coinbase(Exchange, ImplicitAPI):
3110
3110
  request['limit'] = limit
3111
3111
  if since is not None:
3112
3112
  request['start_date'] = self.iso8601(since)
3113
- until = self.safe_integer_n(params, ['until', 'till'])
3113
+ until = self.safe_integer_n(params, ['until'])
3114
3114
  if until is not None:
3115
- params = self.omit(params, ['until', 'till'])
3115
+ params = self.omit(params, ['until'])
3116
3116
  request['end_date'] = self.iso8601(until)
3117
3117
  response = await self.v3PrivateGetBrokerageOrdersHistoricalBatch(self.extend(request, params))
3118
3118
  #
@@ -3180,9 +3180,9 @@ class coinbase(Exchange, ImplicitAPI):
3180
3180
  request['limit'] = limit
3181
3181
  if since is not None:
3182
3182
  request['start_date'] = self.iso8601(since)
3183
- until = self.safe_integer_n(params, ['until', 'till'])
3183
+ until = self.safe_integer_n(params, ['until'])
3184
3184
  if until is not None:
3185
- params = self.omit(params, ['until', 'till'])
3185
+ params = self.omit(params, ['until'])
3186
3186
  request['end_date'] = self.iso8601(until)
3187
3187
  response = await self.v3PrivateGetBrokerageOrdersHistoricalBatch(self.extend(request, params))
3188
3188
  #
@@ -3310,8 +3310,8 @@ class coinbase(Exchange, ImplicitAPI):
3310
3310
  'product_id': market['id'],
3311
3311
  'granularity': self.safe_string(self.timeframes, timeframe, timeframe),
3312
3312
  }
3313
- until = self.safe_integer_n(params, ['until', 'till', 'end'])
3314
- params = self.omit(params, ['until', 'till'])
3313
+ until = self.safe_integer_n(params, ['until', 'end'])
3314
+ params = self.omit(params, ['until'])
3315
3315
  duration = self.parse_timeframe(timeframe)
3316
3316
  requestedDuration = limit * duration
3317
3317
  sinceString = None
@@ -3438,9 +3438,9 @@ class coinbase(Exchange, ImplicitAPI):
3438
3438
  request['limit'] = limit
3439
3439
  if since is not None:
3440
3440
  request['start_sequence_timestamp'] = self.iso8601(since)
3441
- until = self.safe_integer_n(params, ['until', 'till'])
3441
+ until = self.safe_integer_n(params, ['until'])
3442
3442
  if until is not None:
3443
- params = self.omit(params, ['until', 'till'])
3443
+ params = self.omit(params, ['until'])
3444
3444
  request['end_sequence_timestamp'] = self.iso8601(until)
3445
3445
  response = await self.v3PrivateGetBrokerageOrdersHistoricalFills(self.extend(request, params))
3446
3446
  #
@@ -1725,9 +1725,9 @@ class coinbaseinternational(Exchange, ImplicitAPI):
1725
1725
  request['result_limit'] = limit
1726
1726
  if since is not None:
1727
1727
  request['time_from'] = self.iso8601(since)
1728
- until = self.safe_string_n(params, ['until', 'till'])
1728
+ until = self.safe_string_n(params, ['until'])
1729
1729
  if until is not None:
1730
- params = self.omit(params, ['until', 'till'])
1730
+ params = self.omit(params, ['until'])
1731
1731
  request['ref_datetime'] = self.iso8601(until)
1732
1732
  response = await self.v1PrivateGetPortfoliosFills(self.extend(request, params))
1733
1733
  #