ccxt 4.2.86__py2.py3-none-any.whl → 4.2.87__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 (78) 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 +18 -5
  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 +20 -6
  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/currencycom.py +1 -1
  19. ccxt/async_support/delta.py +8 -6
  20. ccxt/async_support/digifinex.py +9 -7
  21. ccxt/async_support/exmo.py +15 -15
  22. ccxt/async_support/gate.py +9 -6
  23. ccxt/async_support/hitbtc.py +31 -7
  24. ccxt/async_support/htx.py +2 -2
  25. ccxt/async_support/huobijp.py +1 -1
  26. ccxt/async_support/hyperliquid.py +242 -16
  27. ccxt/async_support/idex.py +1 -1
  28. ccxt/async_support/krakenfutures.py +2 -4
  29. ccxt/async_support/kucoinfutures.py +2 -2
  30. ccxt/async_support/lbank.py +2 -0
  31. ccxt/async_support/mexc.py +3 -3
  32. ccxt/async_support/oceanex.py +1 -1
  33. ccxt/async_support/okx.py +29 -15
  34. ccxt/async_support/phemex.py +6 -4
  35. ccxt/async_support/wazirx.py +1 -1
  36. ccxt/async_support/zonda.py +2 -0
  37. ccxt/base/exchange.py +1 -1
  38. ccxt/base/types.py +12 -0
  39. ccxt/binance.py +18 -5
  40. ccxt/bingx.py +39 -3
  41. ccxt/bitfinex.py +2 -0
  42. ccxt/bitfinex2.py +18 -4
  43. ccxt/bitflyer.py +18 -0
  44. ccxt/bitget.py +20 -6
  45. ccxt/bitopro.py +2 -0
  46. ccxt/bitrue.py +16 -8
  47. ccxt/bitvavo.py +2 -0
  48. ccxt/btcmarkets.py +1 -1
  49. ccxt/btcturk.py +2 -1
  50. ccxt/coinex.py +182 -58
  51. ccxt/currencycom.py +1 -1
  52. ccxt/delta.py +8 -6
  53. ccxt/digifinex.py +9 -7
  54. ccxt/exmo.py +15 -15
  55. ccxt/gate.py +9 -6
  56. ccxt/hitbtc.py +31 -7
  57. ccxt/htx.py +2 -2
  58. ccxt/huobijp.py +1 -1
  59. ccxt/hyperliquid.py +241 -16
  60. ccxt/idex.py +1 -1
  61. ccxt/krakenfutures.py +2 -4
  62. ccxt/kucoinfutures.py +2 -2
  63. ccxt/lbank.py +2 -0
  64. ccxt/mexc.py +3 -3
  65. ccxt/oceanex.py +1 -1
  66. ccxt/okx.py +29 -15
  67. ccxt/phemex.py +6 -4
  68. ccxt/pro/__init__.py +1 -1
  69. ccxt/pro/kucoin.py +10 -6
  70. ccxt/test/base/test_last_price.py +0 -1
  71. ccxt/test/base/test_shared_methods.py +1 -2
  72. ccxt/test/base/test_status.py +1 -1
  73. ccxt/wazirx.py +1 -1
  74. ccxt/zonda.py +2 -0
  75. {ccxt-4.2.86.dist-info → ccxt-4.2.87.dist-info}/METADATA +4 -4
  76. {ccxt-4.2.86.dist-info → ccxt-4.2.87.dist-info}/RECORD +78 -78
  77. {ccxt-4.2.86.dist-info → ccxt-4.2.87.dist-info}/WHEEL +0 -0
  78. {ccxt-4.2.86.dist-info → ccxt-4.2.87.dist-info}/top_level.txt +0 -0
ccxt/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.2.86'
25
+ __version__ = '4.2.87'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/ascendex.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Int, Leverage, Leverages, MarginMode, MarginModes, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currency, Int, Leverage, Leverages, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -2701,7 +2701,7 @@ class ascendex(Exchange, ImplicitAPI):
2701
2701
  result = self.parse_funding_rates(contracts)
2702
2702
  return self.filter_by_array(result, 'symbol', symbols)
2703
2703
 
