ccxt 4.4.3__py2.py3-none-any.whl → 4.4.4__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 (79) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/async_support/__init__.py +1 -1
  3. ccxt/async_support/base/exchange.py +24 -13
  4. ccxt/async_support/base/ws/cache.py +1 -0
  5. ccxt/async_support/binance.py +40 -15
  6. ccxt/async_support/bingx.py +1 -0
  7. ccxt/async_support/bitfinex2.py +10 -9
  8. ccxt/async_support/bitget.py +13 -9
  9. ccxt/async_support/bitmex.py +14 -13
  10. ccxt/async_support/bitso.py +8 -7
  11. ccxt/async_support/bitstamp.py +12 -12
  12. ccxt/async_support/blofin.py +24 -26
  13. ccxt/async_support/bybit.py +24 -23
  14. ccxt/async_support/coinbase.py +31 -10
  15. ccxt/async_support/coinbaseexchange.py +14 -14
  16. ccxt/async_support/coinlist.py +9 -8
  17. ccxt/async_support/coinmetro.py +6 -6
  18. ccxt/async_support/cryptocom.py +10 -8
  19. ccxt/async_support/currencycom.py +9 -9
  20. ccxt/async_support/delta.py +8 -8
  21. ccxt/async_support/digifinex.py +11 -9
  22. ccxt/async_support/gate.py +9 -8
  23. ccxt/async_support/hashkey.py +12 -10
  24. ccxt/async_support/htx.py +16 -19
  25. ccxt/async_support/hyperliquid.py +70 -117
  26. ccxt/async_support/kraken.py +12 -10
  27. ccxt/async_support/kucoin.py +12 -11
  28. ccxt/async_support/luno.py +13 -12
  29. ccxt/async_support/mexc.py +34 -2
  30. ccxt/async_support/ndax.py +9 -8
  31. ccxt/async_support/okcoin.py +21 -30
  32. ccxt/async_support/okx.py +21 -29
  33. ccxt/async_support/woo.py +10 -9
  34. ccxt/async_support/woofipro.py +11 -9
  35. ccxt/async_support/xt.py +7 -6
  36. ccxt/async_support/zonda.py +9 -8
  37. ccxt/base/exchange.py +3 -1
  38. ccxt/binance.py +40 -15
  39. ccxt/bingx.py +1 -0
  40. ccxt/bitfinex2.py +10 -9
  41. ccxt/bitget.py +13 -9
  42. ccxt/bitmex.py +14 -13
  43. ccxt/bitso.py +8 -7
  44. ccxt/bitstamp.py +12 -12
  45. ccxt/blofin.py +24 -26
  46. ccxt/bybit.py +24 -23
  47. ccxt/coinbase.py +31 -10
  48. ccxt/coinbaseexchange.py +14 -14
  49. ccxt/coinlist.py +9 -8
  50. ccxt/coinmetro.py +6 -6
  51. ccxt/cryptocom.py +10 -8
  52. ccxt/currencycom.py +9 -9
  53. ccxt/delta.py +8 -8
  54. ccxt/digifinex.py +11 -9
  55. ccxt/gate.py +9 -8
  56. ccxt/hashkey.py +12 -10
  57. ccxt/htx.py +16 -19
  58. ccxt/hyperliquid.py +70 -117
  59. ccxt/kraken.py +12 -10
  60. ccxt/kucoin.py +12 -11
  61. ccxt/luno.py +13 -12
  62. ccxt/mexc.py +33 -2
  63. ccxt/ndax.py +9 -8
  64. ccxt/okcoin.py +21 -30
  65. ccxt/okx.py +21 -29
  66. ccxt/pro/__init__.py +1 -1
  67. ccxt/pro/bybit.py +51 -0
  68. ccxt/pro/mexc.py +78 -0
  69. ccxt/test/tests_async.py +1 -1
  70. ccxt/test/tests_sync.py +1 -1
  71. ccxt/woo.py +10 -9
  72. ccxt/woofipro.py +11 -9
  73. ccxt/xt.py +7 -6
  74. ccxt/zonda.py +9 -8
  75. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/METADATA +5 -5
  76. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/RECORD +79 -79
  77. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/LICENSE.txt +0 -0
  78. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/WHEEL +0 -0
  79. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.kraken import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, LedgerEntry, 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 AuthenticationError
