ccxt 4.2.88__py2.py3-none-any.whl → 4.2.90__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 (156) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bingx.py +2 -0
  3. ccxt/abstract/bybit.py +2 -0
  4. ccxt/ascendex.py +6 -3
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/ascendex.py +6 -3
  7. ccxt/async_support/base/exchange.py +15 -2
  8. ccxt/async_support/bigone.py +2 -2
  9. ccxt/async_support/binance.py +88 -14
  10. ccxt/async_support/bingx.py +96 -3
  11. ccxt/async_support/bit2c.py +2 -2
  12. ccxt/async_support/bitbank.py +2 -2
  13. ccxt/async_support/bitfinex.py +2 -2
  14. ccxt/async_support/bitfinex2.py +4 -3
  15. ccxt/async_support/bitflyer.py +4 -2
  16. ccxt/async_support/bitget.py +12 -5
  17. ccxt/async_support/bitmart.py +6 -4
  18. ccxt/async_support/bitmex.py +3 -2
  19. ccxt/async_support/bitopro.py +3 -3
  20. ccxt/async_support/bitrue.py +3 -2
  21. ccxt/async_support/bitso.py +2 -2
  22. ccxt/async_support/bitstamp.py +89 -97
  23. ccxt/async_support/bitteam.py +2 -2
  24. ccxt/async_support/bitvavo.py +3 -3
  25. ccxt/async_support/bl3p.py +2 -2
  26. ccxt/async_support/blockchaincom.py +2 -2
  27. ccxt/async_support/blofin.py +4 -2
  28. ccxt/async_support/bybit.py +57 -5
  29. ccxt/async_support/cex.py +3 -3
  30. ccxt/async_support/coinbase.py +42 -22
  31. ccxt/async_support/coinbaseinternational.py +3 -2
  32. ccxt/async_support/coinbasepro.py +3 -3
  33. ccxt/async_support/coincheck.py +2 -2
  34. ccxt/async_support/coinex.py +101 -13
  35. ccxt/async_support/coinlist.py +3 -3
  36. ccxt/async_support/coinmate.py +2 -2
  37. ccxt/async_support/coinmetro.py +2 -2
  38. ccxt/async_support/coinone.py +2 -2
  39. ccxt/async_support/coinsph.py +6 -4
  40. ccxt/async_support/cryptocom.py +1 -0
  41. ccxt/async_support/currencycom.py +3 -3
  42. ccxt/async_support/delta.py +3 -2
  43. ccxt/async_support/deribit.py +3 -3
  44. ccxt/async_support/digifinex.py +7 -4
  45. ccxt/async_support/exmo.py +4 -3
  46. ccxt/async_support/gate.py +8 -4
  47. ccxt/async_support/gemini.py +13 -12
  48. ccxt/async_support/hitbtc.py +8 -5
  49. ccxt/async_support/hollaex.py +3 -3
  50. ccxt/async_support/htx.py +7 -4
  51. ccxt/async_support/huobijp.py +2 -2
  52. ccxt/async_support/hyperliquid.py +3 -2
  53. ccxt/async_support/idex.py +3 -3
  54. ccxt/async_support/independentreserve.py +2 -2
  55. ccxt/async_support/kraken.py +3 -3
  56. ccxt/async_support/kucoin.py +43 -18
  57. ccxt/async_support/kucoinfutures.py +32 -4
  58. ccxt/async_support/kuna.py +2 -2
  59. ccxt/async_support/latoken.py +7 -3
  60. ccxt/async_support/lbank.py +7 -5
  61. ccxt/async_support/luno.py +4 -2
  62. ccxt/async_support/lykke.py +2 -2
  63. ccxt/async_support/mexc.py +57 -9
  64. ccxt/async_support/ndax.py +2 -2
  65. ccxt/async_support/oceanex.py +2 -2
  66. ccxt/async_support/okcoin.py +2 -2
  67. ccxt/async_support/okx.py +149 -12
  68. ccxt/async_support/onetrading.py +3 -3
  69. ccxt/async_support/phemex.py +3 -2
  70. ccxt/async_support/poloniex.py +3 -3
  71. ccxt/async_support/probit.py +2 -2
  72. ccxt/async_support/timex.py +6 -4
  73. ccxt/async_support/upbit.py +2 -2
  74. ccxt/async_support/wazirx.py +2 -2
  75. ccxt/async_support/whitebit.py +3 -3
  76. ccxt/async_support/woo.py +4 -3
  77. ccxt/async_support/yobit.py +2 -2
  78. ccxt/base/exchange.py +65 -12
  79. ccxt/base/types.py +33 -0
  80. ccxt/bigone.py +2 -2
  81. ccxt/binance.py +88 -14
  82. ccxt/bingx.py +96 -3
  83. ccxt/bit2c.py +2 -2
  84. ccxt/bitbank.py +2 -2
  85. ccxt/bitfinex.py +2 -2
  86. ccxt/bitfinex2.py +4 -3
  87. ccxt/bitflyer.py +4 -2
  88. ccxt/bitget.py +12 -5
  89. ccxt/bitmart.py +6 -4
  90. ccxt/bitmex.py +3 -2
  91. ccxt/bitopro.py +3 -3
  92. ccxt/bitrue.py +3 -2
  93. ccxt/bitso.py +2 -2
  94. ccxt/bitstamp.py +89 -97
  95. ccxt/bitteam.py +2 -2
  96. ccxt/bitvavo.py +3 -3
  97. ccxt/bl3p.py +2 -2
  98. ccxt/blockchaincom.py +2 -2
  99. ccxt/blofin.py +4 -2
  100. ccxt/bybit.py +57 -5
  101. ccxt/cex.py +3 -3
  102. ccxt/coinbase.py +42 -22
  103. ccxt/coinbaseinternational.py +3 -2
  104. ccxt/coinbasepro.py +3 -3
  105. ccxt/coincheck.py +2 -2
  106. ccxt/coinex.py +101 -13
  107. ccxt/coinlist.py +3 -3
  108. ccxt/coinmate.py +2 -2
  109. ccxt/coinmetro.py +2 -2
  110. ccxt/coinone.py +2 -2
  111. ccxt/coinsph.py +6 -4
  112. ccxt/cryptocom.py +1 -0
  113. ccxt/currencycom.py +3 -3
  114. ccxt/delta.py +3 -2
  115. ccxt/deribit.py +3 -3
  116. ccxt/digifinex.py +7 -4
  117. ccxt/exmo.py +4 -3
  118. ccxt/gate.py +8 -4
  119. ccxt/gemini.py +13 -12
  120. ccxt/hitbtc.py +8 -5
  121. ccxt/hollaex.py +3 -3
  122. ccxt/htx.py +7 -4
  123. ccxt/huobijp.py +2 -2
  124. ccxt/hyperliquid.py +3 -2
  125. ccxt/idex.py +3 -3
  126. ccxt/independentreserve.py +2 -2
  127. ccxt/kraken.py +3 -3
  128. ccxt/kucoin.py +43 -18
  129. ccxt/kucoinfutures.py +32 -4
  130. ccxt/kuna.py +2 -2
  131. ccxt/latoken.py +7 -3
  132. ccxt/lbank.py +7 -5
  133. ccxt/luno.py +4 -2
  134. ccxt/lykke.py +2 -2
  135. ccxt/mexc.py +57 -9
  136. ccxt/ndax.py +2 -2
  137. ccxt/oceanex.py +2 -2
  138. ccxt/okcoin.py +2 -2
  139. ccxt/okx.py +149 -12
  140. ccxt/onetrading.py +3 -3
  141. ccxt/phemex.py +3 -2
  142. ccxt/poloniex.py +3 -3
  143. ccxt/pro/__init__.py +1 -1
  144. ccxt/pro/bitget.py +2 -0
  145. ccxt/pro/bitvavo.py +2 -2
  146. ccxt/probit.py +2 -2
  147. ccxt/timex.py +6 -4
  148. ccxt/upbit.py +2 -2
  149. ccxt/wazirx.py +2 -2
  150. ccxt/whitebit.py +3 -3
  151. ccxt/woo.py +4 -3
  152. ccxt/yobit.py +2 -2
  153. {ccxt-4.2.88.dist-info → ccxt-4.2.90.dist-info}/METADATA +4 -4
  154. {ccxt-4.2.88.dist-info → ccxt-4.2.90.dist-info}/RECORD +156 -156
  155. {ccxt-4.2.88.dist-info → ccxt-4.2.90.dist-info}/WHEEL +0 -0
  156. {ccxt-4.2.88.dist-info → ccxt-4.2.90.dist-info}/top_level.txt +0 -0
