ccxt 4.2.86__py2.py3-none-any.whl → 4.2.88__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 (82) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/ascendex.py +16 -6
  3. ccxt/async_support/__init__.py +1 -1
  4. ccxt/async_support/ascendex.py +16 -6
  5. ccxt/async_support/base/exchange.py +1 -1
  6. ccxt/async_support/binance.py +28 -11
  7. ccxt/async_support/bingx.py +39 -3
  8. ccxt/async_support/bitfinex.py +2 -0
  9. ccxt/async_support/bitfinex2.py +18 -4
  10. ccxt/async_support/bitflyer.py +18 -0
  11. ccxt/async_support/bitget.py +37 -22
  12. ccxt/async_support/bitopro.py +2 -0
  13. ccxt/async_support/bitrue.py +16 -8
  14. ccxt/async_support/bitvavo.py +2 -0
  15. ccxt/async_support/btcmarkets.py +1 -1
  16. ccxt/async_support/btcturk.py +2 -1
  17. ccxt/async_support/coinex.py +182 -58
  18. ccxt/async_support/cryptocom.py +1 -1
  19. ccxt/async_support/currencycom.py +1 -1
  20. ccxt/async_support/delta.py +8 -6
  21. ccxt/async_support/digifinex.py +9 -7
  22. ccxt/async_support/exmo.py +15 -15
  23. ccxt/async_support/gate.py +23 -20
  24. ccxt/async_support/hitbtc.py +31 -7
  25. ccxt/async_support/htx.py +2 -2
  26. ccxt/async_support/huobijp.py +1 -1
  27. ccxt/async_support/hyperliquid.py +242 -16
  28. ccxt/async_support/idex.py +1 -1
  29. ccxt/async_support/krakenfutures.py +4 -5
  30. ccxt/async_support/kucoin.py +7 -4
  31. ccxt/async_support/kucoinfutures.py +2 -2
  32. ccxt/async_support/lbank.py +2 -0
  33. ccxt/async_support/mexc.py +4 -4
  34. ccxt/async_support/oceanex.py +1 -1
  35. ccxt/async_support/okx.py +29 -15
  36. ccxt/async_support/phemex.py +6 -4
  37. ccxt/async_support/wazirx.py +1 -1
  38. ccxt/async_support/zonda.py +2 -0
  39. ccxt/base/exchange.py +22 -3
  40. ccxt/base/types.py +12 -0
  41. ccxt/binance.py +28 -11
  42. ccxt/bingx.py +39 -3
  43. ccxt/bitfinex.py +2 -0
  44. ccxt/bitfinex2.py +18 -4
  45. ccxt/bitflyer.py +18 -0
  46. ccxt/bitget.py +37 -22
  47. ccxt/bitopro.py +2 -0
  48. ccxt/bitrue.py +16 -8
  49. ccxt/bitvavo.py +2 -0
  50. ccxt/btcmarkets.py +1 -1
  51. ccxt/btcturk.py +2 -1
  52. ccxt/coinex.py +182 -58
  53. ccxt/cryptocom.py +1 -1
  54. ccxt/currencycom.py +1 -1
  55. ccxt/delta.py +8 -6
  56. ccxt/digifinex.py +9 -7
  57. ccxt/exmo.py +15 -15
  58. ccxt/gate.py +23 -20
  59. ccxt/hitbtc.py +31 -7
  60. ccxt/htx.py +2 -2
  61. ccxt/huobijp.py +1 -1
  62. ccxt/hyperliquid.py +241 -16
  63. ccxt/idex.py +1 -1
  64. ccxt/krakenfutures.py +4 -5
  65. ccxt/kucoin.py +7 -4
  66. ccxt/kucoinfutures.py +2 -2
  67. ccxt/lbank.py +2 -0
  68. ccxt/mexc.py +4 -4
  69. ccxt/oceanex.py +1 -1
  70. ccxt/okx.py +29 -15
  71. ccxt/phemex.py +6 -4
  72. ccxt/pro/__init__.py +1 -1
  73. ccxt/pro/kucoin.py +10 -6
  74. ccxt/test/base/test_last_price.py +0 -1
  75. ccxt/test/base/test_shared_methods.py +1 -2
  76. ccxt/test/base/test_status.py +1 -1
  77. ccxt/wazirx.py +1 -1
  78. ccxt/zonda.py +2 -0
  79. {ccxt-4.2.86.dist-info → ccxt-4.2.88.dist-info}/METADATA +5 -6
  80. {ccxt-4.2.86.dist-info → ccxt-4.2.88.dist-info}/RECORD +82 -82
  81. {ccxt-4.2.86.dist-info → ccxt-4.2.88.dist-info}/WHEEL +0 -0
  82. {ccxt-4.2.86.dist-info → ccxt-4.2.88.dist-info}/top_level.txt +0 -0