@@ -1026,7 +1026,7 @@ class kraken(Exchange, ImplicitAPI):
1026
1026
  }
1027
1027
  return self.safe_string(types, type, type)
1028
1028
 
1029
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1029
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1030
1030
  #
1031
1031
  # {
1032
1032
  # 'LTFK7F-N2CUX-PNY4SX': {
@@ -1048,7 +1048,9 @@ class kraken(Exchange, ImplicitAPI):
1048
1048
  referenceId = self.safe_string(item, 'refid')
1049
1049
  referenceAccount = None
1050
1050
  type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
1051
- code = self.safe_currency_code(self.safe_string(item, 'asset'), currency)
1051
+ currencyId = self.safe_string(item, 'asset')
1052
+ code = self.safe_currency_code(currencyId, currency)
1053
+ currency = self.safe_currency(currencyId, currency)
1052
1054
  amount = self.safe_string(item, 'amount')
1053
1055
  if Precise.string_lt(amount, '0'):
1054
1056
  direction = 'out'
@@ -1056,7 +1058,7 @@ class kraken(Exchange, ImplicitAPI):
1056
1058
  else:
1057
1059
  direction = 'in'
1058
1060
  timestamp = self.safe_integer_product(item, 'time', 1000)
1059
- return {
1061
+ return self.safe_ledger_entry({
1060
1062
  'info': item,
1061
1063
  'id': id,
1062
1064
  'direction': direction,
@@ -1075,15 +1077,15 @@ class kraken(Exchange, ImplicitAPI):
1075
1077
  'cost': self.safe_number(item, 'fee'),
1076
1078
  'currency': code,
1077
1079
  },
1078
- }
1080
+ }, currency)
1079
1081
 
1080
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1082
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1081
1083
  """
1082
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1084
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1083
1085
  :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
1084
- :param str code: unified currency code, default is None
1086
+ :param str [code]: unified currency code, default is None
1085
1087
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1086
- :param int [limit]: max number of ledger entrys to return, default is None
1088
+ :param int [limit]: max number of ledger entries to return, default is None
1087
1089
  :param dict [params]: extra parameters specific to the exchange API endpoint
1088
1090
  :param int [params.until]: timestamp in ms of the latest ledger entry
1089
1091
  :param int [params.end]: timestamp in seconds of the latest ledger entry
@@ -1151,7 +1153,7 @@ class kraken(Exchange, ImplicitAPI):
1151
1153
  items.append(value)
1152
1154
  return self.parse_ledger(items)
1153
1155
 
1154
- async def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
1156
+ async def fetch_ledger_entry(self, id: str, code: Str = None, params={}) -> LedgerEntry:
1155
1157
  items = await self.fetch_ledger_entries_by_ids([id], code, params)
1156
1158
  return items[0]
1157
1159
 
@@ -9,7 +9,7 @@ import asyncio
9
9
  import hashlib
10
10
  import math
11
11
  import json
12
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
12
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
13
13
  from typing import List
14
14
  from ccxt.base.errors import ExchangeError
15
15
  from ccxt.base.errors import AuthenticationError
@@ -3932,7 +3932,7 @@ class kucoin(Exchange, ImplicitAPI):
3932
3932
  }
3933
3933
  return self.safe_string(types, type, type)
3934
3934
 
3935
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
3935
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
3936
3936
  #
3937
3937
  # {
3938
3938
  # "id": "611a1e7c6a053300067a88d9", #unique key for each ledger entry
@@ -3950,6 +3950,7 @@ class kucoin(Exchange, ImplicitAPI):
3950
3950
  id = self.safe_string(item, 'id')
3951
3951
  currencyId = self.safe_string(item, 'currency')
3952
3952
  code = self.safe_currency_code(currencyId, currency)
3953
+ currency = self.safe_currency(currencyId, currency)
3953
3954
  amount = self.safe_number(item, 'amount')
3954
3955
  balanceAfter = None
3955
3956
  # balanceAfter = self.safe_number(item, 'balance'); only returns zero string
@@ -3992,7 +3993,8 @@ class kucoin(Exchange, ImplicitAPI):
3992
3993
  if feeCost != '0':
3993
3994
  feeCurrency = code
3994
3995
  fee = {'cost': self.parse_number(feeCost), 'currency': feeCurrency}
3995
- return {
3996
+ return self.safe_ledger_entry({
3997
+ 'info': item,
3996
3998
  'id': id,
3997
3999
  'direction': direction,
3998
4000
  'account': account,
@@ -4007,22 +4009,21 @@ class kucoin(Exchange, ImplicitAPI):
4007
4009
  'after': balanceAfter, # None
4008
4010
  'status': None,
4009
4011
  'fee': fee,
4010
- 'info': item,
4011
- }
4012
+ }, currency)
4012
4013
 
4013
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
4014
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
4014
4015
  """
