ccxt 4.4.77__py2.py3-none-any.whl → 4.4.78__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 (103) hide show
  1. ccxt/__init__.py +3 -3
  2. ccxt/abstract/apex.py +31 -0
  3. ccxt/apex.py +1884 -0
  4. ccxt/ascendex.py +2 -2
  5. ccxt/async_support/__init__.py +3 -3
  6. ccxt/async_support/apex.py +1884 -0
  7. ccxt/async_support/ascendex.py +2 -2
  8. ccxt/async_support/base/exchange.py +1 -1
  9. ccxt/async_support/binance.py +3 -3
  10. ccxt/async_support/bingx.py +1 -1
  11. ccxt/async_support/bitfinex.py +2 -2
  12. ccxt/async_support/bitflyer.py +2 -2
  13. ccxt/async_support/bitget.py +134 -64
  14. ccxt/async_support/bitmart.py +2 -2
  15. ccxt/async_support/bitmex.py +6 -6
  16. ccxt/async_support/cex.py +1 -1
  17. ccxt/async_support/coinbase.py +29 -4
  18. ccxt/async_support/coincatch.py +66 -0
  19. ccxt/async_support/coinex.py +1 -1
  20. ccxt/async_support/cryptocom.py +2 -2
  21. ccxt/async_support/defx.py +1 -1
  22. ccxt/async_support/delta.py +1 -1
  23. ccxt/async_support/deribit.py +2 -2
  24. ccxt/async_support/derive.py +2 -2
  25. ccxt/async_support/digifinex.py +2 -2
  26. ccxt/async_support/gate.py +1 -1
  27. ccxt/async_support/hitbtc.py +5 -2
  28. ccxt/async_support/htx.py +2 -2
  29. ccxt/async_support/hyperliquid.py +13 -6
  30. ccxt/async_support/kraken.py +2 -2
  31. ccxt/async_support/krakenfutures.py +2 -2
  32. ccxt/async_support/kucoinfutures.py +2 -2
  33. ccxt/async_support/mexc.py +50 -52
  34. ccxt/async_support/okx.py +1 -1
  35. ccxt/async_support/oxfun.py +2 -2
  36. ccxt/async_support/paradex.py +2 -2
  37. ccxt/async_support/phemex.py +4 -3
  38. ccxt/async_support/poloniex.py +3 -3
  39. ccxt/async_support/probit.py +1 -0
  40. ccxt/async_support/tradeogre.py +2 -1
  41. ccxt/async_support/upbit.py +201 -43
  42. ccxt/async_support/vertex.py +2 -2
  43. ccxt/async_support/whitebit.py +1 -0
  44. ccxt/async_support/woo.py +5 -3
  45. ccxt/async_support/woofipro.py +2 -2
  46. ccxt/async_support/xt.py +9 -2
  47. ccxt/base/errors.py +6 -0
  48. ccxt/base/exchange.py +69 -2
  49. ccxt/binance.py +3 -3
  50. ccxt/bingx.py +1 -1
  51. ccxt/bitfinex.py +2 -2
  52. ccxt/bitflyer.py +2 -2
  53. ccxt/bitget.py +134 -64
  54. ccxt/bitmart.py +2 -2
  55. ccxt/bitmex.py +6 -6
  56. ccxt/cex.py +1 -1
  57. ccxt/coinbase.py +29 -4
  58. ccxt/coincatch.py +66 -0
  59. ccxt/coinex.py +1 -1
  60. ccxt/cryptocom.py +2 -2
  61. ccxt/defx.py +1 -1
  62. ccxt/delta.py +1 -1
  63. ccxt/deribit.py +2 -2
  64. ccxt/derive.py +2 -2
  65. ccxt/digifinex.py +2 -2
  66. ccxt/gate.py +1 -1
  67. ccxt/hitbtc.py +5 -2
  68. ccxt/htx.py +2 -2
  69. ccxt/hyperliquid.py +13 -6
  70. ccxt/kraken.py +2 -2
  71. ccxt/krakenfutures.py +2 -2
  72. ccxt/kucoinfutures.py +2 -2
  73. ccxt/mexc.py +50 -52
  74. ccxt/okx.py +1 -1
  75. ccxt/oxfun.py +2 -2
  76. ccxt/paradex.py +2 -2
  77. ccxt/phemex.py +4 -3
  78. ccxt/poloniex.py +3 -3
  79. ccxt/pro/__init__.py +5 -1
  80. ccxt/pro/apex.py +984 -0
  81. ccxt/pro/coinbase.py +4 -6
  82. ccxt/pro/gate.py +22 -2
  83. ccxt/pro/hollaex.py +2 -2
  84. ccxt/pro/p2b.py +2 -2
  85. ccxt/pro/tradeogre.py +272 -0
  86. ccxt/probit.py +1 -0
  87. ccxt/test/tests_async.py +4 -0
  88. ccxt/test/tests_sync.py +4 -0
  89. ccxt/tradeogre.py +2 -1
  90. ccxt/upbit.py +201 -43
  91. ccxt/vertex.py +2 -2
  92. ccxt/whitebit.py +1 -0
  93. ccxt/woo.py +5 -3
  94. ccxt/woofipro.py +2 -2
  95. ccxt/xt.py +9 -2
  96. {ccxt-4.4.77.dist-info → ccxt-4.4.78.dist-info}/METADATA +4 -4
  97. {ccxt-4.4.77.dist-info → ccxt-4.4.78.dist-info}/RECORD +100 -98
  98. ccxt/abstract/ace.py +0 -15
  99. ccxt/ace.py +0 -1152
  100. ccxt/async_support/ace.py +0 -1152
  101. {ccxt-4.4.77.dist-info → ccxt-4.4.78.dist-info}/LICENSE.txt +0 -0
  102. {ccxt-4.4.77.dist-info → ccxt-4.4.78.dist-info}/WHEEL +0 -0
  103. {ccxt-4.4.77.dist-info → ccxt-4.4.78.dist-info}/top_level.txt +0 -0
