ccxt 4.4.2__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 (87) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bitmart.py +1 -0
  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 +50 -25
  7. ccxt/async_support/bingx.py +1 -0
  8. ccxt/async_support/bitfinex2.py +10 -9
  9. ccxt/async_support/bitget.py +13 -9
  10. ccxt/async_support/bitmart.py +3 -1
  11. ccxt/async_support/bitmex.py +14 -13
  12. ccxt/async_support/bitso.py +8 -7
  13. ccxt/async_support/bitstamp.py +36 -48
  14. ccxt/async_support/blofin.py +24 -26
  15. ccxt/async_support/bybit.py +26 -23
  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 +12 -9
  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/mexc.py +49 -2
  32. ccxt/async_support/ndax.py +9 -8
  33. ccxt/async_support/okcoin.py +21 -30
  34. ccxt/async_support/okx.py +21 -29
  35. ccxt/async_support/woo.py +10 -9
  36. ccxt/async_support/woofipro.py +11 -9
  37. ccxt/async_support/xt.py +12 -7
  38. ccxt/async_support/zonda.py +9 -8
  39. ccxt/base/exchange.py +3 -1
  40. ccxt/binance.py +50 -25
  41. ccxt/bingx.py +1 -0
  42. ccxt/bitfinex2.py +10 -9
  43. ccxt/bitget.py +13 -9
  44. ccxt/bitmart.py +3 -1
  45. ccxt/bitmex.py +14 -13
  46. ccxt/bitso.py +8 -7
  47. ccxt/bitstamp.py +36 -48
  48. ccxt/blofin.py +24 -26
  49. ccxt/bybit.py +26 -23
  50. ccxt/coinbase.py +31 -10
  51. ccxt/coinbaseexchange.py +14 -14
  52. ccxt/coinlist.py +9 -8
  53. ccxt/coinmetro.py +6 -6
  54. ccxt/cryptocom.py +12 -9
  55. ccxt/currencycom.py +9 -9
  56. ccxt/delta.py +8 -8
  57. ccxt/digifinex.py +11 -9
  58. ccxt/gate.py +9 -8
  59. ccxt/hashkey.py +12 -10
  60. ccxt/htx.py +16 -19
  61. ccxt/hyperliquid.py +70 -117
  62. ccxt/kraken.py +12 -10
  63. ccxt/kucoin.py +12 -11
  64. ccxt/luno.py +13 -12
  65. ccxt/mexc.py +48 -2
  66. ccxt/ndax.py +9 -8
  67. ccxt/okcoin.py +21 -30
  68. ccxt/okx.py +21 -29
  69. ccxt/pro/__init__.py +1 -1
  70. ccxt/pro/bybit.py +51 -0
  71. ccxt/pro/cryptocom.py +181 -22
  72. ccxt/pro/mexc.py +154 -4
  73. ccxt/pro/okx.py +5 -3
  74. ccxt/pro/oxfun.py +70 -0
  75. ccxt/pro/phemex.py +41 -2
  76. ccxt/pro/woofipro.py +64 -0
  77. ccxt/test/tests_async.py +1 -1
  78. ccxt/test/tests_sync.py +1 -1
  79. ccxt/woo.py +10 -9
  80. ccxt/woofipro.py +11 -9
  81. ccxt/xt.py +12 -7
  82. ccxt/zonda.py +9 -8
  83. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/METADATA +5 -5
  84. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/RECORD +87 -87
  85. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/LICENSE.txt +0 -0
  86. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/WHEEL +0 -0
  87. {ccxt-4.4.2.dist-info → ccxt-4.4.4.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
@@ -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
@@ -4855,6 +4887,14 @@ class mexc(Exchange, ImplicitAPI):
4855
4887
  return self.parse_transaction(response, currency)
4856
4888
 
4857
4889
  async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
4890
+ """
4891
+ set hedged to True or False for a market
4892
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
4893
+ :param bool hedged: set to True to use dualSidePosition
4894
+ :param str symbol: not used by mexc setPositionMode()
4895
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4896
+ :returns dict: response from the exchange
4897
+ """
4858
4898
  request: dict = {
4859
4899
  'positionMode': 1 if hedged else 2, # 1 Hedge, 2 One-way, before changing position mode make sure that there are no active orders, planned orders, or open positions, the risk limit level will be reset to 1
4860
4900
  }
@@ -4868,6 +4908,13 @@ class mexc(Exchange, ImplicitAPI):
4868
4908
  return response
4869
4909
 
4870
4910
  async def fetch_position_mode(self, symbol: Str = None, params={}):
4911
+ """
4912
+ fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
4913
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
4914
+ :param str symbol: not used by mexc fetchPositionMode
4915
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4916
+ :returns dict: an object detailing whether the market is in hedged or one-way mode
4917
+ """
4871
4918
  response = await self.contractPrivateGetPositionPositionMode(params)
4872
4919
  #
4873
4920
  # {
@@ -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
  #
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
@@ -1138,17 +1138,21 @@ class xt(Exchange, ImplicitAPI):
1138
1138
  maxCost = None
1139
1139
  minPrice = None
1140
1140
  maxPrice = None
1141
+ amountPrecision = None
1141
1142
  for i in range(0, len(filters)):
1142
1143
  entry = filters[i]
1143
1144
  filter = self.safe_string(entry, 'filter')
1144
1145
  if filter == 'QUANTITY':
1145
1146
  minAmount = self.safe_number(entry, 'min')
1146
1147
  maxAmount = self.safe_number(entry, 'max')
1148
+ amountPrecision = self.safe_number(entry, 'tickSize')
1147
1149
  if filter == 'QUOTE_QTY':
1148
1150
  minCost = self.safe_number(entry, 'min')
1149
1151
  if filter == 'PRICE':
1150
1152
  minPrice = self.safe_number(entry, 'min')
1151
1153
  maxPrice = self.safe_number(entry, 'max')
1154
+ if amountPrecision is None:
1155
+ amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
1152
1156
  underlyingType = self.safe_string(market, 'underlyingType')
1153
1157
  linear = None
1154
1158
  inverse = None
@@ -1223,7 +1227,7 @@ class xt(Exchange, ImplicitAPI):
1223
1227
  'optionType': None,
1224
1228
  'precision': {
1225
1229
  'price': self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision'))),
1226
- 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision'))),
1230
+ 'amount': amountPrecision,
1227
1231
  'base': self.parse_number(self.parse_precision(self.safe_string(market, 'baseCoinPrecision'))),
1228
1232
  'quote': self.parse_number(self.parse_precision(self.safe_string(market, 'quoteCoinPrecision'))),
1229
1233
  },
@@ -3307,7 +3311,7 @@ class xt(Exchange, ImplicitAPI):
3307
3311
  }
