ccxt 4.4.3__py2.py3-none-any.whl → 4.4.5__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 (90) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binanceus.py +36 -36
  3. ccxt/async_support/__init__.py +1 -1
  4. ccxt/async_support/base/exchange.py +24 -13
  5. ccxt/async_support/base/ws/cache.py +1 -0
  6. ccxt/async_support/binance.py +43 -18
  7. ccxt/async_support/binanceus.py +1 -0
  8. ccxt/async_support/bingx.py +1 -0
  9. ccxt/async_support/bitfinex2.py +10 -9
  10. ccxt/async_support/bitget.py +55 -99
  11. ccxt/async_support/bitmex.py +14 -13
  12. ccxt/async_support/bitso.py +8 -7
  13. ccxt/async_support/bitstamp.py +12 -12
  14. ccxt/async_support/blofin.py +24 -26
  15. ccxt/async_support/bybit.py +101 -29
  16. ccxt/async_support/coinbase.py +31 -10
  17. ccxt/async_support/coinbaseexchange.py +14 -14
  18. ccxt/async_support/coinlist.py +9 -8
  19. ccxt/async_support/coinmetro.py +6 -6
  20. ccxt/async_support/cryptocom.py +10 -8
  21. ccxt/async_support/currencycom.py +9 -9
  22. ccxt/async_support/delta.py +8 -8
  23. ccxt/async_support/digifinex.py +11 -9
  24. ccxt/async_support/gate.py +9 -8
  25. ccxt/async_support/hashkey.py +12 -10
  26. ccxt/async_support/htx.py +16 -19
  27. ccxt/async_support/hyperliquid.py +70 -117
  28. ccxt/async_support/kraken.py +12 -10
  29. ccxt/async_support/kucoin.py +12 -11
  30. ccxt/async_support/luno.py +13 -12
  31. ccxt/async_support/lykke.py +2 -2
  32. ccxt/async_support/mexc.py +41 -3
  33. ccxt/async_support/ndax.py +9 -8
  34. ccxt/async_support/okcoin.py +21 -30
  35. ccxt/async_support/okx.py +21 -29
  36. ccxt/async_support/paradex.py +1 -1
  37. ccxt/async_support/woo.py +10 -9
  38. ccxt/async_support/woofipro.py +11 -9
  39. ccxt/async_support/xt.py +7 -6
  40. ccxt/async_support/zonda.py +9 -8
  41. ccxt/base/exchange.py +3 -1
  42. ccxt/binance.py +43 -18
  43. ccxt/binanceus.py +1 -0
  44. ccxt/bingx.py +1 -0
  45. ccxt/bitfinex2.py +10 -9
  46. ccxt/bitget.py +55 -99
  47. ccxt/bitmex.py +14 -13
  48. ccxt/bitso.py +8 -7
  49. ccxt/bitstamp.py +12 -12
  50. ccxt/blofin.py +24 -26
  51. ccxt/bybit.py +101 -29
  52. ccxt/coinbase.py +31 -10
  53. ccxt/coinbaseexchange.py +14 -14
  54. ccxt/coinlist.py +9 -8
  55. ccxt/coinmetro.py +6 -6
  56. ccxt/cryptocom.py +10 -8
  57. ccxt/currencycom.py +9 -9
  58. ccxt/delta.py +8 -8
  59. ccxt/digifinex.py +11 -9
  60. ccxt/gate.py +9 -8
  61. ccxt/hashkey.py +12 -10
  62. ccxt/htx.py +16 -19
  63. ccxt/hyperliquid.py +70 -117
  64. ccxt/kraken.py +12 -10
  65. ccxt/kucoin.py +12 -11
  66. ccxt/luno.py +13 -12
  67. ccxt/lykke.py +2 -2
  68. ccxt/mexc.py +40 -3
  69. ccxt/ndax.py +9 -8
  70. ccxt/okcoin.py +21 -30
  71. ccxt/okx.py +21 -29
  72. ccxt/paradex.py +1 -1
  73. ccxt/pro/__init__.py +1 -1
  74. ccxt/pro/binance.py +6 -2
  75. ccxt/pro/binanceus.py +2 -1
  76. ccxt/pro/bybit.py +51 -0
  77. ccxt/pro/hyperliquid.py +14 -1
  78. ccxt/pro/mexc.py +78 -0
  79. ccxt/pro/paradex.py +1 -0
  80. ccxt/test/tests_async.py +1 -1
  81. ccxt/test/tests_sync.py +1 -1
  82. ccxt/woo.py +10 -9
  83. ccxt/woofipro.py +11 -9
  84. ccxt/xt.py +7 -6
  85. ccxt/zonda.py +9 -8
  86. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/METADATA +5 -5
  87. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/RECORD +90 -90
  88. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/LICENSE.txt +0 -0
  89. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/WHEEL +0 -0
  90. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/top_level.txt +0 -0