@@ -3859,7 +3859,7 @@ class coinex(Exchange, ImplicitAPI):
3859
3859
  data = self.safe_list(response, 'data', [])
3860
3860
  return self.parse_trades(data, market, since, limit)
3861
3861
 
3862
- async def fetch_positions(self, symbols: Strings = None, params={}):
3862
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3863
3863
  """
3864
3864
  fetch all open positions
3865
3865
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.cryptocom import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Any, Balances, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
9
+ from ccxt.base.types import Account, Any, Balances, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2789,7 +2789,7 @@ class cryptocom(Exchange, ImplicitAPI):
2789
2789
  data = self.safe_list(result, 'data', [])
2790
2790
  return self.parse_position(self.safe_dict(data, 0), market)
2791
2791
 
2792
- async def fetch_positions(self, symbols: Strings = None, params={}):
2792
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2793
2793
  """
2794
2794
  fetch all open positions
2795
2795
 
@@ -1495,7 +1495,7 @@ class defx(Exchange, ImplicitAPI):
1495
1495
  first = self.safe_dict(data, 0, {})
1496
1496
  return self.parse_position(first, market)
1497
1497
 
1498
- async def fetch_positions(self, symbols: Strings = None, params={}):
1498
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
1499
1499
  """
1500
1500
  fetch all open positions
1501
1501
 
@@ -1660,7 +1660,7 @@ class delta(Exchange, ImplicitAPI):
1660
1660
  result = self.safe_dict(response, 'result', {})
1661
1661
  return self.parse_position(result, market)
1662
1662
 
1663
- async def fetch_positions(self, symbols: Strings = None, params={}):
1663
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
1664
1664
  """
1665
1665
  fetch all open positions
1666
1666
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.deribit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Greeks, Int, Market, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, MarketInterface, TransferEntry
9
+ from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Greeks, Int, Market, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, MarketInterface, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2673,7 +2673,7 @@ class deribit(Exchange, ImplicitAPI):
2673
2673
  result = self.safe_dict(response, 'result')
2674
2674
  return self.parse_position(result)
2675
2675
 