ccxt/latoken.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.latoken import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -401,7 +401,7 @@ class latoken(Exchange, ImplicitAPI):
401
401
  })
402
402
  return self.safe_value(self.options['fetchCurrencies'], 'response')
403
403
 
404
- def fetch_currencies(self, params={}):
404
+ def fetch_currencies(self, params={}) -> Currencies:
405
405
  """
406
406
  fetches all available currencies on an exchange
407
407
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -808,7 +808,7 @@ class latoken(Exchange, ImplicitAPI):
808
808
  #
809
809
  return self.parse_trades(response, market, since, limit)
810
810
 
811
- def fetch_trading_fee(self, symbol: str, params={}):
811
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
812
812
  """
813
813
  fetch the trading fees for a market
814
814
  :see: https://api.latoken.com/doc/v2/#tag/Trade/operation/getFeeByPair
@@ -849,6 +849,8 @@ class latoken(Exchange, ImplicitAPI):
849
849
  'symbol': market['symbol'],
850
850
  'maker': self.safe_number(response, 'makerFee'),
851
851
  'taker': self.safe_number(response, 'takerFee'),
852
+ 'percentage': None,
853
+ 'tierBased': None,
852
854
  }
853
855
 
854
856
  def fetch_private_trading_fee(self, symbol: str, params={}):
