ccxt 4.4.3__py2.py3-none-any.whl → 4.4.4__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +1 -1
- 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 +40 -15
- ccxt/async_support/bingx.py +1 -0
- ccxt/async_support/bitfinex2.py +10 -9
- ccxt/async_support/bitget.py +13 -9
- 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 +24 -23
- 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/mexc.py +34 -2
- ccxt/async_support/ndax.py +9 -8
- ccxt/async_support/okcoin.py +21 -30
- ccxt/async_support/okx.py +21 -29
- 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 +40 -15
- ccxt/bingx.py +1 -0
- ccxt/bitfinex2.py +10 -9
- ccxt/bitget.py +13 -9
- ccxt/bitmex.py +14 -13
- ccxt/bitso.py +8 -7
- ccxt/bitstamp.py +12 -12
- ccxt/blofin.py +24 -26
- ccxt/bybit.py +24 -23
- 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/mexc.py +33 -2
- ccxt/ndax.py +9 -8
- ccxt/okcoin.py +21 -30
- ccxt/okx.py +21 -29
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bybit.py +51 -0
- ccxt/pro/mexc.py +78 -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.4.dist-info}/METADATA +5 -5
- {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/RECORD +79 -79
- {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/WHEEL +0 -0
- {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/async_support/__init__.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.4.
|
5
|
+
__version__ = '4.4.4'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -65,6 +65,7 @@ class Exchange(BaseExchange):
|
|
65
65
|
ping = None
|
66
66
|
newUpdates = True
|
67
67
|
clients = {}
|
68
|
+
timeout_on_exit = 250 # needed for: https://github.com/ccxt/ccxt/pull/23470
|
68
69
|
|
69
70
|
def __init__(self, config={}):
|
70
71
|
if 'asyncio_loop' in config:
|
@@ -114,8 +115,8 @@ class Exchange(BaseExchange):
|
|
114
115
|
|
115
116
|
if self.own_session and self.session is None:
|
116
117
|
# Pass this SSL context to aiohttp and create a TCPConnector
|
117
|
-
|
118
|
-
self.session = aiohttp.ClientSession(loop=self.asyncio_loop, connector=
|
118
|
+
self.tcp_connector = aiohttp.TCPConnector(ssl=self.ssl_context, loop=self.asyncio_loop, enable_cleanup_closed=True)
|
119
|
+
self.session = aiohttp.ClientSession(loop=self.asyncio_loop, connector=self.tcp_connector, trust_env=self.aiohttp_trust_env)
|
119
120
|
|
120
121
|
async def close(self):
|
121
122
|
await self.ws_close()
|
@@ -123,7 +124,17 @@ class Exchange(BaseExchange):
|
|
123
124
|
if self.own_session:
|
124
125
|
await self.session.close()
|
125
126
|
self.session = None
|
127
|
+
await self.close_connector()
|
126
128
|
await self.close_proxy_sessions()
|
129
|
+
await self.sleep(self.timeout_on_exit)
|
130
|
+
|
131
|
+
async def close_connector(self):
|
132
|
+
if self.tcp_connector is not None:
|
133
|
+
await self.tcp_connector.close()
|
134
|
+
self.tcp_connector = None
|
135
|
+
if self.aiohttp_socks_connector is not None:
|
136
|
+
await self.aiohttp_socks_connector.close()
|
137
|
+
self.aiohttp_socks_connector = None
|
127
138
|
|
128
139
|
async def close_proxy_sessions(self):
|
129
140
|
if self.socks_proxy_sessions is not None:
|
@@ -153,20 +164,20 @@ class Exchange(BaseExchange):
|
|
153
164
|
elif socksProxy:
|
154
165
|
if ProxyConnector is None:
|
155
166
|
raise NotSupported(self.id + ' - to use SOCKS proxy with ccxt, you need "aiohttp_socks" module that can be installed by "pip install aiohttp_socks"')
|
156
|
-
# Create our SSL context object with our CA cert file
|
157
|
-
self.open() # ensure `asyncio_loop` is set
|
158
|
-
connector = ProxyConnector.from_url(
|
159
|
-
socksProxy,
|
160
|
-
# extra args copied from self.open()
|
161
|
-
ssl=self.ssl_context,
|
162
|
-
loop=self.asyncio_loop,
|
163
|
-
enable_cleanup_closed=True
|
164
|
-
)
|
165
167
|
# override session
|
166
168
|
if (self.socks_proxy_sessions is None):
|
167
169
|
self.socks_proxy_sessions = {}
|
168
170
|
if (socksProxy not in self.socks_proxy_sessions):
|
169
|
-
|
171
|
+
# Create our SSL context object with our CA cert file
|
172
|
+
self.open() # ensure `asyncio_loop` is set
|
173
|
+
self.aiohttp_socks_connector = ProxyConnector.from_url(
|
174
|
+
socksProxy,
|
175
|
+
# extra args copied from self.open()
|
176
|
+
ssl=self.ssl_context,
|
177
|
+
loop=self.asyncio_loop,
|
178
|
+
enable_cleanup_closed=True
|
179
|
+
)
|
180
|
+
self.socks_proxy_sessions[socksProxy] = aiohttp.ClientSession(loop=self.asyncio_loop, connector=self.aiohttp_socks_connector, trust_env=self.aiohttp_trust_env)
|
170
181
|
proxy_session = self.socks_proxy_sessions[socksProxy]
|
171
182
|
# add aiohttp_proxy for python as exclusion
|
172
183
|
elif self.aiohttp_proxy:
|
@@ -23,6 +23,7 @@ class BaseCache(list):
|
|
23
23
|
__contains__ = Delegate('__contains__', '_deque')
|
24
24
|
__reversed__ = Delegate('__reversed__', '_deque')
|
25
25
|
clear = Delegate('clear', '_deque')
|
26
|
+
pop = Delegate('pop', '_deque')
|
26
27
|
|
27
28
|
def __init__(self, max_size=None):
|
28
29
|
super(BaseCache, self).__init__()
|
ccxt/async_support/binance.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
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
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import AuthenticationError
|
@@ -10362,19 +10362,42 @@ class binance(Exchange, ImplicitAPI):
|
|
10362
10362
|
result.append(self.parse_settlement(settlements[i], market))
|
10363
10363
|
return result
|
10364
10364
|
|
10365
|
-
async def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
|
10365
|
+
async def fetch_ledger_entry(self, id: str, code: Str = None, params={}) -> LedgerEntry:
|
10366
|
+
"""
|
10367
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
10368
|
+
:see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
10369
|
+
:param str id: the identification number of the ledger entry
|
10370
|
+
:param str code: unified currency code
|
10371
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
10372
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
10373
|
+
"""
|
10366
10374
|
await self.load_markets()
|
10367
10375
|
type = None
|
10368
10376
|
type, params = self.handle_market_type_and_params('fetchLedgerEntry', None, params)
|
10369
|
-
query: dict = {
|
10370
|
-
'recordId': id,
|
10371
|
-
'type': type,
|
10372
|
-
}
|
10373
10377
|
if type != 'option':
|
10374
10378
|
raise BadRequest(self.id + ' fetchLedgerEntry() can only be used for type option')
|
10375
|
-
|
10379
|
+
self.check_required_argument('fetchLedgerEntry', code, 'code')
|
10380
|
+
currency = self.currency(code)
|
10381
|
+
request: dict = {
|
10382
|
+
'recordId': id,
|
10383
|
+
'currency': currency['id'],
|
10384
|
+
}
|
10385
|
+
response = await self.eapiPrivateGetBill(self.extend(request, params))
|
10386
|
+
#
|
10387
|
+
# [
|
10388
|
+
# {
|
10389
|
+
# "id": "1125899906845701870",
|
10390
|
+
# "asset": "USDT",
|
10391
|
+
# "amount": "-0.16518203",
|
10392
|
+
# "type": "FEE",
|
10393
|
+
# "createDate": 1676621042489
|
10394
|
+
# }
|
10395
|
+
# ]
|
10396
|
+
#
|
10397
|
+
first = self.safe_dict(response, 0, response)
|
10398
|
+
return self.parse_ledger_entry(first, currency)
|
10376
10399
|
|
10377
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
10400
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
10378
10401
|
"""
|
10379
10402
|
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
10380
10403
|
:see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
@@ -10382,9 +10405,9 @@ class binance(Exchange, ImplicitAPI):
|
|
10382
10405
|
:see: https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
|
10383
10406
|
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
|
10384
10407
|
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
|
10385
|
-
:param str code: unified currency code
|
10408
|
+
:param str [code]: unified currency code
|
10386
10409
|
:param int [since]: timestamp in ms of the earliest ledger entry
|
10387
|
-
:param int [limit]: max number of ledger
|
10410
|
+
:param int [limit]: max number of ledger entries to return
|
10388
10411
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
10389
10412
|
:param int [params.until]: timestamp in ms of the latest ledger entry
|
10390
10413
|
: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)
|
@@ -10462,7 +10485,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10462
10485
|
#
|
10463
10486
|
return self.parse_ledger(response, currency, since, limit)
|
10464
10487
|
|
10465
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
10488
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
10466
10489
|
#
|
10467
10490
|
# options(eapi)
|
10468
10491
|
#
|
@@ -10495,16 +10518,19 @@ class binance(Exchange, ImplicitAPI):
|
|
10495
10518
|
else:
|
10496
10519
|
direction = 'in'
|
10497
10520
|
currencyId = self.safe_string(item, 'asset')
|
10521
|
+
code = self.safe_currency_code(currencyId, currency)
|
10522
|
+
currency = self.safe_currency(currencyId, currency)
|
10498
10523
|
timestamp = self.safe_integer_2(item, 'createDate', 'time')
|
10499
10524
|
type = self.safe_string_2(item, 'type', 'incomeType')
|
10500
|
-
return {
|
10525
|
+
return self.safe_ledger_entry({
|
10526
|
+
'info': item,
|
10501
10527
|
'id': self.safe_string_2(item, 'id', 'tranId'),
|
10502
10528
|
'direction': direction,
|
10503
10529
|
'account': None,
|
10504
10530
|
'referenceAccount': None,
|
10505
10531
|
'referenceId': self.safe_string(item, 'tradeId'),
|
10506
10532
|
'type': self.parse_ledger_entry_type(type),
|
10507
|
-
'currency':
|
10533
|
+
'currency': code,
|
10508
10534
|
'amount': self.parse_number(amount),
|
10509
10535
|
'timestamp': timestamp,
|
10510
10536
|
'datetime': self.iso8601(timestamp),
|
@@ -10512,8 +10538,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10512
10538
|
'after': None,
|
10513
10539
|
'status': None,
|
10514
10540
|
'fee': None,
|
10515
|
-
|
10516
|
-
}
|
10541
|
+
}, currency)
|
10517
10542
|
|
10518
10543
|
def parse_ledger_entry_type(self, type):
|
10519
10544
|
ledgerType: dict = {
|
ccxt/async_support/bingx.py
CHANGED
ccxt/async_support/bitfinex2.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitfinex2 import ImplicitAPI
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
|
-
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
|
10
|
+
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
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -2730,7 +2730,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2730
2730
|
else:
|
2731
2731
|
return type
|
2732
2732
|
|
2733
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
2733
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
2734
2734
|
#
|
2735
2735
|
# [
|
2736
2736
|
# [
|
@@ -2751,6 +2751,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2751
2751
|
id = self.safe_string(itemList, 0)
|
2752
2752
|
currencyId = self.safe_string(itemList, 1)
|
2753
2753
|
code = self.safe_currency_code(currencyId, currency)
|
2754
|
+
currency = self.safe_currency(currencyId, currency)
|
2754
2755
|
timestamp = self.safe_integer(itemList, 3)
|
2755
2756
|
amount = self.safe_number(itemList, 5)
|
2756
2757
|
after = self.safe_number(itemList, 6)
|
@@ -2759,7 +2760,8 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2759
2760
|
parts = description.split(' @ ')
|
2760
2761
|
first = self.safe_string_lower(parts, 0)
|
2761
2762
|
type = self.parse_ledger_entry_type(first)
|
2762
|
-
return {
|
2763
|
+
return self.safe_ledger_entry({
|
2764
|
+
'info': item,
|
2763
2765
|
'id': id,
|
2764
2766
|
'direction': None,
|
2765
2767
|
'account': None,
|
@@ -2774,16 +2776,15 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2774
2776
|
'after': after,
|
2775
2777
|
'status': None,
|
2776
2778
|
'fee': None,
|
2777
|
-
|
2778
|
-
}
|
2779
|
+
}, currency)
|
2779
2780
|
|
2780
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2781
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
2781
2782
|
"""
|
2782
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
2783
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
2783
2784
|
:see: https://docs.bitfinex.com/reference/rest-auth-ledgers
|
2784
|
-
:param str code: unified currency code, default is None
|
2785
|
+
:param str [code]: unified currency code, default is None
|
2785
2786
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
2786
|
-
:param int [limit]: max number of ledger
|
2787
|
+
:param int [limit]: max number of ledger entries to return, default is None, max is 2500
|
2787
2788
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2788
2789
|
:param int [params.until]: timestamp in ms of the latest ledger entry
|
2789
2790
|
: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/async_support/bitget.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
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
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import AuthenticationError
|
@@ -5493,14 +5493,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
5493
5493
|
orders = self.safe_list(response, 'data', [])
|
5494
5494
|
return self.parse_orders(orders, market, since, limit)
|
5495
5495
|
|
5496
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
5496
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
5497
5497
|
"""
|
5498
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
5498
5499
|
:see: https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
5499
5500
|
:see: https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
5500
|
-
|
5501
|
-
:param str code: unified currency code, default is None
|
5501
|
+
:param str [code]: unified currency code, default is None
|
5502
5502
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
5503
|
-
:param int [limit]: max number of ledger
|
5503
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
5504
5504
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5505
5505
|
:param int [params.until]: end time in ms
|
5506
5506
|
:param str [params.symbol]: *contract only* unified market symbol
|
@@ -5598,7 +5598,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5598
5598
|
return self.parse_ledger(bills, currency, since, limit)
|
5599
5599
|
return self.parse_ledger(data, currency, since, limit)
|
5600
5600
|
|
5601
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
5601
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
5602
5602
|
#
|
5603
5603
|
# spot
|
5604
5604
|
#
|
@@ -5628,6 +5628,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5628
5628
|
#
|
5629
5629
|
currencyId = self.safe_string(item, 'coin')
|
5630
5630
|
code = self.safe_currency_code(currencyId, currency)
|
5631
|
+
currency = self.safe_currency(currencyId, currency)
|
5631
5632
|
timestamp = self.safe_integer(item, 'cTime')
|
5632
5633
|
after = self.safe_number(item, 'balance')
|
5633
5634
|
fee = self.safe_number_2(item, 'fees', 'fee')
|
@@ -5636,7 +5637,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5636
5637
|
direction = 'in'
|
5637
5638
|
if amountRaw.find('-') >= 0:
|
5638
5639
|
direction = 'out'
|
5639
|
-
return {
|
5640
|
+
return self.safe_ledger_entry({
|
5640
5641
|
'info': item,
|
5641
5642
|
'id': self.safe_string(item, 'billId'),
|
5642
5643
|
'timestamp': timestamp,
|
@@ -5651,8 +5652,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
5651
5652
|
'before': None,
|
5652
5653
|
'after': after,
|
5653
5654
|
'status': None,
|
5654
|
-
'fee':
|
5655
|
-
|
5655
|
+
'fee': {
|
5656
|
+
'currency': code,
|
5657
|
+
'cost': fee,
|
5658
|
+
},
|
5659
|
+
}, currency)
|
5656
5660
|
|
5657
5661
|
def parse_ledger_type(self, type):
|
5658
5662
|
types: dict = {
|
ccxt/async_support/bitmex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.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
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
1147
|
+
async 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
|
"""
|
ccxt/async_support/bitso.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitso import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -195,12 +195,12 @@ class bitso(Exchange, ImplicitAPI):
|
|
195
195
|
},
|
196
196
|
})
|
197
197
|
|
198
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
198
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
199
199
|
"""
|
200
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
201
|
-
:param str code: unified currency code, default is None
|
200
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
201
|
+
:param str [code]: unified currency code, default is None
|
202
202
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
203
|
-
:param int [limit]: max number of ledger
|
203
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
204
204
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
205
205
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
206
206
|
"""
|
@@ -244,7 +244,7 @@ class bitso(Exchange, ImplicitAPI):
|
|
244
244
|
}
|
245
245
|
return self.safe_string(types, type, type)
|
246
246
|
|
247
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
247
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
248
248
|
#
|
249
249
|
# {
|
250
250
|
# "eid": "2510b3e2bc1c87f584500a18084f35ed",
|
@@ -308,6 +308,7 @@ class bitso(Exchange, ImplicitAPI):
|
|
308
308
|
amount = self.safe_string(firstBalance, 'amount')
|
309
309
|
currencyId = self.safe_string(firstBalance, 'currency')
|
310
310
|
code = self.safe_currency_code(currencyId, currency)
|
311
|
+
currency = self.safe_currency(currencyId, currency)
|
311
312
|
details = self.safe_value(item, 'details', {})
|
312
313
|
referenceId = self.safe_string_2(details, 'fid', 'wid')
|
313
314
|
if referenceId is None:
|
@@ -327,6 +328,7 @@ class bitso(Exchange, ImplicitAPI):
|
|
327
328
|
}
|
328
329
|
timestamp = self.parse8601(self.safe_string(item, 'created_at'))
|
329
330
|
return self.safe_ledger_entry({
|
331
|
+
'info': item,
|
330
332
|
'id': self.safe_string(item, 'eid'),
|
331
333
|
'direction': direction,
|
332
334
|
'account': None,
|
@@ -341,7 +343,6 @@ class bitso(Exchange, ImplicitAPI):
|
|
341
343
|
'after': None,
|
342
344
|
'status': 'ok',
|
343
345
|
'fee': fee,
|
344
|
-
'info': item,
|
345
346
|
}, currency)
|
346
347
|
|
347
348
|
async def fetch_markets(self, params={}) -> List[Market]:
|
ccxt/async_support/bitstamp.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitstamp import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -1831,7 +1831,7 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1831
1831
|
}
|
1832
1832
|
return self.safe_string(types, type, type)
|
1833
1833
|
|
1834
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
1834
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
1835
1835
|
#
|
1836
1836
|
# [
|
1837
1837
|
# {
|
@@ -1872,9 +1872,9 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1872
1872
|
if market is None:
|
1873
1873
|
market = self.get_market_from_trade(item)
|
1874
1874
|
direction = 'in' if (parsedTrade['side'] == 'buy') else 'out'
|
1875
|
-
return {
|
1876
|
-
'id': parsedTrade['id'],
|
1875
|
+
return self.safe_ledger_entry({
|
1877
1876
|
'info': item,
|
1877
|
+
'id': parsedTrade['id'],
|
1878
1878
|
'timestamp': parsedTrade['timestamp'],
|
1879
1879
|
'datetime': parsedTrade['datetime'],
|
1880
1880
|
'direction': direction,
|
@@ -1888,7 +1888,7 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1888
1888
|
'after': None,
|
1889
1889
|
'status': 'ok',
|
1890
1890
|
'fee': parsedTrade['fee'],
|
1891
|
-
}
|
1891
|
+
}, currency)
|
1892
1892
|
else:
|
1893
1893
|
parsedTransaction = self.parse_transaction(item, currency)
|
1894
1894
|
direction = None
|
@@ -1900,9 +1900,9 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1900
1900
|
currency = self.currency(currencyCode)
|
1901
1901
|
amount = self.safe_string(item, currency['id'])
|
1902
1902
|
direction = 'in' if Precise.string_gt(amount, '0') else 'out'
|
1903
|
-
return {
|
1904
|
-
'id': parsedTransaction['id'],
|
1903
|
+
return self.safe_ledger_entry({
|
1905
1904
|
'info': item,
|
1905
|
+
'id': parsedTransaction['id'],
|
1906
1906
|
'timestamp': parsedTransaction['timestamp'],
|
1907
1907
|
'datetime': parsedTransaction['datetime'],
|
1908
1908
|
'direction': direction,
|
@@ -1916,15 +1916,15 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1916
1916
|
'after': None,
|
1917
1917
|
'status': parsedTransaction['status'],
|
1918
1918
|
'fee': parsedTransaction['fee'],
|
1919
|
-
}
|
1919
|
+
}, currency)
|
1920
1920
|
|
1921
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
1921
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
1922
1922
|
"""
|
1923
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
1923
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
1924
1924
|
:see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
|
1925
|
-
:param str code: unified currency code, default is None
|
1925
|
+
:param str [code]: unified currency code, default is None
|
1926
1926
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
1927
|
-
:param int [limit]: max number of ledger
|
1927
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
1928
1928
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1929
1929
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
1930
1930
|
"""
|
ccxt/async_support/blofin.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.blofin import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -1413,17 +1413,17 @@ class blofin(Exchange, ImplicitAPI):
|
|
1413
1413
|
data = self.safe_list(response, 'data', [])
|
1414
1414
|
return self.parse_transactions(data, currency, since, limit, params)
|
1415
1415
|
|
1416
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
1416
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
1417
1417
|
"""
|
1418
|
-
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
1418
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
1419
1419
|
:see: https://blofin.com/docs#get-funds-transfer-history
|
1420
|
-
:param str code: unified currency code, default is None
|
1420
|
+
:param str [code]: unified currency code, default is None
|
1421
1421
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
1422
|
-
:param int [limit]: max number of ledger
|
1422
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
1423
1423
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1424
1424
|
:param str [params.marginMode]: 'cross' or 'isolated'
|
1425
1425
|
:param int [params.until]: the latest time in ms to fetch entries for
|
1426
|
-
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [
|
1426
|
+
: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)
|
1427
1427
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
1428
1428
|
"""
|
1429
1429
|
await self.load_markets()
|
@@ -1554,30 +1554,28 @@ class blofin(Exchange, ImplicitAPI):
|
|
1554
1554
|
}
|
1555
1555
|
return self.safe_string(types, type, type)
|
1556
1556
|
|
1557
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
toAccount = self.safe_string(item, 'toAccount')
|
1562
|
-
type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
|
1563
|
-
code = self.safe_currency_code(self.safe_string(item, 'currency'), currency)
|
1564
|
-
amountString = self.safe_string(item, 'amount')
|
1565
|
-
amount = self.parse_number(amountString)
|
1557
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
1558
|
+
currencyId = self.safe_string(item, 'currency')
|
1559
|
+
code = self.safe_currency_code(currencyId, currency)
|
1560
|
+
currency = self.safe_currency(currencyId, currency)
|
1566
1561
|
timestamp = self.safe_integer(item, 'ts')
|
1567
|
-
|
1568
|
-
return {
|
1569
|
-
'id': id,
|
1562
|
+
return self.safe_ledger_entry({
|
1570
1563
|
'info': item,
|
1564
|
+
'id': self.safe_string(item, 'transferId'),
|
1565
|
+
'direction': None,
|
1566
|
+
'account': None,
|
1567
|
+
'referenceId': self.safe_string(item, 'clientId'),
|
1568
|
+
'referenceAccount': None,
|
1569
|
+
'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
|
1570
|
+
'currency': code,
|
1571
|
+
'amount': self.safe_number(item, 'amount'),
|
1571
1572
|
'timestamp': timestamp,
|
1572
1573
|
'datetime': self.iso8601(timestamp),
|
1573
|
-
'
|
1574
|
-
'
|
1575
|
-
'
|
1576
|
-
'
|
1577
|
-
|
1578
|
-
'clientId': referenceId, # balance before
|
1579
|
-
'status': status,
|
1580
|
-
}
|
1574
|
+
'before': None,
|
1575
|
+
'after': None,
|
1576
|
+
'status': 'ok',
|
1577
|
+
'fee': None,
|
1578
|
+
}, currency)
|
1581
1579
|
|
1582
1580
|
def parse_ids(self, ids):
|
1583
1581
|
"""
|