2676
- async def fetch_positions(self, symbols: Strings = None, params={}):
2676
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2677
2677
  """
2678
2678
  fetch all open positions
2679
2679
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.derive import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderSide, OrderType, Str, Strings, Ticker, FundingRate, Trade, Transaction
9
+ from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderSide, OrderType, Position, Str, Strings, Ticker, FundingRate, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2028,7 +2028,7 @@ class derive(Exchange, ImplicitAPI):
2028
2028
  trades = self.safe_list(result, 'trades', [])
2029
2029
  return self.parse_trades(trades, market, since, limit, params)
2030
2030
 
2031
- async def fetch_positions(self, symbols: Strings = None, params={}):
2031
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2032
2032
  """
2033
2033
  fetch all open positions
2034
2034
 
@@ -8,7 +8,7 @@ from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Any, Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
11
+ from ccxt.base.types import Any, Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -3376,7 +3376,7 @@ class digifinex(Exchange, ImplicitAPI):
3376
3376
  'tierBased': None,
3377
3377
  }
3378
3378
 
3379
- async def fetch_positions(self, symbols: Strings = None, params={}):
3379
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3380
3380
  """
3381
3381
  fetch all open positions
3382
3382
 
@@ -5724,7 +5724,7 @@ class gate(Exchange, ImplicitAPI):
5724
5724
  #
5725
5725
  return self.parse_position(response, market)
5726
5726
 
5727
- async def fetch_positions(self, symbols: Strings = None, params={}):
5727
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
5728
5728
  """
5729
5729
  fetch all open positions
5730
5730
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hitbtc import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, OrderBooks, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, OrderBooks, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -966,6 +966,8 @@ class hitbtc(Exchange, ImplicitAPI):
966
966
  transferEnabled = self.safe_bool(entry, 'transfer_enabled', False)
967
967
  active = payinEnabled and payoutEnabled and transferEnabled
968
968
  rawNetworks = self.safe_value(entry, 'networks', [])
969
+ isCrypto = self.safe_bool(entry, 'crypto')
970
+ type = 'crypto' if isCrypto else 'fiat'
969
971
  networks: dict = {}
970
972
  fee = None
971
973
  depositEnabled = None
@@ -1023,6 +1025,7 @@ class hitbtc(Exchange, ImplicitAPI):
1023
1025
  'max': None,
1024
1026
  },
1025
1027
  },
1028
+ 'type': type,
1026
1029
  }
1027
1030
  return result
1028
1031
 
@@ -2823,7 +2826,7 @@ class hitbtc(Exchange, ImplicitAPI):
2823
2826
  sorted = self.sort_by(rates, 'timestamp')
2824
2827
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
2825
2828
 
2826
- async def fetch_positions(self, symbols: Strings = None, params={}):
2829
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2827
2830
  """
2828
2831
  fetch all open positions
2829
2832
 
ccxt/async_support/htx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.htx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -7338,7 +7338,7 @@ class htx(Exchange, ImplicitAPI):
7338
7338
  'takeProfitPrice': None,
7339
7339
  })
7340
7340
 
7341
- async def fetch_positions(self, symbols: Strings = None, params={}):
7341
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
7342
7342
  """
7343
7343
  fetch all open positions
7344
7344
 
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hyperliquid import ImplicitAPI
8
8
  import asyncio
9
9
  import math
10
- from ccxt.base.types import Any, Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Any, Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import ArgumentsRequired
@@ -772,12 +772,15 @@ class hyperliquid(Exchange, ImplicitAPI):
772
772
  :param dict [params]: extra parameters specific to the exchange API endpoint
773
773
  :param str [params.user]: user address, will default to self.walletAddress if not provided
774
774
  :param str [params.type]: wallet type, ['spot', 'swap'], defaults to swap