4016
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
4015
4017
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-spot-margin
4016
4018
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-trade_hf
4017
4019
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-margin_hf
4018
- fetch the history of changes, actions done by the user or operations that altered balance of the user
4019
- :param str code: unified currency code, default is None
4020
+ :param str [code]: unified currency code, default is None
4020
4021
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
4021
- :param int [limit]: max number of ledger entrys to return, default is None
4022
+ :param int [limit]: max number of ledger entries to return, default is None
4022
4023
  :param dict [params]: extra parameters specific to the exchange API endpoint
4023
4024
  :param boolean [params.hf]: default False, when True will fetch ledger entries for the high frequency trading account
4024
4025
  :param int [params.until]: the latest time in ms to fetch entries for
4025
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4026
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4026
4027
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
4027
4028
  """
4028
4029
  await self.load_markets()
@@ -4743,7 +4744,7 @@ class kucoin(Exchange, ImplicitAPI):
4743
4744
  #
4744
4745
  errorCode = self.safe_string(response, 'code')
4745
4746
  message = self.safe_string_2(response, 'msg', 'data', '')
4746
- feedback = self.id + ' ' + message
4747
+ feedback = self.id + ' ' + body
4747
4748
  self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
4748
4749
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
4749
4750
  self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.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, TradingFeeInterface
8
+ from ccxt.base.types import Account, Balances, Currency, Int, LedgerEntry, 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
@@ -920,13 +920,13 @@ class luno(Exchange, ImplicitAPI):
920
920
  }
921
921
  return await self.fetch_ledger(code, since, limit, self.extend(request, params))
922
922
 
923
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
923
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
924
924
  """
925
- fetch the history of changes, actions done by the user or operations that altered balance of the user
925
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
926
926
  :see: https://www.luno.com/en/developers/api#tag/Accounts/operation/ListTransactions
927
- :param str code: unified currency code, default is None
927
+ :param str [code]: unified currency code, default is None
928
928
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
929
- :param int [limit]: max number of ledger entrys to return, default is None
929
+ :param int [limit]: max number of ledger entries to return, default is None
930
930
  :param dict [params]: extra parameters specific to the exchange API endpoint