@@ -872,6 +874,8 @@ class latoken(Exchange, ImplicitAPI):
872
874
  'symbol': market['symbol'],
873
875
  'maker': self.safe_number(response, 'makerFee'),
874
876
  'taker': self.safe_number(response, 'takerFee'),
877
+ 'percentage': None,
878
+ 'tierBased': None,
875
879
  }
876
880
 
877
881
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
ccxt/lbank.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.lbank import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -1182,7 +1182,7 @@ class lbank(Exchange, ImplicitAPI):
1182
1182
  #
1183
1183
  return self.parse_balance(response)
1184
1184
 
1185
- def parse_trading_fee(self, fee, market: Market = None):
1185
+ def parse_trading_fee(self, fee, market: Market = None) -> TradingFeeInterface:
1186
1186
  #
1187
1187
  # {
1188
1188
  # "symbol":"skt_usdt",
@@ -1197,9 +1197,11 @@ class lbank(Exchange, ImplicitAPI):
1197
1197
  'symbol': symbol,
1198
1198
  'maker': self.safe_number(fee, 'makerCommission'),
1199
1199
  'taker': self.safe_number(fee, 'takerCommission'),
1200
+ 'percentage': None,
1201
+ 'tierBased': None,
1200
1202
  }
1201
1203
 
1202
- def fetch_trading_fee(self, symbol: str, params={}):
1204
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
1203
1205
  """
1204
1206
  fetch the trading fees for a market
1205
1207
  :see: https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
@@ -1209,9 +1211,9 @@ class lbank(Exchange, ImplicitAPI):
1209
1211
  """
1210
1212
  market = self.market(symbol)
1211
1213
  result = self.fetch_trading_fees(self.extend(params, {'category': market['id']}))
1212
- return result
1214
+ return self.safe_dict(result, symbol)
1213
1215
 
1214
- def fetch_trading_fees(self, params={}):
1216
+ def fetch_trading_fees(self, params={}) -> TradingFees:
1215
1217
  """
1216
1218
  fetch the trading fees for multiple markets
1217
1219
  :see: https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
ccxt/luno.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.luno import ImplicitAPI
8
- from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
8
+ from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import ArgumentsRequired
@@ -812,7 +812,7 @@ class luno(Exchange, ImplicitAPI):
812
812
  trades = self.safe_list(response, 'trades', [])
813
813
  return self.parse_trades(trades, market, since, limit)
814
814
 
815
- def fetch_trading_fee(self, symbol: str, params={}):
815
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
816
816
  """
817
817
  fetch the trading fees for a market
818
818
  :see: https://www.luno.com/en/developers/api#tag/Orders/operation/getFeeInfo
@@ -838,6 +838,8 @@ class luno(Exchange, ImplicitAPI):
838
838
  'symbol': symbol,
839
839
  'maker': self.safe_number(response, 'maker_fee'),
840
840
  'taker': self.safe_number(response, 'taker_fee'),