775
+ :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
775
776
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
776
777
  """
777
778
  userAddress = None
778
779
  userAddress, params = self.handle_public_address('fetchBalance', params)
779
780
  type = None
780
781
  type, params = self.handle_market_type_and_params('fetchBalance', None, params)
782
+ marginMode = None
783
+ marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params)
781
784
  isSpot = (type == 'spot')
782
785
  reqType = 'spotClearinghouseState' if (isSpot) else 'clearinghouseState'
783
786
  request: dict = {
@@ -834,12 +837,16 @@ class hyperliquid(Exchange, ImplicitAPI):
834
837
  spotBalances[code] = account
835
838
  return self.safe_balance(spotBalances)
836
839
  data = self.safe_dict(response, 'marginSummary', {})
840
+ usdcBalance = {
841
+ 'total': self.safe_number(data, 'accountValue'),
842
+ }
843
+ if (marginMode is not None) and (marginMode == 'isolated'):
844
+ usdcBalance['free'] = self.safe_number(response, 'withdrawable')
845
+ else:
846
+ usdcBalance['used'] = self.safe_number(data, 'totalMarginUsed')
837
847
  result: dict = {
838
848
  'info': response,
839
- 'USDC': {
840
- 'total': self.safe_number(data, 'accountValue'),
841
- 'used': self.safe_number(data, 'totalMarginUsed'),
842
- },
849
+ 'USDC': usdcBalance,
843
850
  }
844
851
  timestamp = self.safe_integer(response, 'time')
845
852
  result['timestamp'] = timestamp
@@ -2453,7 +2460,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2453
2460
  positions = await self.fetch_positions([symbol], params)
2454
2461
  return self.safe_dict(positions, 0, {})
2455
2462
 
2456
- async def fetch_positions(self, symbols: Strings = None, params={}):
2463
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2457
2464
  """
2458
2465
  fetch all open positions
2459
2466
 
@@ -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 Any, Balances, Currencies, Currency, DepositAddress, IndexType, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, IndexType, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, 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
@@ -3067,7 +3067,7 @@ class kraken(Exchange, ImplicitAPI):
3067
3067
  return self.parse_transaction(result, currency)
3068
3068
  raise ExchangeError(self.id + " withdraw() requires a 'key' parameter(withdrawal key name, up on your account)")
3069
3069
 
3070
- async def fetch_positions(self, symbols: Strings = None, params={}):
3070
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3071
3071
  """
3072
3072
  fetch all open positions
3073
3073
 
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.krakenfutures import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TransferEntry
9
+ from ccxt.base.types import Any, Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2287,7 +2287,7 @@ class krakenfutures(Exchange, ImplicitAPI):
2287
2287
  sorted = self.sort_by(result, 'timestamp')
2288
2288
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
2289
2289
 
2290
- async def fetch_positions(self, symbols: Strings = None, params={}):
2290
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2291
2291
  """
2292
2292
 
2293
2293
  https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.kucoin import kucoin
7
7
  from ccxt.abstract.kucoinfutures import ImplicitAPI
8
- from ccxt.base.types import Any, Balances, Currency, DepositAddress, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
8
+ from ccxt.base.types import Any, Balances, Currency, DepositAddress, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
9
9
  from typing import List
10
10
  from ccxt.base.errors import AuthenticationError
11
11
  from ccxt.base.errors import PermissionDenied
@@ -1232,7 +1232,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1232
1232
  data = self.safe_dict(response, 'data', {})
1233
1233
  return self.parse_position(data, market)
1234
1234
 
