ccxt 4.4.3__py2.py3-none-any.whl → 4.4.5__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +1 -1
- ccxt/abstract/binanceus.py +36 -36
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +24 -13
- ccxt/async_support/base/ws/cache.py +1 -0
- ccxt/async_support/binance.py +43 -18
- ccxt/async_support/binanceus.py +1 -0
- ccxt/async_support/bingx.py +1 -0
- ccxt/async_support/bitfinex2.py +10 -9
- ccxt/async_support/bitget.py +55 -99
- ccxt/async_support/bitmex.py +14 -13
- ccxt/async_support/bitso.py +8 -7
- ccxt/async_support/bitstamp.py +12 -12
- ccxt/async_support/blofin.py +24 -26
- ccxt/async_support/bybit.py +101 -29
- ccxt/async_support/coinbase.py +31 -10
- ccxt/async_support/coinbaseexchange.py +14 -14
- ccxt/async_support/coinlist.py +9 -8
- ccxt/async_support/coinmetro.py +6 -6
- ccxt/async_support/cryptocom.py +10 -8
- ccxt/async_support/currencycom.py +9 -9
- ccxt/async_support/delta.py +8 -8
- ccxt/async_support/digifinex.py +11 -9
- ccxt/async_support/gate.py +9 -8
- ccxt/async_support/hashkey.py +12 -10
- ccxt/async_support/htx.py +16 -19
- ccxt/async_support/hyperliquid.py +70 -117
- ccxt/async_support/kraken.py +12 -10
- ccxt/async_support/kucoin.py +12 -11
- ccxt/async_support/luno.py +13 -12
- ccxt/async_support/lykke.py +2 -2
- ccxt/async_support/mexc.py +41 -3
- ccxt/async_support/ndax.py +9 -8
- ccxt/async_support/okcoin.py +21 -30
- ccxt/async_support/okx.py +21 -29
- ccxt/async_support/paradex.py +1 -1
- ccxt/async_support/woo.py +10 -9
- ccxt/async_support/woofipro.py +11 -9
- ccxt/async_support/xt.py +7 -6
- ccxt/async_support/zonda.py +9 -8
- ccxt/base/exchange.py +3 -1
- ccxt/binance.py +43 -18
- ccxt/binanceus.py +1 -0
- ccxt/bingx.py +1 -0
- ccxt/bitfinex2.py +10 -9
- ccxt/bitget.py +55 -99
- ccxt/bitmex.py +14 -13
- ccxt/bitso.py +8 -7
- ccxt/bitstamp.py +12 -12
- ccxt/blofin.py +24 -26
- ccxt/bybit.py +101 -29
- ccxt/coinbase.py +31 -10
- ccxt/coinbaseexchange.py +14 -14
- ccxt/coinlist.py +9 -8
- ccxt/coinmetro.py +6 -6
- ccxt/cryptocom.py +10 -8
- ccxt/currencycom.py +9 -9
- ccxt/delta.py +8 -8
- ccxt/digifinex.py +11 -9
- ccxt/gate.py +9 -8
- ccxt/hashkey.py +12 -10
- ccxt/htx.py +16 -19
- ccxt/hyperliquid.py +70 -117
- ccxt/kraken.py +12 -10
- ccxt/kucoin.py +12 -11
- ccxt/luno.py +13 -12
- ccxt/lykke.py +2 -2
- ccxt/mexc.py +40 -3
- ccxt/ndax.py +9 -8
- ccxt/okcoin.py +21 -30
- ccxt/okx.py +21 -29
- ccxt/paradex.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +6 -2
- ccxt/pro/binanceus.py +2 -1
- ccxt/pro/bybit.py +51 -0
- ccxt/pro/hyperliquid.py +14 -1
- ccxt/pro/mexc.py +78 -0
- ccxt/pro/paradex.py +1 -0
- ccxt/test/tests_async.py +1 -1
- ccxt/test/tests_sync.py +1 -1
- ccxt/woo.py +10 -9
- ccxt/woofipro.py +11 -9
- ccxt/xt.py +7 -6
- ccxt/zonda.py +9 -8
- {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/METADATA +5 -5
- {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/RECORD +90 -90
- {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/WHEEL +0 -0
- {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/top_level.txt +0 -0
ccxt/async_support/zonda.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.zonda import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -804,13 +804,13 @@ class zonda(Exchange, ImplicitAPI):
|
|
804
804
|
items = self.safe_dict(response, 'items')
|
805
805
|
return self.parse_tickers(items, symbols)
|
806
806
|
|
807
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
807
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
808
808
|
"""
|
809
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
809
810
|
:see: https://docs.zondacrypto.exchange/reference/operations-history
|
810
|
-
|
811
|
-
:param str code: unified currency code, default is None
|
811
|
+
:param str [code]: unified currency code, default is None
|
812
812
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
813
|
-
:param int [limit]: max number of ledger
|
813
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
814
814
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
815
815
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
816
816
|
"""
|
@@ -830,7 +830,7 @@ class zonda(Exchange, ImplicitAPI):
|
|
830
830
|
items = response['items']
|
831
831
|
return self.parse_ledger(items, None, since, limit)
|
832
832
|
|
833
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
833
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
834
834
|
#
|
835
835
|
# FUNDS_MIGRATION
|
836
836
|
# {
|
@@ -1101,6 +1101,7 @@ class zonda(Exchange, ImplicitAPI):
|
|
1101
1101
|
timestamp = self.safe_integer(item, 'time')
|
1102
1102
|
balance = self.safe_value(item, 'balance', {})
|
1103
1103
|
currencyId = self.safe_string(balance, 'currency')
|
1104
|
+
currency = self.safe_currency(currencyId, currency)
|
1104
1105
|
change = self.safe_value(item, 'change', {})
|
1105
1106
|
amount = self.safe_string(change, 'total')
|
1106
1107
|
direction = 'in'
|
@@ -1111,7 +1112,7 @@ class zonda(Exchange, ImplicitAPI):
|
|
1111
1112
|
# that can be used to enrich the transfers with txid, address etc(you need to use info.detailId parameter)
|
1112
1113
|
fundsBefore = self.safe_value(item, 'fundsBefore', {})
|
1113
1114
|
fundsAfter = self.safe_value(item, 'fundsAfter', {})
|
1114
|
-
return {
|
1115
|
+
return self.safe_ledger_entry({
|
1115
1116
|
'info': item,
|
1116
1117
|
'id': self.safe_string(item, 'historyId'),
|
1117
1118
|
'direction': direction,
|
@@ -1127,7 +1128,7 @@ class zonda(Exchange, ImplicitAPI):
|
|
1127
1128
|
'timestamp': timestamp,
|
1128
1129
|
'datetime': self.iso8601(timestamp),
|
1129
1130
|
'fee': None,
|
1130
|
-
}
|
1131
|
+
}, currency)
|
1131
1132
|
|
1132
1133
|
def parse_ledger_entry_type(self, type):
|
1133
1134
|
types: dict = {
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.4.
|
7
|
+
__version__ = '4.4.5'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -140,6 +140,8 @@ class Exchange(object):
|
|
140
140
|
aiohttp_trust_env = False
|
141
141
|
requests_trust_env = False
|
142
142
|
session = None # Session () by default
|
143
|
+
tcp_connector = None # aiohttp.TCPConnector
|
144
|
+
aiohttp_socks_connector = None
|
143
145
|
socks_proxy_sessions = None
|
144
146
|
verify = True # SSL verification
|
145
147
|
validateServerSsl = True
|
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 Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, 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
|
@@ -1222,6 +1222,7 @@ class binance(Exchange, ImplicitAPI):
|
|
1222
1222
|
# exchange-specific options
|
1223
1223
|
'options': {
|
1224
1224
|
'sandboxMode': False,
|
1225
|
+
'fetchMargins': True,
|
1225
1226
|
'fetchMarkets': [
|
1226
1227
|
'spot', # allows CORS in browsers
|
1227
1228
|
'linear', # allows CORS in browsers
|
@@ -2853,13 +2854,12 @@ class binance(Exchange, ImplicitAPI):
|
|
2853
2854
|
if type == 'option' and sandboxMode:
|
2854
2855
|
continue
|
2855
2856
|
fetchMarkets.append(type)
|
2856
|
-
fetchMargins = False
|
2857
|
+
fetchMargins = self.safe_bool(self.options, 'fetchMargins', False)
|
2857
2858
|
for i in range(0, len(fetchMarkets)):
|
2858
2859
|
marketType = fetchMarkets[i]
|
2859
2860
|
if marketType == 'spot':
|
2860
2861
|
promisesRaw.append(self.publicGetExchangeInfo(params))
|
2861
|
-
if self.check_required_credentials(False) and not sandboxMode:
|
2862
|
-
fetchMargins = True
|
2862
|
+
if fetchMargins and self.check_required_credentials(False) and not sandboxMode:
|
2863
2863
|
promisesRaw.append(self.sapiGetMarginAllPairs(params))
|
2864
2864
|
promisesRaw.append(self.sapiGetMarginIsolatedAllPairs(params))
|
2865
2865
|
elif marketType == 'linear':
|
@@ -10361,19 +10361,42 @@ class binance(Exchange, ImplicitAPI):
|
|
10361
10361
|
result.append(self.parse_settlement(settlements[i], market))
|
10362
10362
|
return result
|
10363
10363
|
|
10364
|
-
def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
|
10364
|
+
def fetch_ledger_entry(self, id: str, code: Str = None, params={}) -> LedgerEntry:
|
10365
|
+
"""
|
10366
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
10367
|
+
:see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
10368
|
+
:param str id: the identification number of the ledger entry
|
10369
|
+
:param str code: unified currency code
|
10370
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
10371
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
10372
|
+
"""
|
10365
10373
|
self.load_markets()
|
10366
10374
|
type = None
|
10367
10375
|
type, params = self.handle_market_type_and_params('fetchLedgerEntry', None, params)
|
10368
|
-
query: dict = {
|
10369
|
-
'recordId': id,
|
10370
|
-
'type': type,
|
10371
|
-
}
|
10372
10376
|
if type != 'option':
|
10373
10377
|
raise BadRequest(self.id + ' fetchLedgerEntry() can only be used for type option')
|
10374
|
-
|
10378
|
+
self.check_required_argument('fetchLedgerEntry', code, 'code')
|
10379
|
+
currency = self.currency(code)
|
10380
|
+
request: dict = {
|
10381
|
+
'recordId': id,
|
10382
|
+
'currency': currency['id'],
|
10383
|
+
}
|
10384
|
+
response = self.eapiPrivateGetBill(self.extend(request, params))
|
10385
|
+
#
|
10386
|
+
# [
|
10387
|
+
# {
|
10388
|
+
# "id": "1125899906845701870",
|
10389
|
+
# "asset": "USDT",
|
10390
|
+
# "amount": "-0.16518203",
|
10391
|
+
# "type": "FEE",
|
10392
|
+
# "createDate": 1676621042489
|
10393
|
+
# }
|
10394
|
+
# ]
|
10395
|
+
#
|
10396
|
+
first = self.safe_dict(response, 0, response)
|
10397
|
+
return self.parse_ledger_entry(first, currency)
|
10375
10398
|
|
10376
|
-
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
10399
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
10377
10400
|
"""
|
10378
10401
|
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
10379
10402
|
:see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
@@ -10381,9 +10404,9 @@ class binance(Exchange, ImplicitAPI):
|
|
10381
10404
|
:see: https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
|
10382
10405
|
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
|
10383
10406
|
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
|
10384
|
-
:param str code: unified currency code
|
10407
|
+
:param str [code]: unified currency code
|
10385
10408
|
:param int [since]: timestamp in ms of the earliest ledger entry
|
10386
|
-
:param int [limit]: max number of ledger
|
10409
|
+
:param int [limit]: max number of ledger entries to return
|
10387
10410
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
10388
10411
|
:param int [params.until]: timestamp in ms of the latest ledger entry
|
10389
10412
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
@@ -10461,7 +10484,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10461
10484
|
#
|
10462
10485
|
return self.parse_ledger(response, currency, since, limit)
|
10463
10486
|
|
10464
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
10487
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
10465
10488
|
#
|
10466
10489
|
# options(eapi)
|
10467
10490
|
#
|
@@ -10494,16 +10517,19 @@ class binance(Exchange, ImplicitAPI):
|
|
10494
10517
|
else:
|
10495
10518
|
direction = 'in'
|
10496
10519
|
currencyId = self.safe_string(item, 'asset')
|
10520
|
+
code = self.safe_currency_code(currencyId, currency)
|
10521
|
+
currency = self.safe_currency(currencyId, currency)
|
10497
10522
|
timestamp = self.safe_integer_2(item, 'createDate', 'time')
|
10498
10523
|
type = self.safe_string_2(item, 'type', 'incomeType')
|
10499
|
-
return {
|
10524
|
+
return self.safe_ledger_entry({
|
10525
|
+
'info': item,
|
10500
10526
|
'id': self.safe_string_2(item, 'id', 'tranId'),
|
10501
10527
|
'direction': direction,
|
10502
10528
|
'account': None,
|
10503
10529
|
'referenceAccount': None,
|
10504
10530
|
'referenceId': self.safe_string(item, 'tradeId'),
|
10505
10531
|
'type': self.parse_ledger_entry_type(type),
|
10506
|
-
'currency':
|
10532
|
+
'currency': code,
|
10507
10533
|
'amount': self.parse_number(amount),
|
10508
10534
|
'timestamp': timestamp,
|
10509
10535
|
'datetime': self.iso8601(timestamp),
|
@@ -10511,8 +10537,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10511
10537
|
'after': None,
|
10512
10538
|
'status': None,
|
10513
10539
|
'fee': None,
|
10514
|
-
|
10515
|
-
}
|
10540
|
+
}, currency)
|
10516
10541
|
|
10517
10542
|
def parse_ledger_entry_type(self, type):
|
10518
10543
|
ledgerType: dict = {
|
ccxt/binanceus.py
CHANGED
ccxt/bingx.py
CHANGED
ccxt/bitfinex2.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitfinex2 import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, 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
|
@@ -2729,7 +2729,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2729
2729
|
else:
|
2730
2730
|
return type
|
2731
2731
|
|
2732
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
2732
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
2733
2733
|
#
|
2734
2734
|
# [
|
2735
2735
|
# [
|
@@ -2750,6 +2750,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2750
2750
|
id = self.safe_string(itemList, 0)
|
2751
2751
|
currencyId = self.safe_string(itemList, 1)
|
2752
2752
|
code = self.safe_currency_code(currencyId, currency)
|
2753
|
+
currency = self.safe_currency(currencyId, currency)
|
2753
2754
|
timestamp = self.safe_integer(itemList, 3)
|
2754
2755
|
amount = self.safe_number(itemList, 5)
|
2755
2756
|
after = self.safe_number(itemList, 6)
|
@@ -2758,7 +2759,8 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2758
2759
|
parts = description.split(' @ ')
|
2759
2760
|
first = self.safe_string_lower(parts, 0)
|
2760
2761
|
type = self.parse_ledger_entry_type(first)
|
2761
|
-
return {
|
2762
|
+
return self.safe_ledger_entry({
|
2763
|
+
'info': item,
|
2762
2764
|
'id': id,
|
2763
2765
|
'direction': None,
|
2764
2766
|
'account': None,
|
@@ -2773,16 +2775,15 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2773
2775
|
'after': after,
|
2774
2776
|
'status': None,
|
2775
2777
|
'fee': None,
|
2776
|
-
|
2777
|
-
}
|
2778
|
+
}, currency)
|
2778
2779
|
|
2779
|
-
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2780
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
2780
2781
|
"""
|
2781
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
2782
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
2782
2783
|
:see: https://docs.bitfinex.com/reference/rest-auth-ledgers
|
2783
|
-
:param str code: unified currency code, default is None
|
2784
|
+
:param str [code]: unified currency code, default is None
|
2784
2785
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
2785
|
-
:param int [limit]: max number of ledger
|
2786
|
+
:param int [limit]: max number of ledger entries to return, default is None, max is 2500
|
2786
2787
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2787
2788
|
:param int [params.until]: timestamp in ms of the latest ledger entry
|
2788
2789
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
ccxt/bitget.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitget import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, 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
|
@@ -1534,6 +1534,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
1534
1534
|
retrieves data on all markets for bitget
|
1535
1535
|
:see: https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
1536
1536
|
:see: https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
1537
|
+
:see: https://www.bitget.com/api-doc/margin/common/support-currencies
|
1537
1538
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1538
1539
|
:returns dict[]: an array of objects representing market data
|
1539
1540
|
"""
|
@@ -1542,9 +1543,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
1542
1543
|
if sandboxMode:
|
1543
1544
|
types = ['swap']
|
1544
1545
|
promises = []
|
1546
|
+
fetchMargins = False
|
1545
1547
|
for i in range(0, len(types)):
|
1546
1548
|
type = types[i]
|
1547
|
-
if type == 'swap':
|
1549
|
+
if (type == 'swap') or (type == 'future'):
|
1548
1550
|
subTypes = None
|
1549
1551
|
if sandboxMode:
|
1550
1552
|
# the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
|
@@ -1552,15 +1554,33 @@ class bitget(Exchange, ImplicitAPI):
|
|
1552
1554
|
else:
|
1553
1555
|
subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
|
1554
1556
|
for j in range(0, len(subTypes)):
|
1555
|
-
promises.append(self.
|
1557
|
+
promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
|
1556
1558
|
'productType': subTypes[j],
|
1557
1559
|
})))
|
1560
|
+
elif type == 'spot':
|
1561
|
+
promises.append(self.publicSpotGetV2SpotPublicSymbols(params))
|
1562
|
+
fetchMargins = True
|
1563
|
+
promises.append(self.publicMarginGetV2MarginCurrencies(params))
|
1564
|
+
else:
|
1565
|
+
raise NotSupported(self.id + ' does not support ' + type + ' market')
|
1566
|
+
results = promises
|
1567
|
+
markets = []
|
1568
|
+
self.options['crossMarginPairsData'] = []
|
1569
|
+
self.options['isolatedMarginPairsData'] = []
|
1570
|
+
for i in range(0, len(results)):
|
1571
|
+
res = self.safe_dict(results, i)
|
1572
|
+
data = self.safe_list(res, 'data', [])
|
1573
|
+
firstData = self.safe_dict(data, 0, {})
|
1574
|
+
isBorrowable = self.safe_string(firstData, 'isBorrowable')
|
1575
|
+
if fetchMargins and isBorrowable is not None:
|
1576
|
+
keysList = list(self.index_by(data, 'symbol').keys())
|
1577
|
+
self.options['crossMarginPairsData'] = keysList
|
1578
|
+
self.options['isolatedMarginPairsData'] = keysList
|
1558
1579
|
else:
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
result = self.array_concat(result, promises[i])
|
1580
|
+
markets = self.array_concat(markets, data)
|
1581
|
+
result = []
|
1582
|
+
for i in range(0, len(markets)):
|
1583
|
+
result.append(self.parse_market(markets[i]))
|
1564
1584
|
return result
|
1565
1585
|
|
1566
1586
|
def parse_market(self, market: dict) -> Market:
|
@@ -1648,11 +1668,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
1648
1668
|
expiry = None
|
1649
1669
|
expiryDatetime = None
|
1650
1670
|
symbolType = self.safe_string(market, 'symbolType')
|
1671
|
+
marginModes = None
|
1672
|
+
isMarginTradingAllowed = False
|
1651
1673
|
if symbolType is None:
|
1652
1674
|
type = 'spot'
|
1653
1675
|
spot = True
|
1654
1676
|
pricePrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision')))
|
1655
1677
|
amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
|
1678
|
+
hasCrossMargin = self.in_array(marketId, self.options['crossMarginPairsData'])
|
1679
|
+
hasIsolatedMargin = self.in_array(marketId, self.options['isolatedMarginPairsData'])
|
1680
|
+
marginModes = {
|
1681
|
+
'cross': hasCrossMargin,
|
1682
|
+
'isolated': hasIsolatedMargin,
|
1683
|
+
}
|
1684
|
+
isMarginTradingAllowed = hasCrossMargin or hasCrossMargin
|
1656
1685
|
else:
|
1657
1686
|
if symbolType == 'perpetual':
|
1658
1687
|
type = 'swap'
|
@@ -1688,6 +1717,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
1688
1717
|
preciseAmount.reduce()
|
1689
1718
|
amountString = str(preciseAmount)
|
1690
1719
|
amountPrecision = self.parse_number(amountString)
|
1720
|
+
marginModes = {
|
1721
|
+
'cross': True,
|
1722
|
+
'isolated': True,
|
1723
|
+
}
|
1691
1724
|
status = self.safe_string_2(market, 'status', 'symbolStatus')
|
1692
1725
|
active = None
|
1693
1726
|
if status is not None:
|
@@ -1707,7 +1740,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
1707
1740
|
'settleId': settleId,
|
1708
1741
|
'type': type,
|
1709
1742
|
'spot': spot,
|
1710
|
-
'margin':
|
1743
|
+
'margin': spot and isMarginTradingAllowed,
|
1744
|
+
'marginModes': marginModes,
|
1711
1745
|
'swap': swap,
|
1712
1746
|
'future': future,
|
1713
1747
|
'option': False,
|
@@ -1748,88 +1782,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
1748
1782
|
'info': market,
|
1749
1783
|
}
|
1750
1784
|
|
1751
|
-
def fetch_markets_by_type(self, type, params={}):
|
1752
|
-
response = None
|
1753
|
-
if type == 'spot':
|
1754
|
-
response = self.publicSpotGetV2SpotPublicSymbols(params)
|
1755
|
-
elif (type == 'swap') or (type == 'future'):
|
1756
|
-
response = self.publicMixGetV2MixMarketContracts(params)
|
1757
|
-
else:
|
1758
|
-
raise NotSupported(self.id + ' does not support ' + type + ' market')
|
1759
|
-
#
|
1760
|
-
# spot
|
1761
|
-
#
|
1762
|
-
# {
|
1763
|
-
# "code": "00000",
|
1764
|
-
# "msg": "success",
|
1765
|
-
# "requestTime": 1700102364653,
|
1766
|
-
# "data": [
|
1767
|
-
# {
|
1768
|
-
# "symbol": "TRXUSDT",
|
1769
|
-
# "baseCoin": "TRX",
|
1770
|
-
# "quoteCoin": "USDT",
|
1771
|
-
# "minTradeAmount": "0",
|
1772
|
-
# "maxTradeAmount": "10000000000",
|
1773
|
-
# "takerFeeRate": "0.002",
|
1774
|
-
# "makerFeeRate": "0.002",
|
1775
|
-
# "pricePrecision": "6",
|
1776
|
-
# "quantityPrecision": "4",
|
1777
|
-
# "quotePrecision": "6",
|
1778
|
-
# "status": "online",
|
1779
|
-
# "minTradeUSDT": "5",
|
1780
|
-
# "buyLimitPriceRatio": "0.05",
|
1781
|
-
# "sellLimitPriceRatio": "0.05"
|
1782
|
-
# },
|
1783
|
-
# ]
|
1784
|
-
# }
|
1785
|
-
#
|
1786
|
-
# swap and future
|
1787
|
-
#
|
1788
|
-
# {
|
1789
|
-
# "code": "00000",
|
1790
|
-
# "msg": "success",
|
1791
|
-
# "requestTime": 1700102364709,
|
1792
|
-
# "data": [
|
1793
|
-
# {
|
1794
|
-
# "symbol": "BTCUSDT",
|
1795
|
-
# "baseCoin": "BTC",
|
1796
|
-
# "quoteCoin": "USDT",
|
1797
|
-
# "buyLimitPriceRatio": "0.01",
|
1798
|
-
# "sellLimitPriceRatio": "0.01",
|
1799
|
-
# "feeRateUpRatio": "0.005",
|
1800
|
-
# "makerFeeRate": "0.0002",
|
1801
|
-
# "takerFeeRate": "0.0006",
|
1802
|
-
# "openCostUpRatio": "0.01",
|
1803
|
-
# "supportMarginCoins": ["USDT"],
|
1804
|
-
# "minTradeNum": "0.001",
|
1805
|
-
# "priceEndStep": "1",
|
1806
|
-
# "volumePlace": "3",
|
1807
|
-
# "pricePlace": "1",
|
1808
|
-
# "sizeMultiplier": "0.001",
|
1809
|
-
# "symbolType": "perpetual",
|
1810
|
-
# "minTradeUSDT": "5",
|
1811
|
-
# "maxSymbolOrderNum": "200",
|
1812
|
-
# "maxProductOrderNum": "400",
|
1813
|
-
# "maxPositionNum": "150",
|
1814
|
-
# "symbolStatus": "normal",
|
1815
|
-
# "offTime": "-1",
|
1816
|
-
# "limitOpenTime": "-1",
|
1817
|
-
# "deliveryTime": "",
|
1818
|
-
# "deliveryStartTime": "",
|
1819
|
-
# "deliveryPeriod": "",
|
1820
|
-
# "launchTime": "",
|
1821
|
-
# "fundInterval": "8",
|
1822
|
-
# "minLever": "1",
|
1823
|
-
# "maxLever": "125",
|
1824
|
-
# "posLimit": "0.05",
|
1825
|
-
# "maintainTime": ""
|
1826
|
-
# },
|
1827
|
-
# ]
|
1828
|
-
# }
|
1829
|
-
#
|
1830
|
-
data = self.safe_value(response, 'data', [])
|
1831
|
-
return self.parse_markets(data)
|
1832
|
-
|
1833
1785
|
def fetch_currencies(self, params={}) -> Currencies:
|
1834
1786
|
"""
|
1835
1787
|
fetches all available currencies on an exchange
|
@@ -5492,14 +5444,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
5492
5444
|
orders = self.safe_list(response, 'data', [])
|
5493
5445
|
return self.parse_orders(orders, market, since, limit)
|
5494
5446
|
|
5495
|
-
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
5447
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
5496
5448
|
"""
|
5449
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
5497
5450
|
:see: https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
5498
5451
|
:see: https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
5499
|
-
|
5500
|
-
:param str code: unified currency code, default is None
|
5452
|
+
:param str [code]: unified currency code, default is None
|
5501
5453
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
5502
|
-
:param int [limit]: max number of ledger
|
5454
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
5503
5455
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5504
5456
|
:param int [params.until]: end time in ms
|
5505
5457
|
:param str [params.symbol]: *contract only* unified market symbol
|
@@ -5597,7 +5549,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5597
5549
|
return self.parse_ledger(bills, currency, since, limit)
|
5598
5550
|
return self.parse_ledger(data, currency, since, limit)
|
5599
5551
|
|
5600
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
5552
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
5601
5553
|
#
|
5602
5554
|
# spot
|
5603
5555
|
#
|
@@ -5627,6 +5579,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5627
5579
|
#
|
5628
5580
|
currencyId = self.safe_string(item, 'coin')
|
5629
5581
|
code = self.safe_currency_code(currencyId, currency)
|
5582
|
+
currency = self.safe_currency(currencyId, currency)
|
5630
5583
|
timestamp = self.safe_integer(item, 'cTime')
|
5631
5584
|
after = self.safe_number(item, 'balance')
|
5632
5585
|
fee = self.safe_number_2(item, 'fees', 'fee')
|
@@ -5635,7 +5588,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5635
5588
|
direction = 'in'
|
5636
5589
|
if amountRaw.find('-') >= 0:
|
5637
5590
|
direction = 'out'
|
5638
|
-
return {
|
5591
|
+
return self.safe_ledger_entry({
|
5639
5592
|
'info': item,
|
5640
5593
|
'id': self.safe_string(item, 'billId'),
|
5641
5594
|
'timestamp': timestamp,
|
@@ -5650,8 +5603,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
5650
5603
|
'before': None,
|
5651
5604
|
'after': after,
|
5652
5605
|
'status': None,
|
5653
|
-
'fee':
|
5654
|
-
|
5606
|
+
'fee': {
|
5607
|
+
'currency': code,
|
5608
|
+
'cost': fee,
|
5609
|
+
},
|
5610
|
+
}, currency)
|
5655
5611
|
|
5656
5612
|
def parse_ledger_type(self, type):
|
5657
5613
|
types: dict = {
|
ccxt/bitmex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitmex import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -1050,7 +1050,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1050
1050
|
}
|
1051
1051
|
return self.safe_string(types, type, type)
|
1052
1052
|
|
1053
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
1053
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
1054
1054
|
#
|
1055
1055
|
# {
|
1056
1056
|
# "transactID": "69573da3-7744-5467-3207-89fd6efe7a47",
|
@@ -1099,6 +1099,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1099
1099
|
type = self.parse_ledger_entry_type(self.safe_string(item, 'transactType'))
|
1100
1100
|
currencyId = self.safe_string(item, 'currency')
|
1101
1101
|
code = self.safe_currency_code(currencyId, currency)
|
1102
|
+
currency = self.safe_currency(currencyId, currency)
|
1102
1103
|
amountString = self.safe_string(item, 'amount')
|
1103
1104
|
amount = self.convert_to_real_amount(code, amountString)
|
1104
1105
|
timestamp = self.parse8601(self.safe_string(item, 'transactTime'))
|
@@ -1111,13 +1112,13 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1111
1112
|
if feeCost is not None:
|
1112
1113
|
feeCost = self.convert_to_real_amount(code, feeCost)
|
1113
1114
|
fee = {
|
1114
|
-
'cost': self.
|
1115
|
+
'cost': self.parse_to_numeric(feeCost),
|
1115
1116
|
'currency': code,
|
1116
1117
|
}
|
1117
1118
|
after = self.safe_string(item, 'walletBalance')
|
1118
1119
|
if after is not None:
|
1119
1120
|
after = self.convert_to_real_amount(code, after)
|
1120
|
-
before = self.
|
1121
|
+
before = self.parse_to_numeric(Precise.string_sub(self.number_to_string(after), self.number_to_string(amount)))
|
1121
1122
|
direction = None
|
1122
1123
|
if Precise.string_lt(amountString, '0'):
|
1123
1124
|
direction = 'out'
|
@@ -1125,9 +1126,9 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1125
1126
|
else:
|
1126
1127
|
direction = 'in'
|
1127
1128
|
status = self.parse_transaction_status(self.safe_string(item, 'transactStatus'))
|
1128
|
-
return {
|
1129
|
-
'id': id,
|
1129
|
+
return self.safe_ledger_entry({
|
1130
1130
|
'info': item,
|
1131
|
+
'id': id,
|
1131
1132
|
'timestamp': timestamp,
|
1132
1133
|
'datetime': self.iso8601(timestamp),
|
1133
1134
|
'direction': direction,
|
@@ -1136,20 +1137,20 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1136
1137
|
'referenceAccount': referenceAccount,
|
1137
1138
|
'type': type,
|
1138
1139
|
'currency': code,
|
1139
|
-
'amount': amount,
|
1140
|
+
'amount': self.parse_to_numeric(amount),
|
1140
1141
|
'before': before,
|
1141
|
-
'after': self.
|
1142
|
+
'after': self.parse_to_numeric(after),
|
1142
1143
|
'status': status,
|
1143
1144
|
'fee': fee,
|
1144
|
-
}
|
1145
|
+
}, currency)
|
1145
1146
|
|
1146
|
-
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
1147
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
1147
1148
|
"""
|
1148
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
1149
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
1149
1150
|
:see: https://www.bitmex.com/api/explorer/#not /User/User_getWalletHistory
|
1150
|
-
:param str code: unified currency code, default is None
|
1151
|
+
:param str [code]: unified currency code, default is None
|
1151
1152
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
1152
|
-
:param int [limit]: max number of ledger
|
1153
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
1153
1154
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1154
1155
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
1155
1156
|
"""
|