841
+ 'percentage': None,
842
+ 'tierBased': None,
841
843
  }
842
844
 
843
845
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
ccxt/lykke.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.lykke import ImplicitAPI
8
- from ccxt.base.types import Balances, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import BadRequest
@@ -187,7 +187,7 @@ class lykke(Exchange, ImplicitAPI):
187
187
  },
188
188
  })
189
189
 
190
- def fetch_currencies(self, params={}):
190
+ def fetch_currencies(self, params={}) -> Currencies:
191
191
  """
192
192
  fetches all available currencies on an exchange
193
193
  :see: https://lykkecity.github.io/Trading-API/#get-all-assets
ccxt/mexc.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.mexc import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, IndexType, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -89,6 +89,7 @@ class mexc(Exchange, ImplicitAPI):
89
89
  'fetchLeverage': True,
90
90
  'fetchLeverages': False,
91
91
  'fetchLeverageTiers': True,
92
+ 'fetchMarginAdjustmentHistory': False,
92
93
  'fetchMarginMode': False,
93
94
  'fetchMarketLeverageTiers': None,
94
95
  'fetchMarkets': True,
@@ -998,7 +999,7 @@ class mexc(Exchange, ImplicitAPI):
998
999
  return self.safe_integer(response, 'data')
999
1000
  return None
1000
1001
 
1001
- def fetch_currencies(self, params={}):
1002
+ def fetch_currencies(self, params={}) -> Currencies:
1002
1003
  """
1003
1004
  fetches all available currencies on an exchange
1004
1005
  :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
@@ -3343,7 +3344,7 @@ class mexc(Exchange, ImplicitAPI):
3343
3344
  })
3344
3345
  return result
3345
3346
 
3346
- def fetch_trading_fees(self, params={}):
3347
+ def fetch_trading_fees(self, params={}) -> TradingFees:
3347
3348
  """
3348
3349
  fetch the trading fees for multiple markets
3349
3350
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4031,8 +4032,9 @@ class mexc(Exchange, ImplicitAPI):
4031
4032
 
4032
4033
  def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
4033
4034
  """
4034
- retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
4035
- :param str[]|None symbols: list of unified market symbols
4035
+ retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for self market
4036
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
4037
+ :param str[] [symbols]: list of unified market symbols
4036
4038
  :param dict [params]: extra parameters specific to the exchange API endpoint