1235
- async def fetch_positions(self, symbols: Strings = None, params={}):
1235
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
1236
1236
  """
1237
1237
  fetch all open positions
1238
1238
 
@@ -1098,80 +1098,47 @@ class mexc(Exchange, ImplicitAPI):
1098
1098
  id = self.safe_string(currency, 'coin')
1099
1099
  code = self.safe_currency_code(id)
1100
1100
  name = self.safe_string(currency, 'name')
1101
- currencyActive = False
1102
- currencyFee = None
1103
- currencyWithdrawMin = None
1104
- currencyWithdrawMax = None
1105
- depositEnabled = False
1106
- withdrawEnabled = False
1107
1101
  networks: dict = {}
1108
1102
  chains = self.safe_value(currency, 'networkList', [])
1109
1103
  for j in range(0, len(chains)):
1110
1104
  chain = chains[j]
1111
1105
  networkId = self.safe_string_2(chain, 'netWork', 'network')
1112
1106
  network = self.network_id_to_code(networkId)
1113
- isDepositEnabled = self.safe_bool(chain, 'depositEnable', False)
1114
- isWithdrawEnabled = self.safe_bool(chain, 'withdrawEnable', False)
1115
- active = (isDepositEnabled and isWithdrawEnabled)
1116
- currencyActive = active or currencyActive
1117
- withdrawMin = self.safe_string(chain, 'withdrawMin')
1118
- withdrawMax = self.safe_string(chain, 'withdrawMax')
1119
- currencyWithdrawMin = withdrawMin if (currencyWithdrawMin is None) else currencyWithdrawMin
1120
- currencyWithdrawMax = withdrawMax if (currencyWithdrawMax is None) else currencyWithdrawMax
1121
- fee = self.safe_number(chain, 'withdrawFee')
1122
- currencyFee = fee if (currencyFee is None) else currencyFee
1123
- if Precise.string_gt(currencyWithdrawMin, withdrawMin):
1124
- currencyWithdrawMin = withdrawMin
1125
- if Precise.string_lt(currencyWithdrawMax, withdrawMax):
1126
- currencyWithdrawMax = withdrawMax
1127
- if isDepositEnabled:
1128
- depositEnabled = True
1129
- if isWithdrawEnabled:
1130
- withdrawEnabled = True
1131
1107
  networks[network] = {
1132
1108
  'info': chain,
1133
1109
  'id': networkId,
1134
1110
  'network': network,
1135
- 'active': active,
1136
- 'deposit': isDepositEnabled,
1137
- 'withdraw': isWithdrawEnabled,
1138
- 'fee': fee,
1111
+ 'active': None,
1112
+ 'deposit': self.safe_bool(chain, 'depositEnable', False),
1113
+ 'withdraw': self.safe_bool(chain, 'withdrawEnable', False),
1114
+ 'fee': self.safe_number(chain, 'withdrawFee'),
1139
1115
  'precision': None,
1140
1116
  'limits': {
1141
1117
  'withdraw': {
1142
- 'min': withdrawMin,
1143
- 'max': withdrawMax,
1118
+ 'min': self.safe_string(chain, 'withdrawMin'),
1119
+ 'max': self.safe_string(chain, 'withdrawMax'),
1144
1120
  },
1145
1121
  },
1146
1122
  }
1147
- networkKeys = list(networks.keys())
1148
- networkKeysLength = len(networkKeys)
1149
- if (networkKeysLength == 1) or ('NONE' in networks):
1150
- defaultNetwork = self.safe_value_2(networks, 'NONE', networkKeysLength - 1)
1151
- if defaultNetwork is not None:
1152
- currencyFee = defaultNetwork['fee']
1153
- result[code] = {
1123
+ result[code] = self.safe_currency_structure({
1154
1124
  'info': currency,
1155
1125
  'id': id,
1156
1126
  'code': code,
1157
1127
  'name': name,
1158
- 'active': currencyActive,
1159
- 'deposit': depositEnabled,
1160
- 'withdraw': withdrawEnabled,
1161
- 'fee': currencyFee,
1128
+ 'active': None,
1129
+ 'deposit': None,
1130
+ 'withdraw': None,
1131
+ 'fee': None,
1162
1132
  'precision': None,
1163
1133
  'limits': {
1164
1134
  'amount': {
1165
1135
  'min': None,
1166
1136
  'max': None,
1167
1137
  },
1168
- 'withdraw': {
1169
- 'min': currencyWithdrawMin,
1170
- 'max': currencyWithdrawMax,
1171
- },
1172
1138
  },
1139
+ 'type': 'crypto',
1173
1140
  'networks': networks,
1174
- }
1141
+ })
1175
1142
  return result
1176
1143
 
1177
1144
  async def fetch_markets(self, params={}) -> List[Market]:
@@ -3254,13 +3221,27 @@ class mexc(Exchange, ImplicitAPI):
3254
3221
 
3255
3222
  def parse_order(self, order: dict, market: Market = None) -> Order:
3256
3223
  #
3257
- # spot: createOrder
3224
+ # spot
3225
+ # createOrder
3258
3226
  #
3259
- # {
3227
+ # {
3228
+ # "symbol": "FARTCOINUSDT",
3229
+ # "orderId": "C02__342252993005723644225",
3230
+ # "orderListId": "-1",
3231
+ # "price": "1.1",
3232
+ # "origQty": "6.3",
3233
+ # "type": "IMMEDIATE_OR_CANCEL",
3234
+ # "side": "SELL",
3235
+ # "transactTime": "1745852205223"
3236
+ # }
3237
+ #
3238
+ # unknown endpoint on spot
3239
+ #
3240
+ # {
3260
3241
  # "symbol": "BTCUSDT",
3261
3242
  # "orderId": "123738410679123456",
3262
3243
  # "orderListId": -1
3263
- # }
3244
+ # }
3264
3245
  #
3265
3246
  # margin: createOrder
3266
3247
  #
@@ -3422,6 +3403,10 @@ class mexc(Exchange, ImplicitAPI):
3422
3403
  id = order
3423
3404
  else:
3424
3405
  id = self.safe_string_2(order, 'orderId', 'id')
3406
+ timeInForce = self.parse_order_time_in_force(self.safe_string(order, 'timeInForce'))
3407
+ typeRaw = self.safe_string(order, 'type')
3408
+ if timeInForce is None:
3409
+ timeInForce = self.get_tif_from_raw_order_type(typeRaw)
3425
3410
  marketId = self.safe_string(order, 'symbol')
3426
3411
  market = self.safe_market(marketId, market)
3427
3412
  timestamp = self.safe_integer_n(order, ['time', 'createTime', 'transactTime'])
@@ -3443,8 +3428,8 @@ class mexc(Exchange, ImplicitAPI):
3443
3428
  'lastTradeTimestamp': None, # TODO: self might be 'updateTime' if order-status is filled, otherwise cancellation time. needs to be checked
3444
3429
  'status': self.parse_order_status(self.safe_string_2(order, 'status', 'state')),
3445
3430
  'symbol': market['symbol'],
3446
- 'type': self.parse_order_type(self.safe_string(order, 'type')),
3447
- 'timeInForce': self.parse_order_time_in_force(self.safe_string(order, 'timeInForce')),
3431
+ 'type': self.parse_order_type(typeRaw),
3432
+ 'timeInForce': timeInForce,
3448
3433
  'side': self.parse_order_side(self.safe_string(order, 'side')),
3449
3434
  'price': self.safe_number(order, 'price'),
3450
3435
  'triggerPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
@@ -3473,6 +3458,9 @@ class mexc(Exchange, ImplicitAPI):
3473
3458
  'MARKET': 'market',
3474
3459
  'LIMIT': 'limit',
3475
3460
  'LIMIT_MAKER': 'limit',
3461
+ # on spot, during submission below types are used only accepted order
3462
+ 'IMMEDIATE_OR_CANCEL': 'limit',
3463
+ 'FILL_OR_KILL': 'limit',
3476
3464
  }
3477
3465
  return self.safe_string(statuses, status, status)
3478
3466
 
@@ -3500,6 +3488,16 @@ class mexc(Exchange, ImplicitAPI):
3500
3488
  }
3501
3489
  return self.safe_string(statuses, status, status)
3502
3490
 
3491
+ def get_tif_from_raw_order_type(self, orderType: Str = None):
3492
+ statuses: dict = {
3493
+ 'LIMIT': 'GTC',
3494
+ 'LIMIT_MAKER': 'POST_ONLY',
3495
+ 'IMMEDIATE_OR_CANCEL': 'IOC',
3496
+ 'FILL_OR_KILL': 'FOK',
3497
+ 'MARKET': 'IOC',
3498
+ }
3499
+ return self.safe_string(statuses, orderType, orderType)
3500
+
3503
3501
  async def fetch_account_helper(self, type, params):
3504
3502
  if type == 'spot':
3505
3503
  return await self.spotPrivateGetAccount(params)
@@ -4850,7 +4848,7 @@ class mexc(Exchange, ImplicitAPI):
4850
4848
  response = await self.fetch_positions(None, self.extend(request, params))
4851
4849
  return self.safe_value(response, 0)
4852
4850
 
4853
- async def fetch_positions(self, symbols: Strings = None, params={}):
4851
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
4854
4852
  """