@@ -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
@@ -103,7 +104,7 @@ class mexc(Exchange, ImplicitAPI):
103
104
  'fetchOrderBooks': None,
104
105
  'fetchOrders': True,
105
106
  'fetchOrderTrades': True,
106
- 'fetchPosition': True,
107
+ 'fetchPosition': 'emulated',
107
108
  'fetchPositionHistory': 'emulated',
108
109
  'fetchPositionMode': True,
109
110
  'fetchPositions': True,
@@ -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,
@@ -2732,6 +2737,9 @@ class mexc(Exchange, ImplicitAPI):
2732
2737
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
2733
2738
  """
2734
2739
  cancels an open order
2740
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
2741
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2742
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
2735
2743
  :param str id: order id
2736
2744
  :param str symbol: unified symbol of the market the order was made in
2737
2745
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2834,6 +2842,7 @@ class mexc(Exchange, ImplicitAPI):
2834
2842
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
2835
2843
  """
2836
2844
  cancel multiple orders
2845
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2837
2846
  :param str[] ids: order ids
2838
2847
  :param str symbol: unified market symbol, default is None
2839
2848
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2865,6 +2874,9 @@ class mexc(Exchange, ImplicitAPI):
2865
2874
  async def cancel_all_orders(self, symbol: Str = None, params={}):
2866
2875
  """
2867
2876
  cancel all open orders
2877
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
2878
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
2879
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
2868
2880
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2869
2881
  :param dict [params]: extra parameters specific to the exchange API endpoint
2870
2882
  :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
@@ -3251,6 +3263,8 @@ class mexc(Exchange, ImplicitAPI):
3251
3263
  async def fetch_accounts(self, params={}) -> List[Account]:
3252
3264
  """
3253
3265
  fetch all the accounts associated with a profile
3266
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3267
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3254
3268
  :param dict [params]: extra parameters specific to the exchange API endpoint
3255
3269
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
3256
3270
  """
@@ -3275,6 +3289,8 @@ class mexc(Exchange, ImplicitAPI):
3275
3289
  async def fetch_trading_fees(self, params={}) -> TradingFees:
3276
3290
  """
3277
3291
  fetch the trading fees for multiple markets
3292
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3293
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3278
3294
  :param dict [params]: extra parameters specific to the exchange API endpoint
3279
3295
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
3280
3296
  """
@@ -3539,6 +3555,8 @@ class mexc(Exchange, ImplicitAPI):
3539
3555
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3540
3556
  """
3541
3557
  fetch all trades made by the user
3558
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3559
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
3542
3560
  :param str symbol: unified market symbol
3543
3561
  :param int [since]: the earliest time in ms to fetch trades for
3544
3562
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -3619,6 +3637,8 @@ class mexc(Exchange, ImplicitAPI):
3619
3637
  async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3620