ccxt/bitflyer.py CHANGED
@@ -11,6 +11,7 @@ from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
13
13
  from ccxt.base.errors import OrderNotFound
14
+ from ccxt.base.errors import OnMaintenance
14
15
  from ccxt.base.decimal_to_precision import TICK_SIZE
15
16
  from ccxt.base.precise import Precise
16
17
 
@@ -118,6 +119,11 @@ class bitflyer(Exchange, ImplicitAPI):
118
119
  },
119
120
  },
120
121
  'precisionMode': TICK_SIZE,
122
+ 'exceptions': {
123
+ 'exact': {
124
+ '-2': OnMaintenance, # {"status":-2,"error_message":"Under maintenance","data":null}
125
+ },
126
+ },
121
127
  })
122
128
 
123
129
  def parse_expiry_date(self, expiry):
@@ -973,3 +979,15 @@ class bitflyer(Exchange, ImplicitAPI):
973
979
  'Content-Type': 'application/json',
974
980
  }
975
981
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
982
+
983
+ def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
984
+ if response is None:
985
+ return None # fallback to the default error handler
986
+ feedback = self.id + ' ' + body
987
+ # i.e. {"status":-2,"error_message":"Under maintenance","data":null}
988
+ errorMessage = self.safe_string(response, 'error_message')
989
+ statusCode = self.safe_number(response, 'status')
990
+ if errorMessage is not None:
991
+ self.throw_exactly_matched_exception(self.exceptions['exact'], statusCode, feedback)
992
+ self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
993
+ return None
ccxt/bitget.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitget import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Balances, Currency, FundingHistory, Int, Leverage, Liquidation, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currency, FundingHistory, Int, Liquidation, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import PermissionDenied
@@ -1240,6 +1240,7 @@ class bitget(Exchange, ImplicitAPI):
1240
1240
  '40768': OrderNotFound, # Order does not exist"
1241
1241
  '41114': OnMaintenance, # {"code":"41114","msg":"The current trading pair is under maintenance, please refer to the official announcement for the opening time","requestTime":1679196062544,"data":null}
1242
1242
  '43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
1243
+ '43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
1243
1244
  '43025': InvalidOrder, # Plan order does not exist
1244
1245
  '43115': OnMaintenance, # {"code":"43115","msg":"The current trading pair is opening soon, please refer to the official announcement for the opening time","requestTime":1688907202434,"data":null}
1245
1246
  '45110': InvalidOrder, # {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1669911118932,"data":null}
@@ -1315,6 +1316,7 @@ class bitget(Exchange, ImplicitAPI):
1315
1316
  'commonCurrencies': {
1316
1317
  'JADE': 'Jade Protocol',
1317
1318
  'DEGEN': 'DegenReborn',
1319
+ 'TONCOIN': 'TON',
1318
1320
  },