4037
4039
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
4038
4040
  """
@@ -4088,10 +4090,44 @@ class mexc(Exchange, ImplicitAPI):
4088
4090
  return self.parse_leverage_tiers(data, symbols, 'symbol')
4089
4091
 
4090
4092
  def parse_market_leverage_tiers(self, info, market: Market = None):
4091
- """
4092
- @param info {object} Exchange response for 1 market
4093
- @param market {object} CCXT market
4094
- """
4093
+ #
4094
+ # {
4095
+ # "symbol": "BTC_USDT",
4096
+ # "displayName": "BTC_USDT永续",
4097
+ # "displayNameEn": "BTC_USDT SWAP",
4098
+ # "positionOpenType": 3,
4099
+ # "baseCoin": "BTC",
4100
+ # "quoteCoin": "USDT",
4101
+ # "settleCoin": "USDT",
4102
+ # "contractSize": 0.0001,
4103
+ # "minLeverage": 1,
4104
+ # "maxLeverage": 125,
4105
+ # "priceScale": 2,
4106
+ # "volScale": 0,
4107
+ # "amountScale": 4,
4108
+ # "priceUnit": 0.5,
4109
+ # "volUnit": 1,
4110
+ # "minVol": 1,
4111
+ # "maxVol": 1000000,
4112
+ # "bidLimitPriceRate": 0.1,
4113
+ # "askLimitPriceRate": 0.1,
4114
+ # "takerFeeRate": 0.0006,
4115
+ # "makerFeeRate": 0.0002,
4116
+ # "maintenanceMarginRate": 0.004,
4117
+ # "initialMarginRate": 0.008,
4118
+ # "riskBaseVol": 10000,
4119
+ # "riskIncrVol": 200000,
4120
+ # "riskIncrMmr": 0.004,
4121
+ # "riskIncrImr": 0.004,
4122
+ # "riskLevelLimit": 5,
4123
+ # "priceCoefficientVariation": 0.1,
4124
+ # "indexOrigin": ["BINANCE","GATEIO","HUOBI","MXC"],
4125
+ # "state": 0, # 0 enabled, 1 delivery, 2 completed, 3 offline, 4 pause
4126
+ # "isNew": False,
4127
+ # "isHot": True,
4128
+ # "isHidden": False
4129
+ # }
4130
+ #
4095
4131
  maintenanceMarginRate = self.safe_string(info, 'maintenanceMarginRate')
4096
4132
  initialMarginRate = self.safe_string(info, 'initialMarginRate')
4097
4133
  maxVol = self.safe_string(info, 'maxVol')
@@ -4101,6 +4137,18 @@ class mexc(Exchange, ImplicitAPI):
4101
4137
  floor = '0'
4102
4138
  tiers = []
4103
4139
  quoteId = self.safe_string(info, 'quoteCoin')
4140
+ if riskIncrVol == '0':
4141
+ return [
4142
+ {
4143
+ 'tier': 0,
4144
+ 'currency': self.safe_currency_code(quoteId),
4145
+ 'notionalFloor': None,
4146
+ 'notionalCap': None,
4147
+ 'maintenanceMarginRate': None,
4148
+ 'maxLeverage': self.safe_number(info, 'maxLeverage'),
4149
+ 'info': info,
4150
+ },
4151
+ ]
4104
4152
  while(Precise.string_lt(floor, maxVol)):
4105
4153
  cap = Precise.string_add(floor, riskIncrVol)
4106
4154
  tiers.append({
ccxt/ndax.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.ndax import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Account, Balances, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction
10
+ from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import BadSymbol
@@ -329,7 +329,7 @@ class ndax(Exchange, ImplicitAPI):
329
329
  return responseInner
330
330
  return response
331
331
 
332
- def fetch_currencies(self, params={}):
332
+ def fetch_currencies(self, params={}) -> Currencies:
333
333
  """
334
334
  fetches all available currencies on an exchange
335
335
  :see: https://apidoc.ndax.io/#getproduct
ccxt/oceanex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.oceanex import ImplicitAPI
8
- from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
8
+ from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
@@ -543,7 +543,7 @@ class oceanex(Exchange, ImplicitAPI):
543
543
  #
544
544
  return self.safe_timestamp(response, 'data')
545
545
 
546
- def fetch_trading_fees(self, params={}):
546
+ def fetch_trading_fees(self, params={}) -> TradingFees:
547
547
  """
548
548
  fetch the trading fees for multiple markets
549
549
  :see: https://api.oceanex.pro/doc/v1/#trading-fees-post
ccxt/okcoin.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.okcoin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, 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
@@ -733,7 +733,7 @@ class okcoin(Exchange, ImplicitAPI):
733
733
  }
734
734
  return self.safe_string(networksById, networkId, networkId)
735
735
 
736
- def fetch_currencies(self, params={}):
736
+ def fetch_currencies(self, params={}) -> Currencies:
737
737
  """
738
738
  fetches all available currencies on an exchange
739
739
  :param dict [params]: extra parameters specific to the exchange API endpoint
ccxt/okx.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.okx import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, 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
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -106,6 +106,7 @@ class okx(Exchange, ImplicitAPI):
106
106
  'fetchLedgerEntry': None,
107
107
  'fetchLeverage': True,
108
108
  'fetchLeverageTiers': False,
109
+ 'fetchMarginAdjustmentHistory': True,
109
110
  'fetchMarketLeverageTiers': True,
110
111
  'fetchMarkets': True,
111
112
  'fetchMarkOHLCV': True,
@@ -1542,7 +1543,7 @@ class okx(Exchange, ImplicitAPI):
1542
1543
  }
1543
1544
  return self.safe_string(networksById, networkId, networkId)
1544
1545
 