3638
  """
3621
3639
  fetch all the trades made from a single order
3640
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3641
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
3622
3642
  :param str id: order id
3623
3643
  :param str symbol: unified market symbol
3624
3644
  :param int [since]: the earliest time in ms to fetch trades for
@@ -3710,6 +3730,7 @@ class mexc(Exchange, ImplicitAPI):
3710
3730
  async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3711
3731
  """
3712
3732
  remove margin from a position
3733
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3713
3734
  :param str symbol: unified market symbol
3714
3735
  :param float amount: the amount of margin to remove
3715
3736
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3720,6 +3741,7 @@ class mexc(Exchange, ImplicitAPI):
3720
3741
  async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3721
3742
  """
3722
3743
  add margin
3744
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3723
3745
  :param str symbol: unified market symbol
3724
3746
  :param float amount: amount of margin to add
3725
3747
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3730,6 +3752,7 @@ class mexc(Exchange, ImplicitAPI):
3730
3752
  async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
3731
3753
  """
3732
3754
  set the level of leverage for a market
3755
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
3733
3756
  :param float leverage: the rate of leverage
3734
3757
  :param str symbol: unified market symbol
3735
3758
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3757,6 +3780,7 @@ class mexc(Exchange, ImplicitAPI):
3757
3780
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3758
3781
  """
3759
3782
  fetch the history of funding payments paid and received on self account
3783
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
3760
3784
  :param str symbol: unified market symbol
3761
3785
  :param int [since]: the earliest time in ms to fetch funding history for
3762
3786
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3867,6 +3891,7 @@ class mexc(Exchange, ImplicitAPI):
3867
3891
  async def fetch_funding_rate(self, symbol: str, params={}):
3868
3892
  """
3869
3893
  fetch the current funding rate
3894
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
3870
3895
  :param str symbol: unified market symbol
3871
3896
  :param dict [params]: extra parameters specific to the exchange API endpoint
3872
3897
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -3898,6 +3923,7 @@ class mexc(Exchange, ImplicitAPI):
3898
3923
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3899
3924
  """
3900
3925
  fetches historical funding rate prices
3926
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
3901
3927
  :param str symbol: unified symbol of the market to fetch the funding rate history for
3902
3928
  :param int [since]: not used by mexc, but filtered internally by ccxt
3903
3929
  :param int [limit]: mexc limit is page_size default 20, maximum is 100
@@ -4430,6 +4456,7 @@ class mexc(Exchange, ImplicitAPI):
4430
4456
  async def fetch_position(self, symbol: str, params={}):
4431
4457
  """
4432
4458
  fetch data on a single open contract trade position
4459
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4433
4460
  :param str symbol: unified market symbol of the market the position is held in, default is None
4434
4461
  :param dict [params]: extra parameters specific to the exchange API endpoint
4435
4462
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4445,6 +4472,7 @@ class mexc(Exchange, ImplicitAPI):
4445
4472
  async def fetch_positions(self, symbols: Strings = None, params={}):
4446
4473
  """
4447
4474
  fetch all open positions
4475
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4448
4476
  :param str[]|None symbols: list of unified market symbols
4449
4477
  :param dict [params]: extra parameters specific to the exchange API endpoint
4450
4478
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4588,6 +4616,14 @@ class mexc(Exchange, ImplicitAPI):
4588
4616
  })
4589
4617
 
4590
4618
  async def fetch_transfer(self, id: str, code: Str = None, params={}) -> TransferEntry:
4619
+ """
4620
+ fetches a transfer
4621
+ :see: https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
4622
+ :param str id: transfer id
4623
+ :param str [code]: not used by mexc fetchTransfer
4624
+ :param dict params: extra parameters specific to the exchange api endpoint
4625
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
4626
+ """
4591
4627
  marketType, query = self.handle_market_type_and_params('fetchTransfer', None, params)
4592
4628
  await self.load_markets()
4593
4629
  if marketType == 'spot':
@@ -4617,6 +4653,8 @@ class mexc(Exchange, ImplicitAPI):
4617
4653
  async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4618
4654
  """