4855
4853
  fetch all open positions
4856
4854
 
ccxt/async_support/okx.py CHANGED
@@ -5402,7 +5402,7 @@ class okx(Exchange, ImplicitAPI):
5402
5402
  return None
5403
5403
  return self.parse_position(position, market)
5404
5404
 
5405
- async def fetch_positions(self, symbols: Strings = None, params={}):
5405
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
5406
5406
  """
5407
5407
 
5408
5408
  https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.oxfun import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Any, Balances, Bool, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Any, Balances, Bool, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -2130,7 +2130,7 @@ class oxfun(Exchange, ImplicitAPI):
2130
2130
  data['type'] = 'withdrawal'
2131
2131
  return self.parse_transaction(data, currency)
2132
2132
 
2133
- async def fetch_positions(self, symbols: Strings = None, params={}):
2133
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2134
2134
  """
2135
2135
  fetch all open positions
2136
2136
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.paradex import ImplicitAPI
8
- from ccxt.base.types import Any, Balances, Currency, Int, Leverage, MarginMode, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Any, Balances, Currency, Int, Leverage, MarginMode, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -1815,7 +1815,7 @@ class paradex(Exchange, ImplicitAPI):
1815
1815
  positions = await self.fetch_positions([market['symbol']], params)
1816
1816
  return self.safe_dict(positions, 0, {})