1545
- def fetch_currencies(self, params={}):
1546
+ def fetch_currencies(self, params={}) -> Currencies:
1546
1547
  """
1547
1548
  fetches all available currencies on an exchange
1548
1549
  :see: https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies
@@ -2266,7 +2267,7 @@ class okx(Exchange, ImplicitAPI):
2266
2267
  result[code] = account
2267
2268
  return self.safe_balance(result)
2268
2269
 
2269
- def parse_trading_fee(self, fee, market: Market = None):
2270
+ def parse_trading_fee(self, fee, market: Market = None) -> TradingFeeInterface:
2270
2271
  # https://www.okx.com/docs-v5/en/#rest-api-account-get-fee-rates
2271
2272
  #
2272
2273
  # {
@@ -2286,9 +2287,11 @@ class okx(Exchange, ImplicitAPI):
2286
2287
  # OKX returns the fees values opposed to other exchanges, so the sign needs to be flipped
2287
2288
  'maker': self.parse_number(Precise.string_neg(self.safe_string_2(fee, 'maker', 'makerU'))),
2288
2289
  'taker': self.parse_number(Precise.string_neg(self.safe_string_2(fee, 'taker', 'takerU'))),
2290
+ 'percentage': None,
2291
+ 'tierBased': None,
2289
2292
  }
2290
2293
 
2291
- def fetch_trading_fee(self, symbol: str, params={}):
2294
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
2292
2295
  """
2293
2296
  fetch the trading fees for a market
2294
2297
  :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-fee-rates
@@ -6033,9 +6036,9 @@ class okx(Exchange, ImplicitAPI):
6033
6036
  # }
6034
6037
  #
6035
6038
  data = self.safe_list(response, 'data', [])
6039
+ entry = self.safe_dict(data, 0, {})
6036
6040
  errorCode = self.safe_string(response, 'code')