4619
4655
  fetch a history of internal transfers made on an account
4656
+ :see: https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
4657
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
4620
4658
  :param str code: unified currency code of the currency transferred
4621
4659
  :param int [since]: the earliest time in ms to fetch transfers for
4622
4660
  :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
  #
@@ -640,7 +640,7 @@ class paradex(Exchange, ImplicitAPI):
640
640
  'low': None,
641
641
  'bid': self.safe_string(ticker, 'bid'),
642
642
  'bidVolume': None,
643
- 'ask': self.safe_string(ticker, 'sdk'),
643
+ 'ask': self.safe_string(ticker, 'ask'),
644
644
  'askVolume': None,
645
645
  'vwap': None,
646
646
  'open': None,
ccxt/async_support/woo.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.woo import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, LedgerEntry, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from typing import Any
12
12
  from ccxt.base.errors import ExchangeError
@@ -1991,29 +1991,31 @@ class woo(Exchange, ImplicitAPI):
1991
1991
  # }
1992
1992
  return [currency, self.safe_list(response, 'rows', [])]
1993
1993
 
1994
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1994
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1995
1995
  """
1996
1996
  fetch the history of changes, actions done by the user or operations that altered balance of the user
1997
1997
  :see: https://docs.woo.org/#get-asset-history
1998
- :param str code: unified currency code, default is None
1998
+ :param str [code]: unified currency code, default is None
1999
1999
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2000
- :param int [limit]: max number of ledger entrys to return, default is None
2000
+ :param int [limit]: max number of ledger entries to return, default is None
2001
2001
  :param dict [params]: extra parameters specific to the exchange API endpoint
2002
2002
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2003
2003
  """
2004
2004
  currency, rows = await self.get_asset_history_rows(code, since, limit, params)
2005
2005
  return self.parse_ledger(rows, currency, since, limit, params)
2006
2006
 
2007
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2007
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2008
2008
  networkizedCode = self.safe_string(item, 'token')
2009
2009
  currencyDefined = self.get_currency_from_chaincode(networkizedCode, currency)
2010
2010
  code = currencyDefined['code']
2011
+ currency = self.safe_currency(code, currency)
2011
2012
  amount = self.safe_number(item, 'amount')
2012
2013
  side = self.safe_string(item, 'token_side')
2013
2014
  direction = 'in' if (side == 'DEPOSIT') else 'out'
2014
2015
  timestamp = self.safe_timestamp(item, 'created_time')
2015
2016
  fee = self.parse_token_and_fee_temp(item, 'fee_token', 'fee_amount')
2016
- return {
2017
+ return self.safe_ledger_entry({
2018
+ 'info': item,
2017
2019
  'id': self.safe_string(item, 'id'),
2018
2020
  'currency': code,
2019
2021
  'account': self.safe_string(item, 'account'),
@@ -2023,13 +2025,12 @@ class woo(Exchange, ImplicitAPI):
2023
2025
  'amount': amount,
2024
2026
  'before': None,
2025
2027
  'after': None,
2026
- 'fee': fee,
2027
2028
  'direction': direction,
2028
2029
  'timestamp': timestamp,
2029
2030
  'datetime': self.iso8601(timestamp),
2030
2031
  'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
2031
- 'info': item,
2032
- }
2032
+ 'fee': fee,
2033
+ }, currency)
2033
2034
 
2034
2035
  def parse_ledger_entry_type(self, type):