2704
- def modify_margin_helper(self, symbol: str, amount, type, params={}):
2704
+ def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2705
2705
  self.load_markets()
2706
2706
  self.load_accounts()
2707
2707
  market = self.market(symbol)
@@ -2728,19 +2728,29 @@ class ascendex(Exchange, ImplicitAPI):
2728
2728
  'type': type,
2729
2729
  })
2730
2730
 
2731
- def parse_margin_modification(self, data, market: Market = None):
2731
+ def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
2732
+ #
2733
+ # addMargin/reduceMargin
2734
+ #
2735
+ # {
2736
+ # "code": 0
2737
+ # }
2738
+ #
2732
2739
  errorCode = self.safe_string(data, 'code')
2733
2740
  status = 'ok' if (errorCode == '0') else 'failed'
2734
2741
  return {
2735
2742
  'info': data,
2743
+ 'symbol': market['symbol'],
2736
2744
  'type': None,
2737
2745
  'amount': None,
2746
+ 'total': None,
2738
2747
  'code': market['quote'],
2739
- 'symbol': market['symbol'],
2740
2748
  'status': status,
2749
+ 'timestamp': None,
2750
+ 'datetime': None,
2741
2751
  }
2742
2752
 
2743
- def reduce_margin(self, symbol: str, amount, params={}):
2753
+ def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
2744
2754
  """
2745
2755
  remove margin from a position
2746
2756
  :param str symbol: unified market symbol
@@ -2750,7 +2760,7 @@ class ascendex(Exchange, ImplicitAPI):
2750
2760
  """
2751
2761
  return self.modify_margin_helper(symbol, -amount, 'reduce', params)
2752
2762
 
2753
- def add_margin(self, symbol: str, amount, params={}):
2763
+ def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
2754
2764
  """
2755
2765
  add margin
2756
2766
  :param str symbol: unified market symbol
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.86'
7
+ __version__ = '4.2.87'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Int, Leverage, Leverages, MarginMode, MarginModes, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currency, Int, Leverage, Leverages, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -2701,7 +2701,7 @@ class ascendex(Exchange, ImplicitAPI):
2701
2701
  result = self.parse_funding_rates(contracts)
2702
2702
  return self.filter_by_array(result, 'symbol', symbols)
2703
2703
 
2704
- async def modify_margin_helper(self, symbol: str, amount, type, params={}):
2704
+ async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2705
2705
  await self.load_markets()
2706
2706
  await self.load_accounts()
2707
2707
  market = self.market(symbol)
@@ -2728,19 +2728,29 @@ class ascendex(Exchange, ImplicitAPI):
2728
2728
  'type': type,
2729
2729
  })
2730
2730
 
2731
- def parse_margin_modification(self, data, market: Market = None):
2731
+ def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
2732
+ #
2733
+ # addMargin/reduceMargin
2734
+ #
2735
+ # {
2736
+ # "code": 0
2737
+ # }
2738
+ #
2732
2739
  errorCode = self.safe_string(data, 'code')
2733
2740
  status = 'ok' if (errorCode == '0') else 'failed'
2734
2741
  return {
2735
2742
  'info': data,
2743
+ 'symbol': market['symbol'],
2736
2744
  'type': None,
2737
2745
  'amount': None,
2746
+ 'total': None,
2738
2747
  'code': market['quote'],
2739
- 'symbol': market['symbol'],
2740
2748
  'status': status,
2749
+ 'timestamp': None,
2750
+ 'datetime': None,
2741
2751
  }
2742
2752
 
2743
- async def reduce_margin(self, symbol: str, amount, params={}):
2753
+ async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
2744
2754
  """
2745
2755
  remove margin from a position
2746
2756
  :param str symbol: unified market symbol
@@ -2750,7 +2760,7 @@ class ascendex(Exchange, ImplicitAPI):
2750
2760
  """
2751
2761
  return await self.modify_margin_helper(symbol, -amount, 'reduce', params)
2752
2762
 
2753
- async def add_margin(self, symbol: str, amount, params={}):
2763
+ async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
2754
2764
  """
2755
2765
  add margin