3308
3312
  return self.safe_string(statuses, status, status)
3309
3313
 
3310
- 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]:
3311
3315
  """
3312
3316
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
3313
3317
  :see: https://doc.xt.com/#futures_usergetBalanceBill
@@ -3364,7 +3368,7 @@ class xt(Exchange, ImplicitAPI):
3364
3368
  ledger = self.safe_value(data, 'items', [])
3365
3369
  return self.parse_ledger(ledger, currency, since, limit)
3366
3370
 
3367
- def parse_ledger_entry(self, item, currency=None):
3371
+ def parse_ledger_entry(self, item, currency=None) -> LedgerEntry:
3368
3372
  #
3369
3373
  # {
3370
3374
  # "id": "207260567109387524",
@@ -3380,8 +3384,10 @@ class xt(Exchange, ImplicitAPI):
3380
3384
  side = self.safe_string(item, 'side')
3381
3385
  direction = 'in' if (side == 'ADD') else 'out'
3382
3386
  currencyId = self.safe_string(item, 'coin')
3387
+ currency = self.safe_currency(currencyId, currency)
3383
3388
  timestamp = self.safe_integer(item, 'createdTime')
3384
- return {
3389
+ return self.safe_ledger_entry({
3390
+ 'info': item,
3385
3391
  'id': self.safe_string(item, 'id'),
3386
3392
  'direction': direction,
3387
3393
  'account': None,
@@ -3399,8 +3405,7 @@ class xt(Exchange, ImplicitAPI):
3399
3405
  'currency': None,
3400
3406
  'cost': None,
3401
3407
  },
3402
- 'info': item,
3403
- }
3408
+ }, currency)
3404
3409
 
3405
3410
  def parse_ledger_entry_type(self, type):
3406
3411
  ledgerType = {