931
931
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
932
932
  """
@@ -995,13 +995,14 @@ class luno(Exchange, ImplicitAPI):
995
995
  'referenceId': referenceId,
996
996
  }
997
997
 
998
- def parse_ledger_entry(self, entry, currency: Currency = None):
998
+ def parse_ledger_entry(self, entry, currency: Currency = None) -> LedgerEntry:
999
999
  # details = self.safe_value(entry, 'details', {})
1000
1000
  id = self.safe_string(entry, 'row_index')
1001
1001
  account_id = self.safe_string(entry, 'account_id')
1002
1002
  timestamp = self.safe_integer(entry, 'timestamp')
1003
1003
  currencyId = self.safe_string(entry, 'currency')
1004
1004
  code = self.safe_currency_code(currencyId, currency)
1005
+ currency = self.safe_currency(currencyId, currency)
1005
1006
  available_delta = self.safe_string(entry, 'available_delta')
1006
1007
  balance_delta = self.safe_string(entry, 'balance_delta')
1007
1008
  after = self.safe_string(entry, 'balance')
@@ -1027,7 +1028,8 @@ class luno(Exchange, ImplicitAPI):
1027
1028
  direction = 'in'
1028
1029
  elif Precise.string_lt(balance_delta, '0') or Precise.string_lt(available_delta, '0'):
1029
1030
  direction = 'out'
1030
- return {
1031
+ return self.safe_ledger_entry({
1032
+ 'info': entry,
1031
1033
  'id': id,
1032
1034
  'direction': direction,
1033
1035
  'account': account_id,
@@ -1035,15 +1037,14 @@ class luno(Exchange, ImplicitAPI):
1035
1037
  'referenceAccount': None,
1036
1038
  'type': type,
1037
1039
  'currency': code,
1038
- 'amount': self.parse_number(amount),
1040
+ 'amount': self.parse_to_numeric(amount),
1039
1041
  'timestamp': timestamp,
1040
1042
  'datetime': self.iso8601(timestamp),
1041
- 'before': self.parse_number(before),
1042
- 'after': self.parse_number(after),
1043
+ 'before': self.parse_to_numeric(before),
1044
+ 'after': self.parse_to_numeric(after),
1043
1045
  'status': status,
1044
1046
  'fee': None,
1045
- 'info': entry,
1046
- }
1047
+ }, currency)
1047
1048
 
1048
1049
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1049
1050
  url = self.urls['api'][api] + '/' + self.version + '/' + self.implode_params(path, params)
@@ -5,6 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.mexc import ImplicitAPI
8
+ import asyncio
8
9
  import hashlib
9
10
  from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
11
  from typing import List
@@ -1007,8 +1008,9 @@ class mexc(Exchange, ImplicitAPI):
1007
1008
  :param dict [params]: extra parameters specific to the exchange API endpoint
1008
1009
  :returns dict[]: an array of objects representing market data
1009
1010
  """
1010
- spotMarket = await self.fetch_spot_markets(params)
1011
- swapMarket = await self.fetch_swap_markets(params)
1011
+ spotMarketPromise = self.fetch_spot_markets(params)
1012
+ swapMarketPromise = self.fetch_swap_markets(params)
1013
+ spotMarket, swapMarket = await asyncio.gather(*[spotMarketPromise, swapMarketPromise])
1012
1014
  return self.array_concat(spotMarket, swapMarket)
1013
1015
 
1014
1016
  async def fetch_spot_markets(self, params={}):
@@ -1141,7 +1143,10 @@ class mexc(Exchange, ImplicitAPI):
1141
1143
  :param dict [params]: extra parameters specific to the exchange API endpoint
1142
1144
  :returns dict[]: an array of objects representing market data
1143
1145
  """
1146
+ currentRl: number = self.rateLimit
1147
+ self.set_property(self, 'rateLimit', 10) # see comment: https://github.com/ccxt/ccxt/pull/23698
1144
1148
  response = await self.contractPublicGetDetail(params)
1149
+ self.set_property(self, 'rateLimit', currentRl)
1145
1150
  #
1146
1151
  # {
1147
1152
  # "success":true,
@@ -2865,6 +2870,9 @@ class mexc(Exchange, ImplicitAPI):
2865
2870
  async def cancel_all_orders(self, symbol: Str = None, params={}):
2866
2871
  """
2867
2872
  cancel all open orders
2873
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
2874
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
2875
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
2868
2876
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2869
2877
  :param dict [params]: extra parameters specific to the exchange API endpoint
2870
2878
  :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
@@ -3251,6 +3259,8 @@ class mexc(Exchange, ImplicitAPI):
3251
3259
  async def fetch_accounts(self, params={}) -> List[Account]:
3252
3260
  """
3253
3261
  fetch all the accounts associated with a profile
3262
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3263
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3254
3264
  :param dict [params]: extra parameters specific to the exchange API endpoint
3255
3265
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
3256
3266
  """
@@ -3275,6 +3285,8 @@ class mexc(Exchange, ImplicitAPI):
3275
3285
  async def fetch_trading_fees(self, params={}) -> TradingFees:
3276
3286
  """
3277
3287
  fetch the trading fees for multiple markets
3288
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3289
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3278
3290
  :param dict [params]: extra parameters specific to the exchange API endpoint
3279
3291
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
3280
3292
  """
@@ -3539,6 +3551,8 @@ class mexc(Exchange, ImplicitAPI):
3539
3551
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3540
3552
  """
3541
3553
  fetch all trades made by the user
3554
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3555
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
3542
3556
  :param str symbol: unified market symbol
3543
3557
  :param int [since]: the earliest time in ms to fetch trades for
3544
3558
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -3619,6 +3633,8 @@ class mexc(Exchange, ImplicitAPI):
3619
3633
  async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3620
3634
  """
3621
3635
  fetch all the trades made from a single order
3636
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3637
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
3622
3638
  :param str id: order id
3623
3639
  :param str symbol: unified market symbol
3624
3640
  :param int [since]: the earliest time in ms to fetch trades for
@@ -3710,6 +3726,7 @@ class mexc(Exchange, ImplicitAPI):
3710
3726
  async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3711
3727
  """
3712
3728
  remove margin from a position
3729
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3713
3730
  :param str symbol: unified market symbol
3714
3731
  :param float amount: the amount of margin to remove
3715
3732
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3720,6 +3737,7 @@ class mexc(Exchange, ImplicitAPI):
3720
3737
  async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3721
3738
  """
3722
3739
  add margin
3740
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3723
3741
  :param str symbol: unified market symbol
3724
3742
  :param float amount: amount of margin to add
3725
3743
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3730,6 +3748,7 @@ class mexc(Exchange, ImplicitAPI):
3730
3748
  async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
3731
3749
  """
3732
3750
  set the level of leverage for a market
3751
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
3733
3752
  :param float leverage: the rate of leverage
3734
3753
  :param str symbol: unified market symbol
3735
3754
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3757,6 +3776,7 @@ class mexc(Exchange, ImplicitAPI):
3757
3776
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3758
3777
  """
3759
3778
  fetch the history of funding payments paid and received on self account
3779
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
3760
3780
  :param str symbol: unified market symbol
3761
3781
  :param int [since]: the earliest time in ms to fetch funding history for
3762
3782
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3867,6 +3887,7 @@ class mexc(Exchange, ImplicitAPI):
3867
3887
  async def fetch_funding_rate(self, symbol: str, params={}):
3868
3888
  """
3869
3889
  fetch the current funding rate
3890
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
3870
3891
  :param str symbol: unified market symbol
3871
3892
  :param dict [params]: extra parameters specific to the exchange API endpoint
3872
3893
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -3898,6 +3919,7 @@ class mexc(Exchange, ImplicitAPI):
3898
3919
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3899
3920
  """
3900
3921
  fetches historical funding rate prices
3922
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
3901
3923
  :param str symbol: unified symbol of the market to fetch the funding rate history for
3902
3924
  :param int [since]: not used by mexc, but filtered internally by ccxt
3903
3925
  :param int [limit]: mexc limit is page_size default 20, maximum is 100
@@ -4588,6 +4610,14 @@ class mexc(Exchange, ImplicitAPI):
4588
4610
  })
4589
4611
 
4590
4612
  async def fetch_transfer(self, id: str, code: Str = None, params={}) -> TransferEntry:
4613
+ """
4614
+ fetches a transfer
4615
+ :see: https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
4616
+ :param str id: transfer id
4617
+ :param str [code]: not used by mexc fetchTransfer
4618
+ :param dict params: extra parameters specific to the exchange api endpoint
4619
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
4620
+ """
4591
4621
  marketType, query = self.handle_market_type_and_params('fetchTransfer', None, params)
