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.
- ccxt/__init__.py +3 -3
- ccxt/abstract/apex.py +31 -0
- ccxt/abstract/bitmart.py +1 -0
- ccxt/apex.py +1884 -0
- ccxt/ascendex.py +23 -6
- ccxt/async_support/__init__.py +3 -3
- ccxt/async_support/apex.py +1884 -0
- ccxt/async_support/ascendex.py +23 -6
- ccxt/async_support/base/exchange.py +5 -1
- ccxt/async_support/binance.py +9 -3
- ccxt/async_support/bingx.py +4 -4
- ccxt/async_support/bitfinex.py +61 -36
- ccxt/async_support/bitflyer.py +2 -2
- ccxt/async_support/bitget.py +186 -128
- ccxt/async_support/bitmart.py +9 -4
- ccxt/async_support/bitmex.py +14 -7
- ccxt/async_support/bitopro.py +5 -1
- ccxt/async_support/bitrue.py +2 -1
- ccxt/async_support/bitso.py +1 -1
- ccxt/async_support/bitteam.py +2 -0
- ccxt/async_support/bitvavo.py +25 -10
- ccxt/async_support/btcalpha.py +1 -1
- ccxt/async_support/btcmarkets.py +1 -1
- ccxt/async_support/btcturk.py +1 -1
- ccxt/async_support/bybit.py +27 -15
- ccxt/async_support/cex.py +1 -1
- ccxt/async_support/coinbase.py +17 -4
- ccxt/async_support/coincatch.py +66 -0
- ccxt/async_support/coinex.py +2 -1
- ccxt/async_support/coinlist.py +1 -0
- ccxt/async_support/coinone.py +1 -0
- ccxt/async_support/cryptocom.py +2 -2
- ccxt/async_support/defx.py +1 -1
- ccxt/async_support/delta.py +4 -1
- ccxt/async_support/deribit.py +3 -2
- ccxt/async_support/derive.py +2 -2
- ccxt/async_support/digifinex.py +2 -2
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/hitbtc.py +5 -2
- ccxt/async_support/hollaex.py +1 -0
- ccxt/async_support/htx.py +9 -5
- ccxt/async_support/huobijp.py +1 -0
- ccxt/async_support/hyperliquid.py +14 -6
- ccxt/async_support/kraken.py +4 -2
- ccxt/async_support/krakenfutures.py +2 -2
- ccxt/async_support/kucoinfutures.py +2 -2
- ccxt/async_support/mexc.py +50 -52
- ccxt/async_support/okx.py +2 -2
- ccxt/async_support/oxfun.py +2 -2
- ccxt/async_support/paradex.py +2 -2
- ccxt/async_support/phemex.py +4 -3
- ccxt/async_support/poloniex.py +4 -3
- ccxt/async_support/probit.py +1 -0
- ccxt/async_support/timex.py +2 -2
- ccxt/async_support/tradeogre.py +2 -1
- ccxt/async_support/upbit.py +243 -63
- ccxt/async_support/vertex.py +2 -2
- ccxt/async_support/whitebit.py +66 -12
- ccxt/async_support/woo.py +5 -3
- ccxt/async_support/woofipro.py +2 -2
- ccxt/async_support/xt.py +9 -2
- ccxt/base/exchange.py +69 -2
- ccxt/binance.py +9 -3
- ccxt/bingx.py +4 -4
- ccxt/bitfinex.py +61 -36
- ccxt/bitflyer.py +2 -2
- ccxt/bitget.py +186 -128
- ccxt/bitmart.py +9 -4
- ccxt/bitmex.py +14 -7
- ccxt/bitopro.py +5 -1
- ccxt/bitrue.py +2 -1
- ccxt/bitso.py +1 -1
- ccxt/bitteam.py +2 -0
- ccxt/bitvavo.py +25 -10
- ccxt/btcalpha.py +1 -1
- ccxt/btcmarkets.py +1 -1
- ccxt/btcturk.py +1 -1
- ccxt/bybit.py +27 -15
- ccxt/cex.py +1 -1
- ccxt/coinbase.py +17 -4
- ccxt/coincatch.py +66 -0
- ccxt/coinex.py +2 -1
- ccxt/coinlist.py +1 -0
- ccxt/coinone.py +1 -0
- ccxt/cryptocom.py +2 -2
- ccxt/defx.py +1 -1
- ccxt/delta.py +4 -1
- ccxt/deribit.py +3 -2
- ccxt/derive.py +2 -2
- ccxt/digifinex.py +2 -2
- ccxt/gate.py +1 -1
- ccxt/hitbtc.py +5 -2
- ccxt/hollaex.py +1 -0
- ccxt/htx.py +9 -5
- ccxt/huobijp.py +1 -0
- ccxt/hyperliquid.py +14 -6
- ccxt/kraken.py +4 -2
- ccxt/krakenfutures.py +2 -2
- ccxt/kucoinfutures.py +2 -2
- ccxt/mexc.py +50 -52
- ccxt/okx.py +2 -2
- ccxt/oxfun.py +2 -2
- ccxt/paradex.py +2 -2
- ccxt/phemex.py +4 -3
- ccxt/poloniex.py +4 -3
- ccxt/pro/__init__.py +5 -1
- ccxt/pro/apex.py +984 -0
- ccxt/pro/binance.py +3 -3
- ccxt/pro/coinbase.py +43 -57
- ccxt/pro/gate.py +22 -2
- ccxt/pro/hollaex.py +2 -2
- ccxt/pro/p2b.py +2 -2
- ccxt/pro/tradeogre.py +272 -0
- ccxt/pro/upbit.py +42 -0
- ccxt/probit.py +1 -0
- ccxt/test/tests_async.py +4 -1
- ccxt/test/tests_sync.py +4 -1
- ccxt/timex.py +2 -2
- ccxt/tradeogre.py +2 -1
- ccxt/upbit.py +243 -63
- ccxt/vertex.py +2 -2
- ccxt/whitebit.py +66 -12
- ccxt/woo.py +5 -3
- ccxt/woofipro.py +2 -2
- ccxt/xt.py +9 -2
- {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/METADATA +9 -11
- {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/RECORD +130 -128
- ccxt/abstract/ace.py +0 -15
- ccxt/ace.py +0 -1152
- ccxt/async_support/ace.py +0 -1152
- {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/WHEEL +0 -0
- {ccxt-4.4.77.dist-info → ccxt-4.4.80.dist-info}/top_level.txt +0 -0
ccxt/async_support/whitebit.py
CHANGED
@@ -554,18 +554,69 @@ class whitebit(Exchange, ImplicitAPI):
|
|
554
554
|
"""
|
555
555
|
response = await self.v4PublicGetAssets(params)
|
556
556
|
#
|
557
|
-
#
|
558
|
-
#
|
559
|
-
#
|
560
|
-
#
|
561
|
-
#
|
562
|
-
#
|
563
|
-
#
|
564
|
-
#
|
565
|
-
#
|
566
|
-
#
|
567
|
-
#
|
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':
|
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
|
#
|
ccxt/async_support/woofipro.py
CHANGED
@@ -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.
|
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.
|
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': [
|
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":
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
-
|
1197
|
-
|
1198
|
-
|
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':
|
1204
|
-
'low':
|
1205
|
-
'bid':
|
1206
|
-
'bidVolume':
|
1207
|
-
'ask':
|
1208
|
-
'askVolume':
|
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':
|
1215
|
-
'percentage':
|
1247
|
+
'change': change,
|
1248
|
+
'percentage': percentage,
|
1216
1249
|
'average': None,
|
1217
|
-
'baseVolume':
|
1250
|
+
'baseVolume': volume,
|
1218
1251
|
'quoteVolume': None,
|
1219
|
-
'info':
|
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
|
-
|
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
|
-
|
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
|
|