6037
- item = self.safe_dict(data, 0, {})
6038
- return self.extend(self.parse_margin_modification(item, market), {
6041
+ return self.extend(self.parse_margin_modification(entry, market), {
6039
6042
  'status': 'ok' if (errorCode == '0') else 'failed',
6040
6043
  })
6041
6044
 
@@ -6050,22 +6053,66 @@ class okx(Exchange, ImplicitAPI):
6050
6053
  # "type": "reduce"
6051
6054
  # }
6052
6055
  #
6053
- amountRaw = self.safe_number(data, 'amt')
6056
+ # fetchMarginAdjustmentHistory
6057
+ #
6058
+ # {
6059
+ # bal: '67621.4325135010619812',
6060
+ # balChg: '-10.0000000000000000',
6061
+ # billId: '691293628710342659',
6062
+ # ccy: 'USDT',
6063
+ # clOrdId: '',
6064
+ # execType: '',
6065
+ # fee: '0',
6066
+ # fillFwdPx: '',
6067
+ # fillIdxPx: '',
6068
+ # fillMarkPx: '',
6069
+ # fillMarkVol: '',
6070
+ # fillPxUsd: '',
6071
+ # fillPxVol: '',
6072
+ # fillTime: '1711089244850',
6073
+ # from: '',
6074
+ # instId: 'XRP-USDT-SWAP',
6075
+ # instType: 'SWAP',
6076
+ # interest: '0',
6077
+ # mgnMode: 'isolated',
6078
+ # notes: '',
6079
+ # ordId: '',
6080
+ # pnl: '0',
6081
+ # posBal: '73.12',
6082
+ # posBalChg: '10.00',
6083
+ # px: '',
6084
+ # subType: '160',
6085
+ # sz: '10',
6086
+ # tag: '',
6087
+ # to: '',
6088
+ # tradeId: '0',
6089
+ # ts: '1711089244699',
6090
+ # type: '6'
6091
+ # }
6092
+ #
6093
+ amountRaw = self.safe_string_2(data, 'amt', 'posBalChg')
6054
6094
  typeRaw = self.safe_string(data, 'type')
6055
- type = 'reduce' if (typeRaw == 'reduce') else 'add'
6095
+ type = None
6096
+ if typeRaw == '6':
6097
+ type = 'add' if Precise.string_gt(amountRaw, '0') else 'reduce'
6098
+ else:
6099
+ type = typeRaw
6100
+ amount = Precise.string_abs(amountRaw)
6056
6101
  marketId = self.safe_string(data, 'instId')
6057
6102
  responseMarket = self.safe_market(marketId, market)
6058
6103
  code = responseMarket['base'] if responseMarket['inverse'] else responseMarket['quote']
6104
+ timestamp = self.safe_integer(data, 'ts')
6059
6105
  return {
6060
6106
  'info': data,
6061
6107
  'symbol': responseMarket['symbol'],
6062
6108
  'type': type,
6063
- 'amount': amountRaw,
6064
- 'total': None,
6109
+ 'marginMode': 'isolated',
6110
+ 'amount': self.parse_number(amount),
6065
6111
  'code': code,
6112
+ 'total': None,
6066
6113
  'status': None,
6067
- 'timestamp': None,
6068
- 'datetime': None,
6114
+ 'timestamp': timestamp,
6115
+ 'datetime': self.iso8601(timestamp),
6069
6116
  }
6070
6117
 
6071
6118
  def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
@@ -7086,3 +7133,93 @@ class okx(Exchange, ImplicitAPI):
7086
7133
  self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
7087
7134
  raise ExchangeError(feedback) # unknown message
7088
7135
  return None
7136
+
7137
+ def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}) -> List[MarginModification]:
7138
+ """
7139
+ fetches the history of margin added or reduced from contract isolated positions
7140
+ :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-7-days
7141
+ :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
7142
+ :param str [symbol]: not used by okx fetchMarginAdjustmentHistory
7143
+ :param str [type]: "add" or "reduce"
7144
+ :param dict params: extra parameters specific to the exchange api endpoint
7145
+ :param boolean [params.auto]: True if fetching auto margin increases
7146
+ :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
7147
+ """
7148
+ self.load_markets()
7149
+ auto = self.safe_bool(params, 'auto')
7150
+ if type is None:
7151
+ raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a type argument')
7152
+ isAdd = type == 'add'
7153
+ subType = '160' if isAdd else '161'
7154
+ if auto:
7155
+ if isAdd:
7156
+ subType = '162'
7157
+ else:
7158
+ raise BadRequest(self.id + ' cannot fetch margin adjustments for type ' + type)
7159
+ request = {
7160
+ 'subType': subType,
7161
+ 'mgnMode': 'isolated',
7162
+ }
7163
+ until = self.safe_integer(params, 'until')
7164
+ params = self.omit(params, 'until')
7165
+ if since is not None:
7166
+ request['startTime'] = since
7167
+ if limit is not None:
7168
+ request['limit'] = limit
7169
+ if until is not None:
7170
+ request['endTime'] = until
7171
+ response = None
7172
+ now = self.milliseconds()
7173
+ oneWeekAgo = now - 604800000
7174
+ threeMonthsAgo = now - 7776000000
7175
+ if (since is None) or (since > oneWeekAgo):
7176
+ response = self.privateGetAccountBills(self.extend(request, params))
7177
+ elif since > threeMonthsAgo:
7178
+ response = self.privateGetAccountBillsArchive(self.extend(request, params))
7179
+ else:
7180
+ raise BadRequest(self.id + ' fetchMarginAdjustmentHistory() cannot fetch margin adjustments older than 3 months')
7181
+ #
7182
+ # {
7183
+ # code: '0',
7184
+ # data: [
7185
+ # {
7186
+ # bal: '67621.4325135010619812',
7187
+ # balChg: '-10.0000000000000000',
7188
+ # billId: '691293628710342659',
7189
+ # ccy: 'USDT',
7190
+ # clOrdId: '',
7191
+ # execType: '',
7192
+ # fee: '0',
7193
+ # fillFwdPx: '',
7194
+ # fillIdxPx: '',
7195
+ # fillMarkPx: '',
7196
+ # fillMarkVol: '',
7197
+ # fillPxUsd: '',
7198
+ # fillPxVol: '',
7199
+ # fillTime: '1711089244850',
7200
+ # from: '',
7201
+ # instId: 'XRP-USDT-SWAP',
7202
+ # instType: 'SWAP',
7203
+ # interest: '0',
7204
+ # mgnMode: 'isolated',
7205
+ # notes: '',
7206
+ # ordId: '',
7207
+ # pnl: '0',
7208
+ # posBal: '73.12',
7209
+ # posBalChg: '10.00',
7210
+ # px: '',
7211
+ # subType: '160',
7212
+ # sz: '10',
7213
+ # tag: '',
7214
+ # to: '',
7215
+ # tradeId: '0',
7216
+ # ts: '1711089244699',
7217
+ # type: '6'
7218
+ # }
7219
+ # ],
7220
+ # msg: ''
7221
+ # }
7222
+ #
7223
+ data = self.safe_list(response, 'data')
7224
+ modifications = self.parse_margin_modifications(data)
7225
+ return self.filter_by_symbol_since_limit(modifications, symbol, since, limit)
ccxt/onetrading.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.onetrading import ImplicitAPI
8
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
@@ -325,7 +325,7 @@ class onetrading(Exchange, ImplicitAPI):
325
325
  #