2756
2766
  :param str symbol: unified market symbol
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.2.86'
5
+ __version__ = '4.2.87'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -10313,7 +10313,17 @@ class binance(Exchange, ImplicitAPI):
10313
10313
  'code': code,
10314
10314
  })
10315
10315
 
10316
- def parse_margin_modification(self, data, market: Market = None):
10316
+ def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
10317
+ #
10318
+ # add/reduce margin
10319
+ #
10320
+ # {
10321
+ # "code": 200,
10322
+ # "msg": "Successfully modify position margin.",
10323
+ # "amount": 0.001,
10324
+ # "type": 1
10325
+ # }
10326
+ #
10317
10327
  rawType = self.safe_integer(data, 'type')
10318
10328
  resultType = 'add' if (rawType == 1) else 'reduce'
10319
10329
  resultAmount = self.safe_number(data, 'amount')
@@ -10321,14 +10331,17 @@ class binance(Exchange, ImplicitAPI):
10321
10331
  status = 'ok' if (errorCode == '200') else 'failed'
10322
10332
  return {
10323
10333
  'info': data,
10334
+ 'symbol': market['symbol'],
10324
10335
  'type': resultType,
10325
10336
  'amount': resultAmount,
10337
+ 'total': None,
10326
10338
  'code': None,
10327
- 'symbol': market['symbol'],
10328
10339
  'status': status,
10340
+ 'timestamp': None,
10341
+ 'datetime': None,
10329
10342
  }
10330
10343
 
10331
- async def reduce_margin(self, symbol: str, amount, params={}):
10344
+ async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
10332
10345
  """
10333
10346
  :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
10334
10347
  :see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
@@ -10340,7 +10353,7 @@ class binance(Exchange, ImplicitAPI):
10340
10353
  """
10341
10354
  return await self.modify_margin_helper(symbol, amount, 2, params)
10342
10355
 
10343
- async def add_margin(self, symbol: str, amount, params={}):
10356
+ async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
10344
10357
  """
10345
10358
  :see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
10346
10359
  :see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
@@ -8,7 +8,7 @@ from ccxt.abstract.bingx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import numbers
11
- from ccxt.base.types import Balances, Currency, Int, Leverage, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Currency, Int, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -44,6 +44,7 @@ class bingx(Exchange, ImplicitAPI):
44
44
  'swap': True,
45
45
  'future': False,
46
46
  'option': False,
47
+ 'addMargin': True,
47
48
  'cancelAllOrders': True,
48
49
  'cancelOrder': True,
49
50
  'cancelOrders': True,
@@ -90,6 +91,7 @@ class bingx(Exchange, ImplicitAPI):
90
91
  'fetchTrades': True,
91
92
  'fetchTransfers': True,
92
93
  'fetchWithdrawals': True,
94
+ 'reduceMargin': True,
93
95
  'setLeverage': True,
94
96
  'setMargin': True,
95
97
  'setMarginMode': True,
@@ -3247,7 +3249,19 @@ class bingx(Exchange, ImplicitAPI):
3247
3249
  }
3248
3250
  return await self.swapV2PrivatePostTradeMarginType(self.extend(request, params))
3249
3251
 
3250
- async def set_margin(self, symbol: str, amount: float, params={}):
3252
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3253
+ request = {
3254
+ 'type': 1,
3255
+ }
3256
+ return await self.set_margin(symbol, amount, self.extend(request, params))
3257
+
3258
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3259
+ request = {
3260
+ 'type': 2,
3261
+ }
3262
+ return await self.set_margin(symbol, amount, self.extend(request, params))
3263
+
3264
+ async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3251
3265
  """
3252
3266
  Either adds or reduces margin in an isolated position in order to set the margin to a specific value
3253
3267
  :see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Adjust%20isolated%20margin
@@ -3277,7 +3291,29 @@ class bingx(Exchange, ImplicitAPI):
3277
3291
  # "type": 1
3278
3292
  # }
3279
3293
  #