4592
4622
  await self.load_markets()
4593
4623
  if marketType == 'spot':
@@ -4617,6 +4647,8 @@ class mexc(Exchange, ImplicitAPI):
4617
4647
  async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4618
4648
  """
4619
4649
  fetch a history of internal transfers made on an account
4650
+ :see: https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
4651
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
4620
4652
  :param str code: unified currency code of the currency transferred
4621
4653
  :param int [since]: the earliest time in ms to fetch transfers for
4622
4654
  :param int [limit]: the maximum number of transfers structures to retrieve
@@ -7,7 +7,7 @@ from ccxt.async_support.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, Currencies, 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, LedgerEntry, 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 AuthenticationError
@@ -1084,7 +1084,7 @@ class ndax(Exchange, ImplicitAPI):
1084
1084
  }
1085
1085
  return self.safe_string(types, type, type)
1086
1086
 
1087
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1087
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1088
1088
  #
1089
1089
  # {
1090
1090
  # "TransactionId": 2663709493,
@@ -1102,6 +1102,7 @@ class ndax(Exchange, ImplicitAPI):
1102
1102
  # }
1103
1103
  #
1104
1104
  currencyId = self.safe_string(item, 'ProductId')
1105
+ currency = self.safe_currency(currencyId, currency)
1105
1106
  credit = self.safe_string(item, 'CR')
1106
1107
  debit = self.safe_string(item, 'DR')
1107
1108
  amount = None
@@ -1119,7 +1120,7 @@ class ndax(Exchange, ImplicitAPI):
1119
1120
  elif direction == 'in':
1120
1121
  before = Precise.string_max('0', Precise.string_sub(after, amount))
1121
1122
  timestamp = self.safe_integer(item, 'TimeStamp')
1122
- return {
1123
+ return self.safe_ledger_entry({
1123
1124
  'info': item,
1124
1125
  'id': self.safe_string(item, 'TransactionId'),
1125
1126
  'direction': direction,
@@ -1135,15 +1136,15 @@ class ndax(Exchange, ImplicitAPI):
1135
1136
  'timestamp': timestamp,
1136
1137
  'datetime': self.iso8601(timestamp),
1137
1138
  'fee': None,
1138
- }
1139
+ }, currency)
1139
1140
 
1140
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1141
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1141
1142
  """
1142
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1143
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1143
1144
  :see: https://apidoc.ndax.io/#getaccounttransactions
1144
- :param str code: unified currency code, default is None
1145
+ :param str [code]: unified currency code, default is None
1145
1146
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1146
- :param int [limit]: max number of ledger entrys to return, default is None
1147
+ :param int [limit]: max number of ledger entries to return, default is None
1147
1148
  :param dict [params]: extra parameters specific to the exchange API endpoint
1148
1149
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1149
1150
  """
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.okcoin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, 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, LedgerEntry, 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 AuthenticationError
@@ -2668,15 +2668,15 @@ class okcoin(Exchange, ImplicitAPI):
2668
2668
  }
2669
2669
  return await self.fetch_my_trades(symbol, since, limit, self.extend(request, params))
2670
2670
 
2671
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2671
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2672
2672
  """
2673
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2673
2674
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-asset-bills-details
2674
2675
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
2675
2676
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
2676
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2677
- :param str code: unified currency code, default is None
2677
+ :param str [code]: unified currency code, default is None
2678
2678
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2679
- :param int [limit]: max number of ledger entrys to return, default is None
2679
+ :param int [limit]: max number of ledger entries to return, default is None
2680
2680
  :param dict [params]: extra parameters specific to the exchange API endpoint