326
326
  return self.safe_integer(response, 'epoch_millis')
327
327
 
328
- def fetch_currencies(self, params={}):
328
+ def fetch_currencies(self, params={}) -> Currencies:
329
329
  """
330
330
  fetches all available currencies on an exchange
331
331
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -443,7 +443,7 @@ class onetrading(Exchange, ImplicitAPI):
443
443
  'info': market,
444
444
  }
445
445
 
446
- def fetch_trading_fees(self, params={}):
446
+ def fetch_trading_fees(self, params={}) -> TradingFees:
447
447
  """
448
448
  fetch the trading fees for multiple markets
449
449
  :param dict [params]: extra parameters specific to the exchange API endpoint
ccxt/phemex.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.phemex import ImplicitAPI
8
8
  import hashlib
9
9
  import numbers
10
- from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currencies, 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
@@ -971,7 +971,7 @@ class phemex(Exchange, ImplicitAPI):
971
971
  result.append(market)
972
972
  return result
973
973
 
974
- def fetch_currencies(self, params={}):
974
+ def fetch_currencies(self, params={}) -> Currencies:
975
975
  """
976
976
  fetches all available currencies on an exchange
977
977
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3792,6 +3792,7 @@ class phemex(Exchange, ImplicitAPI):
3792
3792
  'info': data,
3793
3793
  'symbol': self.safe_symbol(None, market),
3794
3794
  'type': 'set',
3795
+ 'marginMode': 'isolated',
3795
3796
  'amount': None,
3796
3797
  'total': None,
3797
3798
  'code': market[codeCurrency],
ccxt/poloniex.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.poloniex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -671,7 +671,7 @@ class poloniex(Exchange, ImplicitAPI):
671
671
  #
672
672
  return self.parse_tickers(response, symbols)
673
673
 
674
- def fetch_currencies(self, params={}):
674
+ def fetch_currencies(self, params={}) -> Currencies:
675
675
  """
676
676
  fetches all available currencies on an exchange
677
677
  :see: https://docs.poloniex.com/#public-endpoints-reference-data-currency-information
@@ -1570,7 +1570,7 @@ class poloniex(Exchange, ImplicitAPI):
1570
1570
  #
1571
1571
  return self.parse_balance(response)
1572
1572
 
1573
- def fetch_trading_fees(self, params={}):
1573
+ def fetch_trading_fees(self, params={}) -> TradingFees:
1574
1574
  """
1575
1575
  fetch the trading fees for multiple markets
1576
1576
  :see: https://docs.poloniex.com/#authenticated-endpoints-accounts-fee-info
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.88'
7
+ __version__ = '4.2.90'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/bitget.py CHANGED
@@ -1627,6 +1627,8 @@ class bitget(ccxt.async_support.bitget):
1627
1627
  'ordersAlgo': self.handle_order,
1628
1628
  'account': self.handle_balance,
1629
1629
  'positions': self.handle_positions,
1630
+ 'account-isolated': self.handle_balance,
1631
+ 'account-crossed': self.handle_balance,
1630
1632
  }
1631
1633
  arg = self.safe_value(message, 'arg', {})
1632
1634
  topic = self.safe_value(arg, 'channel', '')
ccxt/pro/bitvavo.py CHANGED
@@ -6,7 +6,7 @@
6
6
  import ccxt.async_support
7
7
  from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheBySymbolById, ArrayCacheByTimestamp
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Int, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade
9
+ from ccxt.base.types import Balances, Int, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, TradingFees
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -838,7 +838,7 @@ class bitvavo(ccxt.async_support.bitvavo):
838
838
  deposits = self.parse_transactions(response, None, None, None, {'type': 'deposit'})
839
839
  client.resolve(deposits, messageHash)
840
840
 
841
- async def fetch_trading_fees_ws(self, params={}):
841
+ async def fetch_trading_fees_ws(self, params={}) -> TradingFees:
842
842
  """
843
843
  :see: https://docs.bitvavo.com/#tag/Account/paths/~1account/get
844
844
  fetch the trading fees for multiple markets