ccxt 4.4.77__py2.py3-none-any.whl → 4.4.80__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 (133) hide show
  1. ccxt/__init__.py +3 -3
  2. ccxt/abstract/apex.py +31 -0
  3. ccxt/abstract/bitmart.py +1 -0
  4. ccxt/apex.py +1884 -0
  5. ccxt/ascendex.py +23 -6
  6. ccxt/async_support/__init__.py +3 -3
  7. ccxt/async_support/apex.py +1884 -0
  8. ccxt/async_support/ascendex.py +23 -6
  9. ccxt/async_support/base/exchange.py +5 -1
  10. ccxt/async_support/binance.py +9 -3
  11. ccxt/async_support/bingx.py +4 -4
  12. ccxt/async_support/bitfinex.py +61 -36
  13. ccxt/async_support/bitflyer.py +2 -2
  14. ccxt/async_support/bitget.py +186 -128
  15. ccxt/async_support/bitmart.py +9 -4
  16. ccxt/async_support/bitmex.py +14 -7
  17. ccxt/async_support/bitopro.py +5 -1
  18. ccxt/async_support/bitrue.py +2 -1
  19. ccxt/async_support/bitso.py +1 -1
  20. ccxt/async_support/bitteam.py +2 -0
  21. ccxt/async_support/bitvavo.py +25 -10
  22. ccxt/async_support/btcalpha.py +1 -1
  23. ccxt/async_support/btcmarkets.py +1 -1
  24. ccxt/async_support/btcturk.py +1 -1
  25. ccxt/async_support/bybit.py +27 -15
  26. ccxt/async_support/cex.py +1 -1
  27. ccxt/async_support/coinbase.py +17 -4
  28. ccxt/async_support/coincatch.py +66 -0
  29. ccxt/async_support/coinex.py +2 -1
  30. ccxt/async_support/coinlist.py +1 -0
  31. ccxt/async_support/coinone.py +1 -0
  32. ccxt/async_support/cryptocom.py +2 -2
  33. ccxt/async_support/defx.py +1 -1
  34. ccxt/async_support/delta.py +4 -1
  35. ccxt/async_support/deribit.py +3 -2
  36. ccxt/async_support/derive.py +2 -2
  37. ccxt/async_support/digifinex.py +2 -2
  38. ccxt/async_support/gate.py +1 -1
  39. ccxt/async_support/hitbtc.py +5 -2
  40. ccxt/async_support/hollaex.py +1 -0
  41. ccxt/async_support/htx.py +9 -5
  42. ccxt/async_support/huobijp.py +1 -0
  43. ccxt/async_support/hyperliquid.py +14 -6
  44. ccxt/async_support/kraken.py +4 -2
  45. ccxt/async_support/krakenfutures.py +2 -2
  46. ccxt/async_support/kucoinfutures.py +2 -2
  47. ccxt/async_support/mexc.py +50 -52
  48. ccxt/async_support/okx.py +2 -2
  49. ccxt/async_support/oxfun.py +2 -2
  50. ccxt/async_support/paradex.py +2 -2
  51. ccxt/async_support/phemex.py +4 -3
  52. ccxt/async_support/poloniex.py +4 -3
  53. ccxt/async_support/probit.py +1 -0
  54. ccxt/async_support/timex.py +2 -2
  55. ccxt/async_support/tradeogre.py +2 -1
  56. ccxt/async_support/upbit.py +243 -63
  57. ccxt/async_support/vertex.py +2 -2
  58. ccxt/async_support/whitebit.py +66 -12
  59. ccxt/async_support/woo.py +5 -3
  60. ccxt/async_support/woofipro.py +2 -2
  61. ccxt/async_support/xt.py +9 -2
  62. ccxt/base/exchange.py +69 -2
  63. ccxt/binance.py +9 -3
  64. ccxt/bingx.py +4 -4
  65. ccxt/bitfinex.py +61 -36
  66. ccxt/bitflyer.py +2 -2
  67. ccxt/bitget.py +186 -128
  68. ccxt/bitmart.py +9 -4
  69. ccxt/bitmex.py +14 -7
  70. ccxt/bitopro.py +5 -1
  71. ccxt/bitrue.py +2 -1
  72. ccxt/bitso.py +1 -1
  73. ccxt/bitteam.py +2 -0
  74. ccxt/bitvavo.py +25 -10
  75. ccxt/btcalpha.py +1 -1
  76. ccxt/btcmarkets.py +1 -1
  77. ccxt/btcturk.py +1 -1
  78. ccxt/bybit.py +27 -15
  79. ccxt/cex.py +1 -1
  80. ccxt/coinbase.py +17 -4
  81. ccxt/coincatch.py +66 -0
  82. ccxt/coinex.py +2 -1
  83. ccxt/coinlist.py +1 -0
  84. ccxt/coinone.py +1 -0
  85. ccxt/cryptocom.py +2 -2
  86. ccxt/defx.py +1 -1
  87. ccxt/delta.py +4 -1
  88. ccxt/deribit.py +3 -2
  89. ccxt/derive.py +2 -2
  90. ccxt/digifinex.py +2 -2
  91. ccxt/gate.py +1 -1
  92. ccxt/hitbtc.py +5 -2
  93. ccxt/hollaex.py +1 -0
  94. ccxt/htx.py +9 -5
  95. ccxt/huobijp.py +1 -0
  96. ccxt/hyperliquid.py +14 -6
  97. ccxt/kraken.py +4 -2
  98. ccxt/krakenfutures.py +2 -2
  99. ccxt/kucoinfutures.py +2 -2
  100. ccxt/mexc.py +50 -52
  101. ccxt/okx.py +2 -2
  102. ccxt/oxfun.py +2 -2
  103. ccxt/paradex.py +2 -2
  104. ccxt/phemex.py +4 -3
  105. ccxt/poloniex.py +4 -3
  106. ccxt/pro/__init__.py +5 -1
  107. ccxt/pro/apex.py +984 -0
  108. ccxt/pro/binance.py +3 -3
  109. ccxt/pro/coinbase.py +43 -57
  110. ccxt/pro/gate.py +22 -2
  111. ccxt/pro/hollaex.py +2 -2
  112. ccxt/pro/p2b.py +2 -2
  113. ccxt/pro/tradeogre.py +272 -0
  114. ccxt/pro/upbit.py +42 -0
  115. ccxt/probit.py +1 -0
  116. ccxt/test/tests_async.py +4 -1
  117. ccxt/test/tests_sync.py +4 -1
  118. ccxt/timex.py +2 -2
  119. ccxt/tradeogre.py +2 -1
  120. ccxt/upbit.py +243 -63
  121. ccxt/vertex.py +2 -2
  122. ccxt/whitebit.py +66 -12
  123. ccxt/woo.py +5 -3
  124. ccxt/woofipro.py +2 -2
  125. ccxt/xt.py +9 -2
  126. {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/METADATA +9 -11
  127. {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/RECORD +130 -128
  128. ccxt/abstract/ace.py +0 -15
  129. ccxt/ace.py +0 -1152
  130. ccxt/async_support/ace.py +0 -1152
  131. {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/LICENSE.txt +0 -0
  132. {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/WHEEL +0 -0
  133. {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/top_level.txt +0 -0
@@ -554,18 +554,69 @@ class whitebit(Exchange, ImplicitAPI):
554
554
  """
555
555
  response = await self.v4PublicGetAssets(params)
556
556
  #
557
- # "BTC": {
558
- # "name": "Bitcoin",
559
- # "unified_cryptoasset_id": 1,
560
- # "can_withdraw": True,
561
- # "can_deposit": True,
562
- # "min_withdraw": "0.001",
563
- # "max_withdraw": "2",
564
- # "maker_fee": "0.1",
565
- # "taker_fee": "0.1",
566
- # "min_deposit": "0.0001",
567
- # "max_deposit": "0",
568
- # },
557
+ # {
558
+ # BTC: {
559
+ # name: "Bitcoin",
560
+ # unified_cryptoasset_id: "1",
561
+ # can_withdraw: True,
562
+ # can_deposit: True,
563
+ # min_withdraw: "0.0003",
564
+ # max_withdraw: "0",
565
+ # maker_fee: "0.1",
566
+ # taker_fee: "0.1",
567
+ # min_deposit: "0.0001",
568
+ # max_deposit: "0",
569
+ # networks: {
570
+ # deposits: ["BTC",],
571
+ # withdraws: ["BTC",],
572
+ # default: "BTC",
573
+ # },
574
+ # confirmations: {
575
+ # BTC: "2",
576
+ # },
577
+ # limits: {
578
+ # deposit: {
579
+ # BTC: {min: "0.0001",},
580
+ # },
581
+ # withdraw: {
582
+ # BTC: {min: "0.0003",},
583
+ # },
584
+ # },
585
+ # currency_precision: "8",
586
+ # is_memo: False,
587
+ # },
588
+ # USD: {
589
+ # name: "United States Dollar",
590
+ # unified_cryptoasset_id: "6955",
591
+ # can_withdraw: True,
592
+ # can_deposit: True,
593
+ # min_withdraw: "10",
594
+ # max_withdraw: "10000",
595
+ # maker_fee: "0.1",
596
+ # taker_fee: "0.1",
597
+ # min_deposit: "10",
598
+ # max_deposit: "10000",
599
+ # networks: {
600
+ # deposits: ["USD",],
601
+ # withdraws: ["USD",],
602
+ # default: "USD",
603
+ # },
604
+ # providers: {
605
+ # deposits: ["ADVCASH",],
606
+ # withdraws: ["ADVCASH",],
607
+ # },
608
+ # limits: {
609
+ # deposit: {
610
+ # USD: { max: "10000", min: "10",},
611
+ # },
612
+ # withdraw: {
613
+ # USD: {max: "10000", min: "10",},
614
+ # },
615
+ # },
616
+ # currency_precision: "2",
617
+ # is_memo: False,
618
+ # }
619
+ # }
569
620
  #
570
621
  ids = list(response.keys())
571
622
  result: dict = {}
@@ -578,6 +629,7 @@ class whitebit(Exchange, ImplicitAPI):
578
629
  canWithdraw = self.safe_bool(currency, 'can_withdraw', True)
579
630
  active = canDeposit and canWithdraw
580
631
  code = self.safe_currency_code(id)
632
+ hasProvider = ('providers' in currency)
581
633
  result[code] = {
582
634
  'id': id,
583
635
  'code': code,
@@ -587,6 +639,8 @@ class whitebit(Exchange, ImplicitAPI):
587
639
  'deposit': canDeposit,
588
640
  'withdraw': canWithdraw,
589
641
  'fee': None,
642
+ 'networks': None, # todo
643
+ 'type': 'fiat' if hasProvider else 'crypto',
590
644
  'precision': None,
591
645
  'limits': {
592
646
  'amount': {
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, Any, Balances, Bool, Conversion, Currencies, Currency, DepositAddress, Int, LedgerEntry, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Any, Balances, Bool, Conversion, Currencies, Currency, DepositAddress, Int, LedgerEntry, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -574,6 +574,7 @@ class woo(Exchange, ImplicitAPI):
574
574
  contractSize = self.parse_number('1')
575
575
  linear = True
576
576
  inverse = False
577
+ active = self.safe_string(market, 'is_trading') == '1'
577
578
  return {
578
579
  'id': marketId,
579
580
  'symbol': symbol,
@@ -589,7 +590,7 @@ class woo(Exchange, ImplicitAPI):
589
590
  'swap': swap,
590
591
  'future': False,
591
592
  'option': False,
592
- 'active': self.safe_string(market, 'is_trading') == '1',
593
+ 'active': active,
593
594
  'contract': contract,
594
595
  'linear': linear,
595
596
  'inverse': inverse,
@@ -926,6 +927,7 @@ class woo(Exchange, ImplicitAPI):
926
927
  'networks': resultingNetworks,
927
928
  'deposit': None,
928
929
  'withdraw': None,
930
+ 'type': 'crypto',
929
931
  'limits': {
930
932
  'deposit': {
931
933
  'min': None,
@@ -3163,7 +3165,7 @@ class woo(Exchange, ImplicitAPI):
3163
3165
  #
3164
3166
  return self.parse_position(response, market)
3165
3167
 
3166
- async def fetch_positions(self, symbols: Strings = None, params={}):
3168
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3167
3169
  await self.load_markets()
3168
3170
  response = await self.v3PrivateGetPositions(params)
3169
3171
  #
@@ -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 Any, Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction
8
+ from ccxt.base.types import Any, Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -2599,7 +2599,7 @@ class woofipro(Exchange, ImplicitAPI):
2599
2599
  data = self.safe_dict(response, 'data')
2600
2600
  return self.parse_position(data, market)
2601
2601
 
2602
- async def fetch_positions(self, symbols: Strings = None, params={}):
2602
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2603
2603
  """
2604
2604
  fetch all open positions
2605
2605
 
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 Any, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, FundingRate, Transaction, TransferEntry
10
+ from ccxt.base.types import Any, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderSide, OrderType, Position, Str, Tickers, FundingRate, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -962,6 +962,12 @@ class xt(Exchange, ImplicitAPI):
962
962
  },
963
963
  },
964
964
  }
965
+ typeRaw = self.safe_string(entry, 'type')
966
+ type: Str = None
967
+ if typeRaw == 'FT':
968
+ type = 'crypto'
969
+ else:
970
+ type = 'other'
965
971
  result[code] = {
966
972
  'info': entry,
967
973
  'id': currencyId,
@@ -973,6 +979,7 @@ class xt(Exchange, ImplicitAPI):
973
979
  'deposit': deposit,
974
980
  'withdraw': withdraw,
975
981
  'networks': networks,
982
+ 'type': type,
976
983
  'limits': {
977
984
  'amount': {
978
985
  'min': None,
@@ -4487,7 +4494,7 @@ class xt(Exchange, ImplicitAPI):
4487
4494
  return self.parse_position(entry, marketInner)
4488
4495
  return None
4489
4496
 
4490
- async def fetch_positions(self, symbols: List[str] = None, params={}):
4497
+ async def fetch_positions(self, symbols: List[str] = None, params={}) -> List[Position]:
4491
4498
  """
4492
4499
  fetch all open positions
4493
4500
 
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.77'
7
+ __version__ = '4.4.80'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -67,6 +67,10 @@ from ccxt.static_dependencies.starknet.hash.address import compute_address
67
67
  from ccxt.static_dependencies.starknet.hash.selector import get_selector_from_name
68
68
  from ccxt.static_dependencies.starknet.hash.utils import message_signature, private_to_stark_key
69
69
  from ccxt.static_dependencies.starknet.utils.typed_data import TypedData as TypedDataDataclass
70
+ try:
71
+ import apexpro.zklink_sdk as zklink_sdk
72
+ except ImportError:
73
+ zklink_sdk = None
70
74
 
71
75
  # -----------------------------------------------------------------------------
72
76
 
@@ -1755,6 +1759,69 @@ class Exchange(object):
1755
1759
  def binary_length(self, binary):
1756
1760
  return len(binary)
1757
1761
 
1762
+ def get_zk_contract_signature_obj(self, seeds: str, params={}):
1763
+ if zklink_sdk is None:
1764
+ raise Exception('zklink_sdk is not installed, please do pip3 install apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linux')
1765
+
1766
+ slotId = self.safe_string(params, 'slotId')
1767
+ nonceInt = int(self.remove0x_prefix(self.hash(self.encode(slotId), 'sha256', 'hex')), 16)
1768
+
1769
+ maxUint64 = 18446744073709551615
1770
+ maxUint32 = 4294967295
1771
+
1772
+ slotId = (nonceInt % maxUint64) / maxUint32
1773
+ nonce = nonceInt % maxUint32
1774
+ accountId = int(self.safe_string(params, 'accountId'), 10) % maxUint32
1775
+
1776
+ priceStr = (Decimal(self.safe_string(params, 'price')) * Decimal(10) ** Decimal('18')).quantize(Decimal(0), rounding='ROUND_DOWN')
1777
+ sizeStr = (Decimal(self.safe_string(params, 'size')) * Decimal(10) ** Decimal('18')).quantize(Decimal(0), rounding='ROUND_DOWN')
1778
+
1779
+ takerFeeRateStr = (Decimal(self.safe_string(params, 'takerFeeRate')) * Decimal(10000)).quantize(Decimal(0), rounding='ROUND_UP')
1780
+ makerFeeRateStr = (Decimal(self.safe_string(params, 'makerFeeRate')) * Decimal(10000)).quantize(Decimal(0), rounding='ROUND_UP')
1781
+
1782
+ builder = zklink_sdk.ContractBuilder(
1783
+ int(accountId), int(0), int(slotId), int(nonce), int(self.safe_number(params, 'pairId')),
1784
+ sizeStr.__str__(), priceStr.__str__(), self.safe_string(params, 'direction') == "BUY",
1785
+ int(takerFeeRateStr), int(makerFeeRateStr), False)
1786
+
1787
+
1788
+ tx = zklink_sdk.Contract(builder)
1789
+ seedsByte = bytes.fromhex(seeds.removeprefix('0x'))
1790
+ signerSeed = zklink_sdk.ZkLinkSigner().new_from_seed(seedsByte)
1791
+ auth_data = signerSeed.sign_musig(tx.get_bytes())
1792
+ signature = auth_data.signature
1793
+ return signature
1794
+
1795
+ def get_zk_transfer_signature_obj(self, seeds: str, params={}):
1796
+ if zklink_sdk is None:
1797
+ raise Exception('zklink_sdk is not installed, please do pip3 install apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linux')
1798
+
1799
+ nonce = self.safe_string(params, 'nonce', '0')
1800
+ if self.safe_bool(params, 'isContract'):
1801
+ formattedUint32 = '4294967295'
1802
+ formattedNonce = int(self.remove0x_prefix(self.hash(self.encode(nonce), 'sha256', 'hex')), 16)
1803
+ nonce = Precise.string_mod(str(formattedNonce), formattedUint32)
1804
+
1805
+ tx_builder = zklink_sdk.TransferBuilder(
1806
+ int(self.safe_number(params, 'zkAccountId', 0)),
1807
+ self.safe_string(params, 'receiverAddress'),
1808
+ int(self.safe_number(params, 'subAccountId', 0)),
1809
+ int(self.safe_number(params, 'receiverSubAccountId', 0)),
1810
+ int(self.safe_number(params, 'tokenId', 0)),
1811
+ self.safe_string(params, 'amount', '0'),
1812
+ self.safe_string(params, 'fee', '0'),
1813
+ self.parse_to_int(nonce),
1814
+ int(self.safe_number(params, 'timestampSeconds', 0))
1815
+ )
1816
+
1817
+ tx = zklink_sdk.Transfer(tx_builder)
1818
+ seedsByte = bytes.fromhex(seeds.removeprefix('0x'))
1819
+ signerSeed = zklink_sdk.ZkLinkSigner().new_from_seed(seedsByte)
1820
+ auth_data = signerSeed.sign_musig(tx.get_bytes())
1821
+ signature = auth_data.signature
1822
+ return signature
1823
+
1824
+
1758
1825
  # ########################################################################
1759
1826
  # ########################################################################
1760
1827
  # ########################################################################
@@ -2953,7 +3020,7 @@ class Exchange(object):
2953
3020
  # find lowest precision(which is more desired)
2954
3021
  precision = self.safe_string(network, 'precision')
2955
3022
  precisionMain = self.safe_string(currency, 'precision')
2956
- if precisionMain is None or Precise.string_lt(precision, precisionMain):
3023
+ if precisionMain is None or Precise.string_gt(precision, precisionMain):
2957
3024
  currency['precision'] = self.parse_number(precision)
2958
3025
  # limits
2959
3026
  limits = self.safe_dict(network, 'limits')
ccxt/binance.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.binance import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Any, Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, LongShortRatio, MarginMode, MarginModes, MarginModification, Market, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, MarketInterface, TransferEntry
10
+ from ccxt.base.types import Any, Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, LongShortRatio, MarginMode, MarginModes, MarginModification, Market, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, MarketInterface, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -43,7 +43,7 @@ class binance(Exchange, ImplicitAPI):
43
43
  return self.deep_extend(super(binance, self).describe(), {
44
44
  'id': 'binance',
45
45
  'name': 'Binance',
46
- 'countries': ['JP', 'MT'], # Japan, Malta
46
+ 'countries': [], # Japan
47
47
  'rateLimit': 50,
48
48
  'certified': True,
49
49
  'pro': True,
@@ -1293,6 +1293,7 @@ class binance(Exchange, ImplicitAPI):
1293
1293
  'inverse', # allows CORS in browsers
1294
1294
  # 'option', # does not allow CORS, enable outside of the browser only
1295
1295
  ],
1296
+ 'loadAllOptions': False,
1296
1297
  'fetchCurrencies': True, # self is a private call and it requires API keys
1297
1298
  # 'fetchTradesMethod': 'publicGetAggTrades', # publicGetTrades, publicGetHistoricalTrades, eapiPublicGetTrades
1298
1299
  # 'repayCrossMarginMethod': 'papiPostRepayLoan', # papiPostMarginRepayDebt
@@ -3020,6 +3021,11 @@ class binance(Exchange, ImplicitAPI):
3020
3021
  """
3021
3022
  promisesRaw = []
3022
3023
  rawFetchMarkets = self.safe_list(self.options, 'fetchMarkets', ['spot', 'linear', 'inverse'])
3024
+ # handle loadAllOptions option
3025
+ loadAllOptions = self.safe_bool(self.options, 'loadAllOptions', False)
3026
+ if loadAllOptions:
3027
+ if not self.in_array('option', rawFetchMarkets):
3028
+ rawFetchMarkets.append('option')
3023
3029
  sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
3024
3030
  fetchMarkets = []
3025
3031
  for i in range(0, len(rawFetchMarkets)):
@@ -10110,7 +10116,7 @@ class binance(Exchange, ImplicitAPI):
10110
10116
  'percentage': None,
10111
10117
  })
10112
10118
 
10113
- def fetch_positions(self, symbols: Strings = None, params={}):
10119
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
10114
10120
  """
10115
10121
  fetch all open positions
10116
10122
 
ccxt/bingx.py CHANGED
@@ -722,7 +722,7 @@ class bingx(Exchange, ImplicitAPI):
722
722
  #
723
723
  # {
724
724
  # "code": 0,
725
- # "timestamp": 1702623271477,
725
+ # "timestamp": 1702623271476,
726
726
  # "data": [
727
727
  # {
728
728
  # "coin": "BTC",
@@ -804,7 +804,7 @@ class bingx(Exchange, ImplicitAPI):
804
804
  'limits': limits,
805
805
  }
806
806
  active = depositEnabled or withdrawEnabled
807
- result[code] = {
807
+ result[code] = self.safe_currency_structure({
808
808
  'info': entry,
809
809
  'code': code,
810
810
  'id': currencyId,
@@ -816,7 +816,7 @@ class bingx(Exchange, ImplicitAPI):
816
816
  'networks': networks,
817
817
  'fee': fee,
818
818
  'limits': defaultLimits,
819
- }
819
+ })
820
820
  return result
821
821
 
822
822
  def fetch_spot_markets(self, params) -> List[Market]:
@@ -2371,7 +2371,7 @@ class bingx(Exchange, ImplicitAPI):
2371
2371
  positions = self.parse_positions(records)
2372
2372
  return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
2373
2373
 
2374
- def fetch_positions(self, symbols: Strings = None, params={}):
2374
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2375
2375
  """
2376
2376
  fetch all open positions
2377
2377
 
ccxt/bitfinex.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -1150,9 +1150,8 @@ class bitfinex(Exchange, ImplicitAPI):
1150
1150
  #
1151
1151
  # on trading pairs(ex. tBTCUSD)
1152
1152
  #
1153
- # {
1154
- # 'result': [
1155
- # SYMBOL,
1153
+ # [
1154
+ # SYMBOL, # self index is not present in singular-ticker
1156
1155
  # BID,
1157
1156
  # BID_SIZE,
1158
1157
  # ASK,
@@ -1163,15 +1162,13 @@ class bitfinex(Exchange, ImplicitAPI):
1163
1162
  # VOLUME,
1164
1163
  # HIGH,
1165
1164
  # LOW
1166
- # ]
1167
- # }
1165
+ # ]
1168
1166
  #
1169
1167
  #
1170
1168
  # on funding currencies(ex. fUSD)
1171
1169
  #
1172
- # {
1173
- # 'result': [
1174
- # SYMBOL,
1170
+ # [
1171
+ # SYMBOL, # self index is not present in singular-ticker
1175
1172
  # FRR,
1176
1173
  # BID,
1177
1174
  # BID_PERIOD,
@@ -1188,35 +1185,71 @@ class bitfinex(Exchange, ImplicitAPI):
1188
1185
  # _PLACEHOLDER,
1189
1186
  # _PLACEHOLDER,
1190
1187
  # FRR_AMOUNT_AVAILABLE
1191
- # ]
1192
- # }
1188
+ # ]
1193
1189
  #
1194
- result = self.safe_list(ticker, 'result')
1190
+ length = len(ticker)
1191
+ isFetchTicker = (length == 10) or (length == 16)
1192
+ symbol: Str = None
1193
+ minusIndex = 0
1194
+ isFundingCurrency = False
1195
+ if isFetchTicker:
1196
+ minusIndex = 1
1197
+ isFundingCurrency = (length == 16)
1198
+ else:
1199
+ marketId = self.safe_string(ticker, 0)
1200
+ market = self.safe_market(marketId, market)
1201
+ isFundingCurrency = (length == 17)
1195
1202
  symbol = self.safe_symbol(None, market)
1196
- length = len(result)
1197
- last = self.safe_string(result, length - 4)
1198
- percentage = self.safe_string(result, length - 5)
1203
+ last: Str = None
1204
+ bid: Str = None
1205
+ ask: Str = None
1206
+ change: Str = None
1207
+ percentage: Str = None
1208
+ volume: Str = None
1209
+ high: Str = None
1210
+ low: Str = None
1211
+ if isFundingCurrency:
1212
+ # per api docs, they are different array type
1213
+ last = self.safe_string(ticker, 10 - minusIndex)
1214
+ bid = self.safe_string(ticker, 2 - minusIndex)
1215
+ ask = self.safe_string(ticker, 5 - minusIndex)
1216
+ change = self.safe_string(ticker, 8 - minusIndex)
1217
+ percentage = self.safe_string(ticker, 9 - minusIndex)
1218
+ volume = self.safe_string(ticker, 11 - minusIndex)
1219
+ high = self.safe_string(ticker, 12 - minusIndex)
1220
+ low = self.safe_string(ticker, 13 - minusIndex)
1221
+ else:
1222
+ # on trading pairs(ex. tBTCUSD or tHMSTR:USD)
1223
+ last = self.safe_string(ticker, 7 - minusIndex)
1224
+ bid = self.safe_string(ticker, 1 - minusIndex)
1225
+ ask = self.safe_string(ticker, 3 - minusIndex)
1226
+ change = self.safe_string(ticker, 5 - minusIndex)
1227
+ percentage = self.safe_string(ticker, 6 - minusIndex)
1228
+ percentage = Precise.string_mul(percentage, '100')
1229
+ volume = self.safe_string(ticker, 8 - minusIndex)
1230
+ high = self.safe_string(ticker, 9 - minusIndex)
1231
+ low = self.safe_string(ticker, 10 - minusIndex)
1199
1232
  return self.safe_ticker({
1200
1233
  'symbol': symbol,
1201
1234
  'timestamp': None,
1202
1235
  'datetime': None,
1203
- 'high': self.safe_string(result, length - 2),
1204
- 'low': self.safe_string(result, length - 1),
1205
- 'bid': self.safe_string(result, length - 10),
1206
- 'bidVolume': self.safe_string(result, length - 9),
1207
- 'ask': self.safe_string(result, length - 8),
1208
- 'askVolume': self.safe_string(result, length - 7),
1236
+ 'high': high,
1237
+ 'low': low,
1238
+ 'bid': bid,
1239
+ 'bidVolume': None,
1240
+ 'ask': ask,
1241
+ 'askVolume': None,
1209
1242
  'vwap': None,
1210
1243
  'open': None,
1211
1244
  'close': last,
1212
1245
  'last': last,
1213
1246
  'previousClose': None,
1214
- 'change': self.safe_string(result, length - 6),
1215
- 'percentage': Precise.string_mul(percentage, '100'),
1247
+ 'change': change,
1248
+ 'percentage': percentage,
1216
1249
  'average': None,
1217
- 'baseVolume': self.safe_string(result, length - 3),
1250
+ 'baseVolume': volume,
1218
1251
  'quoteVolume': None,
1219
- 'info': result,
1252
+ 'info': ticker,
1220
1253
  }, market)
1221
1254
 
1222
1255
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -1277,14 +1310,7 @@ class bitfinex(Exchange, ImplicitAPI):
1277
1310
  # ...
1278
1311
  # ]
1279
1312
  #
1280
- result: dict = {}
1281
- for i in range(0, len(tickers)):
1282
- ticker = tickers[i]
1283
- marketId = self.safe_string(ticker, 0)
1284
- market = self.safe_market(marketId)
1285
- symbol = market['symbol']
1286
- result[symbol] = self.parse_ticker({'result': ticker}, market)
1287
- return self.filter_by_array_tickers(result, 'symbol', symbols)
1313
+ return self.parse_tickers(tickers, symbols)
1288
1314
 
1289
1315
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1290
1316
  """
@@ -1302,8 +1328,7 @@ class bitfinex(Exchange, ImplicitAPI):
1302
1328
  'symbol': market['id'],
1303
1329
  }
1304
1330
  ticker = self.publicGetTickerSymbol(self.extend(request, params))
1305
- result: dict = {'result': ticker}
1306
- return self.parse_ticker(result, market)
1331
+ return self.parse_ticker(ticker, market)
1307
1332
 
1308
1333
  def parse_trade(self, trade: dict, market: Market = None) -> Trade:
1309
1334
  #
@@ -2675,7 +2700,7 @@ class bitfinex(Exchange, ImplicitAPI):
2675
2700
  self.throw_broadly_matched_exception(self.exceptions['broad'], text, text)
2676
2701
  return self.parse_transaction(response, currency)
2677
2702
 
2678
- def fetch_positions(self, symbols: Strings = None, params={}):
2703
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2679
2704
  """
2680
2705
  fetch all open positions
2681
2706
 
ccxt/bitflyer.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitflyer import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, FundingRate, Trade, TradingFeeInterface, Transaction, MarketInterface
9
+ from ccxt.base.types import Any, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, FundingRate, Trade, TradingFeeInterface, Transaction, MarketInterface
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
@@ -842,7 +842,7 @@ class bitflyer(Exchange, ImplicitAPI):
842
842
  #
843
843
  return self.parse_trades(response, market, since, limit)
844
844
 
845
- def fetch_positions(self, symbols: Strings = None, params={}):
845
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
846
846
  """
847
847
  fetch all open positions
848
848