2681
2681
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2682
2682
  """
@@ -2776,7 +2776,7 @@ class okcoin(Exchange, ImplicitAPI):
2776
2776
  }
2777
2777
  return self.safe_string(types, type, type)
2778
2778
 
2779
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2779
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2780
2780
  #
2781
2781
  # privateGetAccountBills, privateGetAccountBillsArchive
2782
2782
  #
@@ -2813,45 +2813,36 @@ class okcoin(Exchange, ImplicitAPI):
2813
2813
  # "ts": "1597026383085"
2814
2814
  # }
2815
2815
  #
2816
- id = self.safe_string(item, 'billId')
2817
- account = None
2818
- referenceId = self.safe_string(item, 'ordId')
2819
- referenceAccount = None
2820
- type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
2821
- code = self.safe_currency_code(self.safe_string(item, 'ccy'), currency)
2822
- amountString = self.safe_string(item, 'balChg')
2823
- amount = self.parse_number(amountString)
2816
+ currencyId = self.safe_string(item, 'ccy')
2817
+ code = self.safe_currency_code(currencyId, currency)
2818
+ currency = self.safe_currency(currencyId, currency)
2824
2819
  timestamp = self.safe_integer(item, 'ts')
2825
2820
  feeCostString = self.safe_string(item, 'fee')
2826
2821
  fee = None
2827
2822
  if feeCostString is not None:
2828
2823
  fee = {
2829
- 'cost': self.parse_number(Precise.string_neg(feeCostString)),
2824
+ 'cost': self.parse_to_numeric(Precise.string_neg(feeCostString)),
2830
2825
  'currency': code,
2831
2826
  }
2832
- before = None
2833
- afterString = self.safe_string(item, 'bal')
2834
- after = self.parse_number(afterString)
2835
- status = 'ok'
2836
2827
  marketId = self.safe_string(item, 'instId')
2837
2828
  symbol = self.safe_symbol(marketId, None, '-')
2838
- return {
2839
- 'id': id,
2829
+ return self.safe_ledger_entry({
2840
2830
  'info': item,
2831
+ 'id': self.safe_string(item, 'billId'),
2841
2832
  'timestamp': timestamp,
2842
2833
  'datetime': self.iso8601(timestamp),
2843
- 'account': account,
2844
- 'referenceId': referenceId,
2845
- 'referenceAccount': referenceAccount,
2846
- 'type': type,
2834
+ 'account': None,
2835
+ 'referenceId': self.safe_string(item, 'ordId'),
2836
+ 'referenceAccount': None,
2837
+ 'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
2847
2838
  'currency': code,
2848
2839
  'symbol': symbol,
2849
- 'amount': amount,
2850
- 'before': before, # balance before
2851
- 'after': after, # balance after
2852
- 'status': status,
2840
+ 'amount': self.safe_number(item, 'balChg'),
2841
+ 'before': None, # balance before
2842
+ 'after': self.safe_number(item, 'bal'), # balance after
2843
+ 'status': 'ok',
2853
2844
  'fee': fee,
2854
- }
2845
+ }, currency)
2855
2846
 
2856
2847
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
2857
2848
  isArray = isinstance(params, list)
ccxt/async_support/okx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.okx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from typing import Any
13
13
  from ccxt.base.errors import ExchangeError
@@ -815,6 +815,7 @@ class okx(Exchange, ImplicitAPI):
815
815
  # SPOT/MARGIN error codes 54000-54999
816
816
  '54000': ExchangeError, # Margin transactions unavailable
817
817
  '54001': ExchangeError, # Only Multi-currency margin account can be set to borrow coins automatically
818
+ '54011': InvalidOrder, # 200 Pre-market trading contracts are only allowed to reduce the number of positions within 1 hour before delivery. Please modify or cancel the order.
818
819
  # Trading bot Error Code from 55100 to 55999
819
820
  '55100': InvalidOrder, # Take profit % should be within the range of {parameter1}-{parameter2}
820
821
  '55101': InvalidOrder, # Stop loss % should be within the range of {parameter1}-{parameter2}
@@ -4184,19 +4185,19 @@ class okx(Exchange, ImplicitAPI):
4184
4185
  }
4185
4186
  return await self.fetch_my_trades(symbol, since, limit, self.extend(request, params))
4186
4187
 
4187
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
4188
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
4188
4189
  """