1319
1321
  'options': {
1320
1322
  'timeframes': {
@@ -1852,8 +1854,8 @@ class bitget(Exchange, ImplicitAPI):
1852
1854
  data = self.safe_value(response, 'data', [])
1853
1855
  for i in range(0, len(data)):
1854
1856
  entry = data[i]
1855
- id = self.safe_string(entry, 'coinId')
1856
- code = self.safe_currency_code(self.safe_string(entry, 'coin'))
1857
+ id = self.safe_string(entry, 'coin') # we don't use 'coinId' has no use. it is 'coin' field that needs to be used in currency related endpoints(deposit, withdraw, etc..)
1858
+ code = self.safe_currency_code(id)
1857
1859
  chains = self.safe_value(entry, 'chains', [])
1858
1860
  networks = {}
1859
1861
  deposit = False
@@ -1970,7 +1972,7 @@ class bitget(Exchange, ImplicitAPI):
1970
1972
  raise ArgumentsRequired(self.id + ' fetchMarketLeverageTiers() requires a code argument')
1971
1973
  params = self.omit(params, 'code')
1972
1974
  currency = self.currency(code)
1973
- request['coin'] = currency['code']
1975
+ request['coin'] = currency['id']
1974
1976
  response = self.privateMarginGetV2MarginCrossedTierData(self.extend(request, params))
1975
1977
  else:
1976
1978
  raise BadRequest(self.id + ' fetchMarketLeverageTiers() symbol does not support market ' + market['symbol'])
@@ -2117,7 +2119,7 @@ class bitget(Exchange, ImplicitAPI):
2117
2119
  if since is None:
2118
2120
  since = self.milliseconds() - 7776000000 # 90 days
2119
2121
  request = {
2120
- 'coin': currency['code'],
2122
+ 'coin': currency['id'],
2121
2123
  'startTime': since,
2122
2124
  'endTime': self.milliseconds(),
2123
2125
  }
@@ -2172,7 +2174,7 @@ class bitget(Exchange, ImplicitAPI):
2172
2174
  currency = self.currency(code)
2173
2175
  networkId = self.network_code_to_id(chain)
2174
2176
  request = {
2175
- 'coin': currency['code'],
2177
+ 'coin': currency['id'],
2176
2178
  'address': address,
2177
2179
  'chain': networkId,
2178
2180
  'size': amount,
@@ -2251,7 +2253,7 @@ class bitget(Exchange, ImplicitAPI):
2251
2253
  if since is None:
2252
2254
  since = self.milliseconds() - 7776000000 # 90 days
2253
2255
  request = {
2254
- 'coin': currency['code'],
2256
+ 'coin': currency['id'],
2255
2257
  'startTime': since,
2256
2258
  'endTime': self.milliseconds(),
2257
2259
  }
@@ -2389,7 +2391,7 @@ class bitget(Exchange, ImplicitAPI):
2389
2391
  networkId = self.network_code_to_id(networkCode, code)
2390
2392
  currency = self.currency(code)
2391
2393
  request = {
2392
- 'coin': currency['code'],
2394
+ 'coin': currency['id'],
2393
2395
  }
2394
2396
  if networkId is not None:
2395
2397
  request['chain'] = networkId
@@ -5491,7 +5493,7 @@ class bitget(Exchange, ImplicitAPI):
5491
5493
  request = {}
5492
5494
  if code is not None:
5493
5495
  currency = self.currency(code)
5494
- request['coin'] = currency['code']
5496
+ request['coin'] = currency['id']
5495
5497
  request, params = self.handle_until_option('endTime', request, params)
5496
5498
  if since is not None:
5497
5499
  request['startTime'] = since
@@ -6427,7 +6429,7 @@ class bitget(Exchange, ImplicitAPI):
6427
6429
  sorted = self.sort_by(result, 'timestamp')
6428
6430
  return self.filter_by_since_limit(sorted, since, limit)
6429
6431
 
6430
- def modify_margin_helper(self, symbol: str, amount, type, params={}):
6432
+ def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
6431
6433
  self.load_markets()
6432
6434
  holdSide = self.safe_string(params, 'holdSide')
6433
6435
  sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
@@ -6461,19 +6463,32 @@ class bitget(Exchange, ImplicitAPI):
6461
6463
  'type': type,
6462
6464
  })
6463
6465
 
6464
- def parse_margin_modification(self, data, market: Market = None):
6466
+ def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
6467
+ #
6468
+ # addMargin/reduceMargin
6469
+ #
6470
+ # {
6471
+ # "code": "00000",
6472
+ # "msg": "success",
6473
+ # "requestTime": 1700813444618,
6474
+ # "data": ""
6475
+ # }
6476
+ #
6465
6477
  errorCode = self.safe_string(data, 'code')
6466
6478
  status = 'ok' if (errorCode == '00000') else 'failed'
6467
6479
  return {
6468
6480
  'info': data,
6481
+ 'symbol': market['symbol'],
6469
6482
  'type': None,
6470
6483
  'amount': None,
6484
+ 'total': None,
6471
6485
  'code': market['settle'],
6472
- 'symbol': market['symbol'],
6473
6486
  'status': status,
6487
+ 'timestamp': None,
6488
+ 'datetime': None,
6474
6489
  }
6475
6490
 
6476
- def reduce_margin(self, symbol: str, amount, params={}):
6491
+ def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
6477
6492
  """
6478
6493
  remove margin from a position
6479
6494
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin
@@ -6489,7 +6504,7 @@ class bitget(Exchange, ImplicitAPI):
6489
6504
  raise ArgumentsRequired(self.id + ' reduceMargin() requires a holdSide parameter, either long or short')
6490
6505
  return self.modify_margin_helper(symbol, amount, 'reduce', params)
6491
6506
 
6492
- def add_margin(self, symbol: str, amount, params={}):
6507
+ def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
6493
6508
  """
6494
6509
  add margin
6495
6510
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin
@@ -6792,7 +6807,7 @@ class bitget(Exchange, ImplicitAPI):
6792
6807
  type = self.safe_string(accountsByType, fromAccount)
6793
6808
  currency = self.currency(code)
6794
6809
  request = {
6795
- 'coin': currency['code'],
6810
+ 'coin': currency['id'],
6796
6811
  'fromType': type,
6797
6812
  }
6798
6813
  if since is not None:
@@ -6847,7 +6862,7 @@ class bitget(Exchange, ImplicitAPI):
6847
6862
  'fromType': fromType,
6848
6863
  'toType': toType,
6849
6864
  'amount': amount,
6850
- 'coin': currency['code'],
6865
+ 'coin': currency['id'],
6851
6866
  }