3280
- return response
3294
+ return self.parse_margin_modification(response, market)
3295
+
3296
+ def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3297
+ #
3298
+ # {
3299
+ # "code": 0,
3300
+ # "msg": "",
3301
+ # "amount": 1,
3302
+ # "type": 1
3303
+ # }
3304
+ #
3305
+ type = self.safe_string(data, 'type')
3306
+ return {
3307
+ 'info': data,
3308
+ 'symbol': self.safe_string(market, 'symbol'),
3309
+ 'type': 'add' if (type == '1') else 'reduce',
3310
+ 'amount': self.safe_number(data, 'amount'),
3311
+ 'total': self.safe_number(data, 'margin'),
3312
+ 'code': self.safe_string(market, 'settle'),
3313
+ 'status': None,
3314
+ 'timestamp': None,
3315
+ 'datetime': None,
3316
+ }
3281
3317
 
3282
3318
  async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
3283
3319
  """
@@ -1259,6 +1259,8 @@ class bitfinex(Exchange, ImplicitAPI):
1259
1259
  await self.load_markets()
1260
1260
  if limit is None:
1261
1261
  limit = 100
1262
+ else:
1263
+ limit = min(limit, 10000)
1262
1264
  market = self.market(symbol)
1263
1265
  v2id = 't' + market['id']
1264
1266
  request = {
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex2 import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -1343,6 +1343,8 @@ class bitfinex2(Exchange, ImplicitAPI):
1343
1343
  market = self.market(symbol)
1344
1344
  if limit is None:
1345
1345
  limit = 10000
1346
+ else:
1347
+ limit = min(limit, 10000)
1346
1348
  request = {
1347
1349
  'symbol': market['id'],
1348
1350
  'timeframe': self.safe_string(self.timeframes, timeframe, timeframe),
@@ -3279,7 +3281,7 @@ class bitfinex2(Exchange, ImplicitAPI):
3279
3281
  'datetime': self.iso8601(timestamp),
3280
3282
  })
3281
3283
 
3282
- async def set_margin(self, symbol: str, amount: float, params={}):
3284
+ async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3283
3285
  """
3284
3286
  either adds or reduces margin in a swap position in order to set the margin to a specific value
3285
3287
  :see: https://docs.bitfinex.com/reference/rest-auth-deriv-pos-collateral-set
@@ -3307,16 +3309,28 @@ class bitfinex2(Exchange, ImplicitAPI):
3307
3309
  data = self.safe_value(response, 0)
3308
3310
  return self.parse_margin_modification(data, market)
3309
3311
 
3310
- def parse_margin_modification(self, data, market=None):
3312
+ def parse_margin_modification(self, data, market=None) -> MarginModification:
3313
+ #
3314
+ # setMargin
3315
+ #
3316
+ # [
3317
+ # [
3318
+ # 1
3319
+ # ]
3320
+ # ]
3321
+ #
3311
3322
  marginStatusRaw = data[0]
3312
3323
  marginStatus = 'ok' if (marginStatusRaw == 1) else 'failed'
3313
3324
  return {
3314
3325
  'info': data,
3326
+ 'symbol': market['symbol'],
3315
3327
  'type': None,
3316
3328
  'amount': None,
3329
+ 'total': None,
3317
3330
  'code': None,
3318
- 'symbol': market['symbol'],
3319
3331
  'status': marginStatus,
3332
+ 'timestamp': None,
3333
+ 'datetime': None,
3320
3334
  }
3321
3335
 
3322
3336
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
@@ -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
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- 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
11
+ 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
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -1241,6 +1241,7 @@ class bitget(Exchange, ImplicitAPI):
1241
1241
  '40768': OrderNotFound, # Order does not exist"
1242
1242
  '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}
1243
1243
  '43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
1244
+ '43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
1244
1245
  '43025': InvalidOrder, # Plan order does not exist
1245
1246
  '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}
1246
1247
  '45110': InvalidOrder, # {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1669911118932,"data":null}
@@ -6428,7 +6429,7 @@ class bitget(Exchange, ImplicitAPI):
6428
6429
  sorted = self.sort_by(result, 'timestamp')
6429
6430
  return self.filter_by_since_limit(sorted, since, limit)
6430
6431
 
6431
- async def modify_margin_helper(self, symbol: str, amount, type, params={}):
6432
+ async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
6432
6433
  await self.load_markets()