4189
4190
  fetch the history of changes, actions done by the user or operations that altered balance of the user
4190
4191
  :see: https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
4191
4192
  :see: https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
4192
4193
  :see: https://www.okx.com/docs-v5/en/#rest-api-funding-asset-bills-details
4193
- :param str code: unified currency code, default is None
4194
+ :param str [code]: unified currency code, default is None
4194
4195
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
4195
- :param int [limit]: max number of ledger entrys to return, default is None
4196
+ :param int [limit]: max number of ledger entries to return, default is None
4196
4197
  :param dict [params]: extra parameters specific to the exchange API endpoint
4197
4198
  :param str [params.marginMode]: 'cross' or 'isolated'
4198
4199
  :param int [params.until]: the latest time in ms to fetch entries for
4199
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4200
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4200
4201
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
4201
4202
  """
4202
4203
  await self.load_markets()
@@ -4312,7 +4313,7 @@ class okx(Exchange, ImplicitAPI):
4312
4313
  }
4313
4314
  return self.safe_string(types, type, type)
4314
4315
 
4315
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
4316
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
4316
4317
  #
4317
4318
  # privateGetAccountBills, privateGetAccountBillsArchive
4318
4319
  #
@@ -4349,14 +4350,9 @@ class okx(Exchange, ImplicitAPI):
4349
4350
  # "ts": "1597026383085"
4350
4351
  # }
4351
4352
  #
4352
- id = self.safe_string(item, 'billId')
4353
- account = None
4354
- referenceId = self.safe_string(item, 'ordId')
4355
- referenceAccount = None
4356
- type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
4357
- code = self.safe_currency_code(self.safe_string(item, 'ccy'), currency)
4358
- amountString = self.safe_string(item, 'balChg')
4359
- amount = self.parse_number(amountString)
4353
+ currencyId = self.safe_string(item, 'ccy')
4354
+ code = self.safe_currency_code(currencyId, currency)
4355
+ currency = self.safe_currency(currencyId, currency)
4360
4356
  timestamp = self.safe_integer(item, 'ts')
4361
4357
  feeCostString = self.safe_string(item, 'fee')
4362
4358
  fee = None
@@ -4365,29 +4361,25 @@ class okx(Exchange, ImplicitAPI):
4365
4361
  'cost': self.parse_number(Precise.string_neg(feeCostString)),
4366
4362
  'currency': code,
4367
4363
  }
4368
- before = None
4369
- afterString = self.safe_string(item, 'bal')
4370
- after = self.parse_number(afterString)
4371
- status = 'ok'
4372
4364
  marketId = self.safe_string(item, 'instId')
4373
4365
  symbol = self.safe_symbol(marketId, None, '-')
4374
- return {
4375
- 'id': id,
4366
+ return self.safe_ledger_entry({
4376
4367
  'info': item,
4368
+ 'id': self.safe_string(item, 'billId'),
4377
4369
  'timestamp': timestamp,
4378
4370
  'datetime': self.iso8601(timestamp),
4379
- 'account': account,
4380
- 'referenceId': referenceId,
4381
- 'referenceAccount': referenceAccount,
4382
- 'type': type,
4371
+ 'account': None,
4372
+ 'referenceId': self.safe_string(item, 'ordId'),
4373
+ 'referenceAccount': None,
4374
+ 'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
4383
4375
  'currency': code,
4384
4376
  'symbol': symbol,
4385
- 'amount': amount,
4386
- 'before': before, # balance before
4387
- 'after': after, # balance after
4388
- 'status': status,
4377
+ 'amount': self.safe_number(item, 'balChg'),
4378
+ 'before': None,
4379
+ 'after': self.safe_number(item, 'bal'),
4380
+ 'status': 'ok',
4389
4381
  'fee': fee,
4390
- }
4382
+ }, currency)
4391
4383
 
4392
4384
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
4393
4385
  #