6852
6867
  symbol = self.safe_string(params, 'symbol')
6853
6868
  params = self.omit(params, 'symbol')
@@ -7027,7 +7042,7 @@ class bitget(Exchange, ImplicitAPI):
7027
7042
  self.load_markets()
7028
7043
  currency = self.currency(code)
7029
7044
  request = {
7030
- 'coin': currency['code'],
7045
+ 'coin': currency['id'],
7031
7046
  'borrowAmount': self.currency_to_precision(code, amount),
7032
7047
  }
7033
7048
  response = self.privateMarginPostV2MarginCrossedAccountBorrow(self.extend(request, params))
@@ -7060,7 +7075,7 @@ class bitget(Exchange, ImplicitAPI):
7060
7075
  currency = self.currency(code)
7061
7076
  market = self.market(symbol)
7062
7077
  request = {
7063
- 'coin': currency['code'],
7078
+ 'coin': currency['id'],
7064
7079
  'borrowAmount': self.currency_to_precision(code, amount),
7065
7080
  'symbol': market['id'],
7066
7081
  }
@@ -7095,7 +7110,7 @@ class bitget(Exchange, ImplicitAPI):
7095
7110
  currency = self.currency(code)
7096
7111
  market = self.market(symbol)
7097
7112
  request = {
7098
- 'coin': currency['code'],
7113
+ 'coin': currency['id'],
7099
7114
  'repayAmount': self.currency_to_precision(code, amount),
7100
7115
  'symbol': market['id'],
7101
7116
  }
@@ -7129,7 +7144,7 @@ class bitget(Exchange, ImplicitAPI):
7129
7144
  self.load_markets()
7130
7145
  currency = self.currency(code)
7131
7146
  request = {
7132
- 'coin': currency['code'],
7147
+ 'coin': currency['id'],
7133
7148
  'repayAmount': self.currency_to_precision(code, amount),
7134
7149
  }
7135
7150
  response = self.privateMarginPostV2MarginCrossedAccountRepay(self.extend(request, params))
@@ -7475,7 +7490,7 @@ class bitget(Exchange, ImplicitAPI):
7475
7490
  self.load_markets()
7476
7491
  currency = self.currency(code)
7477
7492
  request = {
7478
- 'coin': currency['code'],
7493
+ 'coin': currency['id'],
7479
7494
  }
7480
7495
  response = self.privateMarginGetV2MarginCrossedInterestRateAndLimit(self.extend(request, params))
7481
7496
  #
@@ -7566,7 +7581,7 @@ class bitget(Exchange, ImplicitAPI):
7566
7581
  currency = None
7567
7582
  if code is not None:
7568
7583
  currency = self.currency(code)
7569
- request['coin'] = currency['code']
7584
+ request['coin'] = currency['id']
7570
7585
  if since is not None:
7571
7586
  request['startTime'] = since
7572
7587
  else:
ccxt/bitopro.py CHANGED
@@ -735,6 +735,8 @@ class bitopro(Exchange, ImplicitAPI):
735
735
  # we need to have a limit argument because "to" and "from" are required
736
736
  if limit is None:
737
737
  limit = 500
738
+ else:
739
+ limit = min(limit, 75000) # supports slightly more than 75k candles atm, but limit here to avoid errors
738
740
  timeframeInSeconds = self.parse_timeframe(timeframe)