6433
6434
  holdSide = self.safe_string(params, 'holdSide')
6434
6435
  sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
@@ -6462,19 +6463,32 @@ class bitget(Exchange, ImplicitAPI):
6462
6463
  'type': type,
6463
6464
  })
6464
6465
 
6465
- 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
+ #
6466
6477
  errorCode = self.safe_string(data, 'code')
6467
6478
  status = 'ok' if (errorCode == '00000') else 'failed'
6468
6479
  return {
6469
6480
  'info': data,
6481
+ 'symbol': market['symbol'],
6470
6482
  'type': None,
6471
6483
  'amount': None,
6484
+ 'total': None,
6472
6485
  'code': market['settle'],
6473
- 'symbol': market['symbol'],
6474
6486
  'status': status,
6487
+ 'timestamp': None,
6488
+ 'datetime': None,
6475
6489
  }
6476
6490
 
6477
- async def reduce_margin(self, symbol: str, amount, params={}):
6491
+ async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
6478
6492
  """
6479
6493
  remove margin from a position
6480
6494
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin
@@ -6490,7 +6504,7 @@ class bitget(Exchange, ImplicitAPI):
6490
6504
  raise ArgumentsRequired(self.id + ' reduceMargin() requires a holdSide parameter, either long or short')
6491
6505
  return await self.modify_margin_helper(symbol, amount, 'reduce', params)
6492
6506
 
6493
- async def add_margin(self, symbol: str, amount, params={}):
6507
+ async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
6494
6508
  """
6495
6509
  add margin
6496
6510
  :see: https://www.bitget.com/api-doc/contract/account/Change-Margin
@@ -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:
@@ -8,7 +8,7 @@ from ccxt.abstract.bitrue import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -1311,8 +1311,6 @@ class bitrue(Exchange, ImplicitAPI):
1311
1311
  'interval': self.safe_string(timeframesFuture, timeframe, '1min'),
1312
1312
  }
1313
1313
  if limit is not None:
1314
- if limit > 300:
1315
- limit = 300
1316
1314
  request['limit'] = limit
1317
1315
  if market['linear']:
1318
1316
  response = await self.fapiV1PublicGetKlines(self.extend(request, params))
@@ -1327,8 +1325,6 @@ class bitrue(Exchange, ImplicitAPI):
1327
1325
  'scale': self.safe_string(timeframesSpot, timeframe, '1m'),
1328
1326
  }
1329
1327
  if limit is not None:
1330
- if limit > 1440:
1331
- limit = 1440
1332
1328
  request['limit'] = limit
1333
1329
  if since is not None:
1334
1330
  request['fromIdx'] = since
@@ -2843,17 +2839,29 @@ class bitrue(Exchange, ImplicitAPI):
2843
2839
  response = await self.dapiV2PrivatePostLevelEdit(self.extend(request, params))
2844
2840
  return response
2845
2841
 
2846
- def parse_margin_modification(self, data, market=None):
2842
+ def parse_margin_modification(self, data, market=None) -> MarginModification:
2843
+ #
2844
+ # setMargin
2845
+ #
2846
+ # {
2847
+ # "code": 0,
2848
+ # "msg": "success"
2849
+ # "data": null
2850
+ # }
2851
+ #
2847
2852
  return {
2848
2853
  'info': data,
2854
+ 'symbol': market['symbol'],
2849
2855
  'type': None,
2850
2856
  'amount': None,
2857
+ 'total': None,
2851
2858
  'code': None,
2852
- 'symbol': market['symbol'],
2853
2859
  'status': None,
2860
+ 'timestamp': None,
2861
+ 'datetime': None,
2854
2862
  }
2855
2863
 
2856
- async def set_margin(self, symbol: str, amount: float, params={}):
2864
+ async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2857
2865
  """
2858
2866
  Either adds or reduces margin in an isolated position in order to set the margin to a specific value
2859
2867
  :see: https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
@@ -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:
@@ -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 = await self.publicGetMarketsMarketIdCandles(self.extend(request, params))
527
527
  #
528
528
  # [
@@ -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 = await self.graphGetKlinesHistory(self.extend(request, params))
583
584
  #
584
585
  # {