1817
1817
 
1818
- async def fetch_positions(self, symbols: Strings = None, params={}):
1818
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
1819
1819
  """
1820
1820
  fetch all open positions
1821
1821
 
@@ -8,7 +8,7 @@ from ccxt.abstract.phemex import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import numbers
11
- from ccxt.base.types import Any, Balances, Conversion, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, Transaction, TransferEntry
11
+ from ccxt.base.types import Any, Balances, Conversion, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -1167,7 +1167,8 @@ class phemex(Exchange, ImplicitAPI):
1167
1167
  },
1168
1168
  },
1169
1169
  'valueScale': valueScale,
1170
- 'networks': {},
1170
+ 'networks': None,
1171
+ 'type': 'crypto',
1171
1172
  }
1172
1173
  return result
1173
1174
 
@@ -3571,7 +3572,7 @@ class phemex(Exchange, ImplicitAPI):
3571
3572
  'fee': fee,
3572
3573
  }
3573
3574
 
3574
- async def fetch_positions(self, symbols: Strings = None, params={}):
3575
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3575
3576
  """
3576
3577
  fetch all open positions
3577
3578
 
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.poloniex import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, DepositAddress, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, DepositAddress, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -1828,7 +1828,7 @@ class poloniex(Exchange, ImplicitAPI):
1828
1828
  isTrigger = self.safe_value_2(params, 'trigger', 'stop')
1829
1829
  params = self.omit(params, ['trigger', 'stop'])
1830
1830
  response = None
1831
- if not market['spot']:
1831
+ if marketType != 'spot':
1832
1832
  raw = await self.swapPrivateGetV3TradeOrderOpens(self.extend(request, params))
1833
1833
  #
1834
1834
  # {
@@ -3285,7 +3285,7 @@ class poloniex(Exchange, ImplicitAPI):
3285
3285
  #
3286
3286
  return response
3287
3287
 
3288
- async def fetch_positions(self, symbols: Strings = None, params={}):
3288
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3289
3289
  """
3290
3290
  fetch all open positions
3291
3291
 
@@ -563,6 +563,7 @@ class probit(Exchange, ImplicitAPI):
563
563
  'active': active,
564
564
  'deposit': deposit,
565
565
  'withdraw': withdraw,
566
+ 'type': 'crypto',
566
567
  'fee': fee,
567
568
  'precision': self.parse_number(self.parse_precision(self.safe_string(platform, 'precision'))),
568
569
  'limits': {
@@ -24,7 +24,7 @@ class tradeogre(Exchange, ImplicitAPI):
24
24
  'countries': [],
25
25
  'rateLimit': 100,
26
26
  'version': 'v2',
27
- 'pro': False,
27
+ 'pro': True,
28
28
  'has': {
29
29
  'CORS': None,
30
30
  'spot': True,
@@ -525,6 +525,7 @@ class tradeogre(Exchange, ImplicitAPI):
525
525
  'asks': rawAsks,
526
526
  }
527
527
  orderbook = self.parse_order_book(rawOrderbook, symbol)
528
+ orderbook['nonce'] = self.safe_integer(response, 's')
528
529
  return orderbook
529
530
 
530
531
  def parse_bids_asks(self, bidasks, priceKey: IndexType = 0, amountKey: IndexType = 1, countOrIdKey: IndexType = 2):