739
741
  alignedSince = None
740
742
  if since is None:
ccxt/bitrue.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitrue import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import PermissionDenied
@@ -1310,8 +1310,6 @@ class bitrue(Exchange, ImplicitAPI):
1310
1310
  'interval': self.safe_string(timeframesFuture, timeframe, '1min'),
1311
1311
  }
1312
1312
  if limit is not None:
1313
- if limit > 300:
1314
- limit = 300
1315
1313
  request['limit'] = limit
1316
1314
  if market['linear']:
1317
1315
  response = self.fapiV1PublicGetKlines(self.extend(request, params))
@@ -1326,8 +1324,6 @@ class bitrue(Exchange, ImplicitAPI):
1326
1324
  'scale': self.safe_string(timeframesSpot, timeframe, '1m'),
1327
1325
  }
1328
1326
  if limit is not None:
1329
- if limit > 1440:
1330
- limit = 1440
1331
1327
  request['limit'] = limit
1332
1328
  if since is not None:
1333
1329
  request['fromIdx'] = since
@@ -2842,17 +2838,29 @@ class bitrue(Exchange, ImplicitAPI):
2842
2838
  response = self.dapiV2PrivatePostLevelEdit(self.extend(request, params))
2843
2839
  return response
2844
2840
 
2845
- def parse_margin_modification(self, data, market=None):
2841
+ def parse_margin_modification(self, data, market=None) -> MarginModification:
2842
+ #
2843
+ # setMargin
2844
+ #
2845
+ # {
2846
+ # "code": 0,
2847
+ # "msg": "success"
2848
+ # "data": null
2849
+ # }
2850
+ #
2846
2851
  return {
2847
2852
  'info': data,
2853
+ 'symbol': market['symbol'],
2848
2854
  'type': None,
2849
2855
  'amount': None,
2856
+ 'total': None,
2850
2857
  'code': None,
2851
- 'symbol': market['symbol'],
2852
2858
  'status': None,
2859
+ 'timestamp': None,
2860
+ 'datetime': None,
2853
2861
  }
2854
2862
 
2855
- def set_margin(self, symbol: str, amount: float, params={}):
2863
+ def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2856
2864
  """
2857
2865
  Either adds or reduces margin in an isolated position in order to set the margin to a specific value
2858
2866
  :see: https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
ccxt/bitvavo.py CHANGED
@@ -923,6 +923,8 @@ class bitvavo(Exchange, ImplicitAPI):
923
923
  request['start'] = since
924
924
  if limit is None:
925
925
  limit = 1440
926
+ else:
927
+ limit = min(limit, 1440)
926
928
  request['end'] = self.sum(since, limit * duration * 1000)
927
929
  request, params = self.handle_until_option('end', request, params)
928
930
  if limit is not None:
ccxt/btcmarkets.py CHANGED
@@ -522,7 +522,7 @@ class btcmarkets(Exchange, ImplicitAPI):
522
522
  if since is not None:
523
523
  request['from'] = self.iso8601(since)
524
524
  if limit is not None:
525
- request['limit'] = limit # default is 10, max 200
525
+ request['limit'] = min(limit, 200) # default is 10, max 200
526
526
  response = self.publicGetMarketsMarketIdCandles(self.extend(request, params))
527
527
  #
528
528
  # [
ccxt/btcturk.py CHANGED
@@ -570,6 +570,7 @@ class btcturk(Exchange, ImplicitAPI):
570
570
  elif limit is None: # since will also be None
571
571
  limit = 100 # default value
572
572
  if limit is not None:
573
+ limit = min(limit, 11000) # max 11000 candles diapason can be covered
573
574
  if timeframe == '1y': # difficult with leap years
574
575
  raise BadRequest(self.id + ' fetchOHLCV() does not accept a limit parameter when timeframe == "1y"')
575
576
  seconds = self.parse_timeframe(timeframe)
@@ -578,7 +579,7 @@ class btcturk(Exchange, ImplicitAPI):
578
579
  to = self.parse_to_int(since / 1000) + limitSeconds
579
580
  request['to'] = min(request['to'], to)
580
581
  else:
581
- request['from'] = self.parse_to_int(until / 1000) - limitSeconds
582
+ request['from'] = self.parse_to_int(0 / 1000) - limitSeconds
582
583
  response = self.graphGetKlinesHistory(self.extend(request, params))
583
584
  #
584
585
  # {