2035
2036
  types: dict = {
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.woofipro import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction
8
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction
9
9
  from typing import List
10
10
  from typing import Any
11
11
  from ccxt.base.errors import ExchangeError
@@ -1987,14 +1987,16 @@ class woofipro(Exchange, ImplicitAPI):
1987
1987
  data = self.safe_dict(response, 'data', {})
1988
1988
  return [currency, self.safe_list(data, 'rows', [])]
1989
1989
 
1990
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1991
- code = self.safe_string(item, 'token')
1990
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1991
+ currencyId = self.safe_string(item, 'token')
1992
+ code = self.safe_currency_code(currencyId, currency)
1993
+ currency = self.safe_currency(currencyId, currency)
1992
1994
  amount = self.safe_number(item, 'amount')
1993
1995
  side = self.safe_string(item, 'token_side')
1994
1996
  direction = 'in' if (side == 'DEPOSIT') else 'out'
1995
1997
  timestamp = self.safe_integer(item, 'created_time')
1996
1998
  fee = self.parse_token_and_fee_temp(item, 'fee_token', 'fee_amount')
1997
- return {
1999
+ return self.safe_ledger_entry({
1998
2000
  'id': self.safe_string(item, 'id'),
1999
2001
  'currency': code,
2000
2002
  'account': self.safe_string(item, 'account'),
@@ -2010,7 +2012,7 @@ class woofipro(Exchange, ImplicitAPI):
2010
2012
  'datetime': self.iso8601(timestamp),
2011
2013
  'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
2012
2014
  'info': item,
2013
- }
2015
+ }, currency)
2014
2016
 
2015
2017
  def parse_ledger_entry_type(self, type):
2016
2018
  types: dict = {
@@ -2019,13 +2021,13 @@ class woofipro(Exchange, ImplicitAPI):
2019
2021
  }
2020
2022
  return self.safe_string(types, type, type)
2021
2023
 
2022
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2024
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2023
2025
  """
2024
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2026
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2025
2027
  :see: https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history
2026
- :param str code: unified currency code, default is None
2028
+ :param str [code]: unified currency code, default is None
2027
2029
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2028
- :param int [limit]: max number of ledger entrys to return, default is None
2030
+ :param int [limit]: max number of ledger entries to return, default is None
2029
2031
  :param dict [params]: extra parameters specific to the exchange API endpoint
2030
2032
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2031
2033
  """
ccxt/async_support/xt.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.xt import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Currencies, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
10
+ from ccxt.base.types import Currencies, Currency, Int, LedgerEntry, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -3311,7 +3311,7 @@ class xt(Exchange, ImplicitAPI):
3311
3311
  }
3312
3312
  return self.safe_string(statuses, status, status)
3313
3313
 
3314
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3314
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
3315
3315
  """
3316
3316
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
3317
3317
  :see: https://doc.xt.com/#futures_usergetBalanceBill
@@ -3368,7 +3368,7 @@ class xt(Exchange, ImplicitAPI):
3368
3368
  ledger = self.safe_value(data, 'items', [])
3369
3369
  return self.parse_ledger(ledger, currency, since, limit)
3370
3370
 
3371
- def parse_ledger_entry(self, item, currency=None):
3371
+ def parse_ledger_entry(self, item, currency=None) -> LedgerEntry:
3372
3372
  #
3373
3373
  # {
3374
3374
  # "id": "207260567109387524",
@@ -3384,8 +3384,10 @@ class xt(Exchange, ImplicitAPI):
3384
3384
  side = self.safe_string(item, 'side')
3385
3385
  direction = 'in' if (side == 'ADD') else 'out'
3386
3386
  currencyId = self.safe_string(item, 'coin')
3387
+ currency = self.safe_currency(currencyId, currency)
3387
3388
  timestamp = self.safe_integer(item, 'createdTime')
3388
- return {
3389
+ return self.safe_ledger_entry({
3390
+ 'info': item,
3389
3391
  'id': self.safe_string(item, 'id'),
3390
3392
  'direction': direction,
3391
3393
  'account': None,
@@ -3403,8 +3405,7 @@ class xt(Exchange, ImplicitAPI):
3403
3405
  'currency': None,
3404
3406
  'cost': None,
3405
3407
  },
3406
- 'info': item,
3407
- }
3408
+ }, currency)
3408
3409
 
3409
3410
  def parse_ledger_entry_type(self, type):
3410
3411
  ledgerType = {