ccxt 4.4.13__py2.py3-none-any.whl → 4.4.15__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/binance.py +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/abstract/cryptocom.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +34 -1
- ccxt/async_support/binance.py +69 -11
- ccxt/async_support/bitget.py +101 -3
- ccxt/async_support/bitrue.py +1 -7
- ccxt/async_support/bitvavo.py +1 -3
- ccxt/async_support/coinex.py +13 -1
- ccxt/async_support/cryptocom.py +1 -0
- ccxt/async_support/digifinex.py +13 -1
- ccxt/async_support/htx.py +1 -1
- ccxt/async_support/huobijp.py +1 -3
- ccxt/async_support/kucoin.py +36 -1
- ccxt/async_support/kucoinfutures.py +55 -4
- ccxt/async_support/mexc.py +52 -8
- ccxt/async_support/okx.py +12 -0
- ccxt/async_support/onetrading.py +2 -2
- ccxt/async_support/poloniexfutures.py +35 -11
- ccxt/async_support/vertex.py +8 -0
- ccxt/async_support/woo.py +12 -0
- ccxt/async_support/woofipro.py +12 -0
- ccxt/async_support/xt.py +12 -0
- ccxt/base/exchange.py +38 -2
- ccxt/binance.py +69 -11
- ccxt/bitget.py +101 -3
- ccxt/bitrue.py +1 -7
- ccxt/bitvavo.py +1 -3
- ccxt/coinex.py +13 -1
- ccxt/cryptocom.py +1 -0
- ccxt/digifinex.py +13 -1
- ccxt/htx.py +1 -1
- ccxt/huobijp.py +1 -3
- ccxt/kucoin.py +36 -1
- ccxt/kucoinfutures.py +55 -4
- ccxt/mexc.py +52 -8
- ccxt/okx.py +12 -0
- ccxt/onetrading.py +2 -2
- ccxt/poloniexfutures.py +35 -11
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +1 -1
- ccxt/pro/okx.py +38 -0
- ccxt/pro/upbit.py +42 -1
- ccxt/pro/vertex.py +11 -0
- ccxt/test/tests_async.py +53 -53
- ccxt/test/tests_helpers.py +14 -0
- ccxt/test/tests_sync.py +53 -53
- ccxt/vertex.py +8 -0
- ccxt/woo.py +12 -0
- ccxt/woofipro.py +12 -0
- ccxt/xt.py +12 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.15.dist-info}/METADATA +4 -4
- {ccxt-4.4.13.dist-info → ccxt-4.4.15.dist-info}/RECORD +60 -60
- {ccxt-4.4.13.dist-info → ccxt-4.4.15.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.15.dist-info}/WHEEL +0 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.15.dist-info}/top_level.txt +0 -0
ccxt/onetrading.py
CHANGED
@@ -128,8 +128,8 @@ class onetrading(Exchange, ImplicitAPI):
|
|
128
128
|
'urls': {
|
129
129
|
'logo': 'https://github.com/ccxt/ccxt/assets/43336371/bdbc26fd-02f2-4ca7-9f1e-17333690bb1c',
|
130
130
|
'api': {
|
131
|
-
'public': 'https://api.onetrading.com/
|
132
|
-
'private': 'https://api.onetrading.com/
|
131
|
+
'public': 'https://api.onetrading.com/fast',
|
132
|
+
'private': 'https://api.onetrading.com/fast',
|
133
133
|
},
|
134
134
|
'www': 'https://onetrading.com/',
|
135
135
|
'doc': [
|
ccxt/poloniexfutures.py
CHANGED
@@ -48,6 +48,8 @@ class poloniexfutures(Exchange, ImplicitAPI):
|
|
48
48
|
'fetchDepositAddress': False,
|
49
49
|
'fetchDepositAddresses': False,
|
50
50
|
'fetchDepositAddressesByNetwork': False,
|
51
|
+
'fetchFundingInterval': True,
|
52
|
+
'fetchFundingIntervals': False,
|
51
53
|
'fetchFundingRate': True,
|
52
54
|
'fetchFundingRateHistory': False,
|
53
55
|
'fetchL3OrderBook': True,
|
@@ -1550,28 +1552,50 @@ class poloniexfutures(Exchange, ImplicitAPI):
|
|
1550
1552
|
# "predictedValue": 0.00375
|
1551
1553
|
# }
|
1552
1554
|
#
|
1553
|
-
data = self.
|
1555
|
+
data = self.safe_dict(response, 'data', {})
|
1556
|
+
return self.parse_funding_rate(data, market)
|
1557
|
+
|
1558
|
+
def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
1559
|
+
"""
|
1560
|
+
fetch the current funding rate interval
|
1561
|
+
:see: https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index
|
1562
|
+
:param str symbol: unified market symbol
|
1563
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1564
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
1565
|
+
"""
|
1566
|
+
return self.fetch_funding_rate(symbol, params)
|
1567
|
+
|
1568
|
+
def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
|
1569
|
+
#
|
1570
|
+
# {
|
1571
|
+
# "symbol": ".ETHUSDTMFPI8H",
|
1572
|
+
# "granularity": 28800000,
|
1573
|
+
# "timePoint": 1637380800000,
|
1574
|
+
# "value": 0.0001,
|
1575
|
+
# "predictedValue": 0.0001,
|
1576
|
+
# }
|
1577
|
+
#
|
1554
1578
|
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
1555
|
-
|
1579
|
+
marketId = self.safe_string(data, 'symbol')
|
1556
1580
|
return {
|
1557
1581
|
'info': data,
|
1558
|
-
'symbol': market
|
1582
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
1559
1583
|
'markPrice': None,
|
1560
1584
|
'indexPrice': None,
|
1561
1585
|
'interestRate': None,
|
1562
1586
|
'estimatedSettlePrice': None,
|
1563
1587
|
'timestamp': None,
|
1564
1588
|
'datetime': None,
|
1565
|
-
'fundingRate': self.safe_number(data, '
|
1566
|
-
'fundingTimestamp':
|
1567
|
-
'fundingDatetime':
|
1568
|
-
'nextFundingRate':
|
1589
|
+
'fundingRate': self.safe_number(data, 'value'),
|
1590
|
+
'fundingTimestamp': fundingTimestamp,
|
1591
|
+
'fundingDatetime': self.iso8601(fundingTimestamp),
|
1592
|
+
'nextFundingRate': self.safe_number(data, 'predictedValue'),
|
1569
1593
|
'nextFundingTimestamp': None,
|
1570
1594
|
'nextFundingDatetime': None,
|
1571
|
-
'previousFundingRate':
|
1572
|
-
'previousFundingTimestamp':
|
1573
|
-
'previousFundingDatetime':
|
1574
|
-
'interval': self.parse_funding_interval(self.safe_string(data, '
|
1595
|
+
'previousFundingRate': None,
|
1596
|
+
'previousFundingTimestamp': None,
|
1597
|
+
'previousFundingDatetime': None,
|
1598
|
+
'interval': self.parse_funding_interval(self.safe_string(data, 'granularity')),
|
1575
1599
|
}
|
1576
1600
|
|
1577
1601
|
def parse_funding_interval(self, interval):
|
ccxt/pro/__init__.py
CHANGED
ccxt/pro/binance.py
CHANGED
@@ -243,7 +243,7 @@ class binance(ccxt.async_support.binance):
|
|
243
243
|
type = None
|
244
244
|
type, params = self.handle_market_type_and_params('watchLiquidationsForSymbols', firstMarket, params)
|
245
245
|
if type == 'spot':
|
246
|
-
raise BadRequest(self.id + 'watchLiquidationsForSymbols is not supported for
|
246
|
+
raise BadRequest(self.id + 'watchLiquidationsForSymbols is not supported for spot symbols')
|
247
247
|
subType = None
|
248
248
|
subType, params = self.handle_sub_type_and_params('watchLiquidationsForSymbols', firstMarket, params)
|
249
249
|
if self.isLinear(type, subType):
|
ccxt/pro/okx.py
CHANGED
@@ -25,6 +25,8 @@ class okx(ccxt.async_support.okx):
|
|
25
25
|
'has': {
|
26
26
|
'ws': True,
|
27
27
|
'watchTicker': True,
|
28
|
+
'watchMarkPrice': True,
|
29
|
+
'watchMarkPrices': True,
|
28
30
|
'watchTickers': True,
|
29
31
|
'watchBidsAsks': True,
|
30
32
|
'watchOrderBook': True,
|
@@ -408,6 +410,41 @@ class okx(ccxt.async_support.okx):
|
|
408
410
|
return newTickers
|
409
411
|
return self.filter_by_array(self.tickers, 'symbol', symbols)
|
410
412
|
|
413
|
+
async def watch_mark_price(self, symbol: str, params={}) -> Ticker:
|
414
|
+
"""
|
415
|
+
:see: https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel
|
416
|
+
watches a mark price
|
417
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
418
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
419
|
+
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
|
420
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
421
|
+
"""
|
422
|
+
channel = None
|
423
|
+
channel, params = self.handle_option_and_params(params, 'watchMarkPrice', 'channel', 'mark-price')
|
424
|
+
params['channel'] = channel
|
425
|
+
market = self.market(symbol)
|
426
|
+
symbol = market['symbol']
|
427
|
+
ticker = await self.watch_mark_prices([symbol], params)
|
428
|
+
return ticker[symbol]
|
429
|
+
|
430
|
+
async def watch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
431
|
+
"""
|
432
|
+
:see: https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel
|
433
|
+
watches mark prices
|
434
|
+
:param str[] [symbols]: unified symbol of the market to fetch the ticker for
|
435
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
436
|
+
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
|
437
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
438
|
+
"""
|
439
|
+
await self.load_markets()
|
440
|
+
symbols = self.market_symbols(symbols, None, False)
|
441
|
+
channel = None
|
442
|
+
channel, params = self.handle_option_and_params(params, 'watchMarkPrices', 'channel', 'mark-price')
|
443
|
+
newTickers = await self.subscribe_multiple('public', channel, symbols, params)
|
444
|
+
if self.newUpdates:
|
445
|
+
return newTickers
|
446
|
+
return self.filter_by_array(self.tickers, 'symbol', symbols)
|
447
|
+
|
411
448
|
async def un_watch_tickers(self, symbols: Strings = None, params={}) -> Any:
|
412
449
|
"""
|
413
450
|
:see: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
|
@@ -2157,6 +2194,7 @@ class okx(ccxt.async_support.okx):
|
|
2157
2194
|
'books50-l2-tbt': self.handle_order_book, # only users who're VIP4 and above can subscribe, identity verification required before subscription
|
2158
2195
|
'books-l2-tbt': self.handle_order_book, # only users who're VIP5 and above can subscribe, identity verification required before subscription
|
2159
2196
|
'tickers': self.handle_ticker,
|
2197
|
+
'mark-price': self.handle_ticker,
|
2160
2198
|
'positions': self.handle_positions,
|
2161
2199
|
'index-tickers': self.handle_ticker,
|
2162
2200
|
'sprd-tickers': self.handle_ticker,
|
ccxt/pro/upbit.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
import ccxt.async_support
|
7
7
|
from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheBySymbolById
|
8
|
-
from ccxt.base.types import Balances, Int, Order, OrderBook, Str, Ticker, Trade
|
8
|
+
from ccxt.base.types import Balances, Int, Order, OrderBook, Str, Strings, Ticker, Tickers, Trade
|
9
9
|
from ccxt.async_support.base.ws.client import Client
|
10
10
|
from typing import List
|
11
11
|
|
@@ -18,6 +18,7 @@ class upbit(ccxt.async_support.upbit):
|
|
18
18
|
'ws': True,
|
19
19
|
'watchOrderBook': True,
|
20
20
|
'watchTicker': True,
|
21
|
+
'watchTickers': True,
|
21
22
|
'watchTrades': True,
|
22
23
|
'watchTradesForSymbols': True,
|
23
24
|
'watchOrders': True,
|
@@ -60,6 +61,31 @@ class upbit(ccxt.async_support.upbit):
|
|
60
61
|
messageHash = channel + ':' + marketId
|
61
62
|
return await self.watch(url, messageHash, request, messageHash)
|
62
63
|
|
64
|
+
async def watch_public_multiple(self, symbols: Strings, channel, params={}):
|
65
|
+
await self.load_markets()
|
66
|
+
if symbols is None:
|
67
|
+
symbols = self.symbols
|
68
|
+
symbols = self.market_symbols(symbols)
|
69
|
+
marketIds = self.market_ids(symbols)
|
70
|
+
url = self.implode_params(self.urls['api']['ws'], {
|
71
|
+
'hostname': self.hostname,
|
72
|
+
})
|
73
|
+
messageHashes = []
|
74
|
+
for i in range(0, len(marketIds)):
|
75
|
+
messageHashes.append(channel + ':' + marketIds[i])
|
76
|
+
request = [
|
77
|
+
{
|
78
|
+
'ticket': self.uuid(),
|
79
|
+
},
|
80
|
+
{
|
81
|
+
'type': channel,
|
82
|
+
'codes': marketIds,
|
83
|
+
# 'isOnlySnapshot': False,
|
84
|
+
# 'isOnlyRealtime': False,
|
85
|
+
},
|
86
|
+
]
|
87
|
+
return await self.watch_multiple(url, messageHashes, request, messageHashes)
|
88
|
+
|
63
89
|
async def watch_ticker(self, symbol: str, params={}) -> Ticker:
|
64
90
|
"""
|
65
91
|
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
@@ -70,6 +96,21 @@ class upbit(ccxt.async_support.upbit):
|
|
70
96
|
"""
|
71
97
|
return await self.watch_public(symbol, 'ticker')
|
72
98
|
|
99
|
+
async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
100
|
+
"""
|
101
|
+
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
102
|
+
:see: https://global-docs.upbit.com/reference/websocket-ticker
|
103
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
104
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
105
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
106
|
+
"""
|
107
|
+
newTickers = await self.watch_public_multiple(symbols, 'ticker')
|
108
|
+
if self.newUpdates:
|
109
|
+
tickers: dict = {}
|
110
|
+
tickers[newTickers['symbol']] = newTickers
|
111
|
+
return tickers
|
112
|
+
return self.filter_by_array(self.tickers, 'symbol', symbols)
|
113
|
+
|
73
114
|
async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
74
115
|
"""
|
75
116
|
get the list of most recent trades for a particular symbol
|
ccxt/pro/vertex.py
CHANGED
@@ -53,6 +53,9 @@ class vertex(ccxt.async_support.vertex):
|
|
53
53
|
'fetchPositionsSnapshot': True, # or False
|
54
54
|
'awaitPositionsSnapshot': True, # whether to wait for the positions snapshot before providing updates
|
55
55
|
},
|
56
|
+
'ws': {
|
57
|
+
'inflate': True,
|
58
|
+
},
|
56
59
|
},
|
57
60
|
'streaming': {
|
58
61
|
# 'ping': self.ping,
|
@@ -81,6 +84,14 @@ class vertex(ccxt.async_support.vertex):
|
|
81
84
|
'id': requestId,
|
82
85
|
}
|
83
86
|
request = self.extend(subscribe, message)
|
87
|
+
wsOptions = {
|
88
|
+
'headers': {
|
89
|
+
'Sec-WebSocket-Extensions': 'permessage-deflate',
|
90
|
+
},
|
91
|
+
}
|
92
|
+
self.options['ws'] = {
|
93
|
+
'options': wsOptions,
|
94
|
+
}
|
84
95
|
return await self.watch(url, messageHash, request, messageHash, subscribe)
|
85
96
|
|
86
97
|
async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
ccxt/test/tests_async.py
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
import asyncio
|
4
4
|
|
5
5
|
|
6
|
-
from tests_helpers import AuthenticationError, NotSupported, InvalidProxySettings, ExchangeNotAvailable, OperationFailed, OnMaintenance, get_cli_arg_value,
|
6
|
+
from tests_helpers import AuthenticationError, NotSupported, InvalidProxySettings, ExchangeNotAvailable, OperationFailed, OnMaintenance, get_cli_arg_value, get_root_dir, is_sync, dump, json_parse, json_stringify, convert_ascii, io_file_exists, io_file_read, io_dir_read, call_method, call_method_sync, call_exchange_method_dynamically, call_exchange_method_dynamically_sync, get_root_exception, exception_message, exit_script, get_exchange_prop, set_exchange_prop, init_exchange, get_test_files_sync, get_test_files, set_fetch_response, is_null_value, close, get_env_vars, get_lang, get_ext # noqa: F401
|
7
7
|
|
8
8
|
class testMainClass:
|
9
|
-
is_synchronous = IS_SYNCHRONOUS
|
10
9
|
id_tests = False
|
11
10
|
request_tests_failed = False
|
12
11
|
response_tests_failed = False
|
@@ -21,20 +20,17 @@ class testMainClass:
|
|
21
20
|
private_test_only = False
|
22
21
|
load_keys = False
|
23
22
|
sandbox = False
|
24
|
-
proxy_test_file_name = PROXY_TEST_FILE_NAME
|
25
23
|
only_specific_tests = []
|
26
24
|
skipped_settings_for_exchange = {}
|
27
25
|
skipped_methods = {}
|
28
26
|
checked_public_tests = {}
|
29
27
|
test_files = {}
|
30
28
|
public_tests = {}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
ext = EXT
|
35
|
-
lang = LANG
|
29
|
+
ext = ''
|
30
|
+
lang = ''
|
31
|
+
proxy_test_file_name = 'proxies'
|
36
32
|
|
37
|
-
def
|
33
|
+
def parse_cli_args_and_props(self):
|
38
34
|
self.response_tests = get_cli_arg_value('--responseTests')
|
39
35
|
self.id_tests = get_cli_arg_value('--idTests')
|
40
36
|
self.request_tests = get_cli_arg_value('--requestTests')
|
@@ -46,9 +42,11 @@ class testMainClass:
|
|
46
42
|
self.sandbox = get_cli_arg_value('--sandbox')
|
47
43
|
self.load_keys = get_cli_arg_value('--loadKeys')
|
48
44
|
self.ws_tests = get_cli_arg_value('--ws')
|
45
|
+
self.lang = get_lang()
|
46
|
+
self.ext = get_ext()
|
49
47
|
|
50
48
|
async def init(self, exchange_id, symbol_argv, method_argv):
|
51
|
-
self.
|
49
|
+
self.parse_cli_args_and_props()
|
52
50
|
if self.request_tests and self.response_tests:
|
53
51
|
await self.run_static_request_tests(exchange_id, symbol_argv)
|
54
52
|
await self.run_static_response_tests(exchange_id, symbol_argv)
|
@@ -62,12 +60,13 @@ class testMainClass:
|
|
62
60
|
if self.id_tests:
|
63
61
|
await self.run_broker_id_tests()
|
64
62
|
return
|
65
|
-
|
63
|
+
new_line = '\n'
|
64
|
+
dump(new_line + '' + new_line + '' + '[INFO] TESTING ', self.ext, {
|
66
65
|
'exchange': exchange_id,
|
67
66
|
'symbol': symbol_argv,
|
68
67
|
'method': method_argv,
|
69
68
|
'isWs': self.ws_tests,
|
70
|
-
},
|
69
|
+
}, new_line)
|
71
70
|
exchange_args = {
|
72
71
|
'verbose': self.verbose,
|
73
72
|
'debug': self.debug,
|
@@ -100,7 +99,7 @@ class testMainClass:
|
|
100
99
|
async def import_files(self, exchange):
|
101
100
|
properties = list(exchange.has.keys())
|
102
101
|
properties.append('loadMarkets')
|
103
|
-
if
|
102
|
+
if is_sync():
|
104
103
|
self.test_files = get_test_files_sync(properties, self.ws_tests)
|
105
104
|
else:
|
106
105
|
self.test_files = await get_test_files(properties, self.ws_tests)
|
@@ -115,14 +114,15 @@ class testMainClass:
|
|
115
114
|
if is_required and get_exchange_prop(exchange, credential) is None:
|
116
115
|
full_key = exchange_id + '_' + credential
|
117
116
|
credential_env_name = full_key.upper() # example: KRAKEN_APIKEY
|
118
|
-
|
117
|
+
env_vars = get_env_vars()
|
118
|
+
credential_value = env_vars[credential_env_name] if (credential_env_name in env_vars) else None
|
119
119
|
if credential_value:
|
120
120
|
set_exchange_prop(exchange, credential, credential_value)
|
121
121
|
|
122
122
|
def expand_settings(self, exchange):
|
123
123
|
exchange_id = exchange.id
|
124
|
-
keys_global =
|
125
|
-
keys_local =
|
124
|
+
keys_global = get_root_dir() + 'keys.json'
|
125
|
+
keys_local = get_root_dir() + 'keys.local.json'
|
126
126
|
keys_global_exists = io_file_exists(keys_global)
|
127
127
|
keys_local_exists = io_file_exists(keys_local)
|
128
128
|
global_settings = io_file_read(keys_global) if keys_global_exists else {}
|
@@ -145,7 +145,7 @@ class testMainClass:
|
|
145
145
|
if self.load_keys:
|
146
146
|
self.load_credentials_from_env(exchange)
|
147
147
|
# skipped tests
|
148
|
-
skipped_file =
|
148
|
+
skipped_file = get_root_dir() + 'skip-tests.json'
|
149
149
|
skipped_settings = io_file_read(skipped_file)
|
150
150
|
self.skipped_settings_for_exchange = exchange.safe_value(skipped_settings, exchange_id, {})
|
151
151
|
skipped_settings_for_exchange = self.skipped_settings_for_exchange
|
@@ -206,7 +206,7 @@ class testMainClass:
|
|
206
206
|
if self.info:
|
207
207
|
args_stringified = '(' + exchange.json(args) + ')' # args.join() breaks when we provide a list of symbols or multidimensional array; "args.toString()" breaks bcz of "array to string conversion"
|
208
208
|
dump(self.add_padding('[INFO] TESTING', 25), name, method_name, args_stringified)
|
209
|
-
if
|
209
|
+
if is_sync():
|
210
210
|
call_method_sync(self.test_files, method_name, exchange, skipped_properties_for_method, args)
|
211
211
|
else:
|
212
212
|
await call_method(self.test_files, method_name, exchange, skipped_properties_for_method, args)
|
@@ -589,7 +589,7 @@ class testMainClass:
|
|
589
589
|
# these tests should be synchronously executed, because of conflicting nature of proxy settings
|
590
590
|
proxy_test_name = self.proxy_test_file_name
|
591
591
|
# todo: temporary skip for sync py
|
592
|
-
if self.ext == 'py' and
|
592
|
+
if self.ext == 'py' and is_sync():
|
593
593
|
return
|
594
594
|
# try proxy several times
|
595
595
|
max_retries = 3
|
@@ -617,7 +617,7 @@ class testMainClass:
|
|
617
617
|
try:
|
618
618
|
result = await self.load_exchange(exchange)
|
619
619
|
if not result:
|
620
|
-
if not
|
620
|
+
if not is_sync():
|
621
621
|
await close(exchange)
|
622
622
|
return
|
623
623
|
# if (exchange.id === 'binance') {
|
@@ -625,10 +625,10 @@ class testMainClass:
|
|
625
625
|
# # await this.testProxies (exchange);
|
626
626
|
# }
|
627
627
|
await self.test_exchange(exchange, symbol)
|
628
|
-
if not
|
628
|
+
if not is_sync():
|
629
629
|
await close(exchange)
|
630
630
|
except Exception as e:
|
631
|
-
if not
|
631
|
+
if not is_sync():
|
632
632
|
await close(exchange)
|
633
633
|
raise e
|
634
634
|
|
@@ -648,12 +648,12 @@ class testMainClass:
|
|
648
648
|
# to make this test as fast as possible
|
649
649
|
# and basically independent from the exchange
|
650
650
|
# so we can run it offline
|
651
|
-
filename =
|
651
|
+
filename = get_root_dir() + './ts/src/test/static/markets/' + id + '.json'
|
652
652
|
content = io_file_read(filename)
|
653
653
|
return content
|
654
654
|
|
655
655
|
def load_currencies_from_file(self, id):
|
656
|
-
filename =
|
656
|
+
filename = get_root_dir() + './ts/src/test/static/currencies/' + id + '.json'
|
657
657
|
content = io_file_read(filename)
|
658
658
|
return content
|
659
659
|
|
@@ -843,7 +843,7 @@ class testMainClass:
|
|
843
843
|
output = None
|
844
844
|
request_url = None
|
845
845
|
try:
|
846
|
-
if not
|
846
|
+
if not is_sync():
|
847
847
|
await call_exchange_method_dynamically(exchange, method, self.sanitize_data_input(data['input']))
|
848
848
|
else:
|
849
849
|
call_exchange_method_dynamically_sync(exchange, method, self.sanitize_data_input(data['input']))
|
@@ -864,7 +864,7 @@ class testMainClass:
|
|
864
864
|
expected_result = exchange.safe_value(data, 'parsedResponse')
|
865
865
|
mocked_exchange = set_fetch_response(exchange, data['httpResponse'])
|
866
866
|
try:
|
867
|
-
if not
|
867
|
+
if not is_sync():
|
868
868
|
unified_result = await call_exchange_method_dynamically(exchange, method, self.sanitize_data_input(data['input']))
|
869
869
|
self.assert_static_response_output(mocked_exchange, skip_keys, unified_result, expected_result)
|
870
870
|
else:
|
@@ -960,7 +960,7 @@ class testMainClass:
|
|
960
960
|
# reset options
|
961
961
|
# exchange.options = exchange.deepExtend (oldExchangeOptions, {});
|
962
962
|
exchange.extend_exchange_options(exchange.deep_extend(old_exchange_options, {}))
|
963
|
-
if not
|
963
|
+
if not is_sync():
|
964
964
|
await close(exchange)
|
965
965
|
return True # in c# methods that will be used with promiseAll need to return something
|
966
966
|
|
@@ -1010,7 +1010,7 @@ class testMainClass:
|
|
1010
1010
|
# reset options
|
1011
1011
|
# exchange.options = exchange.deepExtend (oldExchangeOptions, {});
|
1012
1012
|
exchange.extend_exchange_options(exchange.deep_extend(old_exchange_options, {}))
|
1013
|
-
if not
|
1013
|
+
if not is_sync():
|
1014
1014
|
await close(exchange)
|
1015
1015
|
return True # in c# methods that will be used with promiseAll need to return something
|
1016
1016
|
|
@@ -1031,7 +1031,7 @@ class testMainClass:
|
|
1031
1031
|
await self.run_static_tests('request', target_exchange, test_name)
|
1032
1032
|
|
1033
1033
|
async def run_static_tests(self, type, target_exchange=None, test_name=None):
|
1034
|
-
folder =
|
1034
|
+
folder = get_root_dir() + './ts/src/test/static/' + type + '/'
|
1035
1035
|
static_data = self.load_static_data(folder, target_exchange)
|
1036
1036
|
if static_data is None:
|
1037
1037
|
return
|
@@ -1056,7 +1056,7 @@ class testMainClass:
|
|
1056
1056
|
if self.request_tests_failed or self.response_tests_failed:
|
1057
1057
|
exit_script(1)
|
1058
1058
|
else:
|
1059
|
-
prefix = '[SYNC]' if (
|
1059
|
+
prefix = '[SYNC]' if (is_sync()) else ''
|
1060
1060
|
success_message = '[' + self.lang + ']' + prefix + '[TEST_SUCCESS] ' + str(sum) + ' static ' + type + ' tests passed.'
|
1061
1061
|
dump('[INFO]' + success_message)
|
1062
1062
|
|
@@ -1103,7 +1103,7 @@ class testMainClass:
|
|
1103
1103
|
assert client_order_id_swap.startswith(swap_id_string), 'binance - swap clientOrderId: ' + client_order_id_swap + ' does not start with swapId' + swap_id_string
|
1104
1104
|
client_order_id_inverse = swap_inverse_order_request['newClientOrderId']
|
1105
1105
|
assert client_order_id_inverse.startswith(swap_id_string), 'binance - swap clientOrderIdInverse: ' + client_order_id_inverse + ' does not start with swapId' + swap_id_string
|
1106
|
-
if not
|
1106
|
+
if not is_sync():
|
1107
1107
|
await close(exchange)
|
1108
1108
|
return True
|
1109
1109
|
|
@@ -1129,7 +1129,7 @@ class testMainClass:
|
|
1129
1129
|
assert client_order_id_swap.startswith(id_string), 'okx - swap clientOrderId: ' + client_order_id_swap + ' does not start with id: ' + id_string
|
1130
1130
|
swap_tag = swap_order_request[0]['tag']
|
1131
1131
|
assert swap_tag == id, 'okx - id: ' + id + ' different from swap tag: ' + swap_tag
|
1132
|
-
if not
|
1132
|
+
if not is_sync():
|
1133
1133
|
await close(exchange)
|
1134
1134
|
return True
|
1135
1135
|
|
@@ -1144,7 +1144,7 @@ class testMainClass:
|
|
1144
1144
|
request = json_parse(exchange.last_request_body)
|
1145
1145
|
broker_id = request['params']['broker_id']
|
1146
1146
|
assert broker_id == id, 'cryptocom - id: ' + id + ' different from broker_id: ' + broker_id
|
1147
|
-
if not
|
1147
|
+
if not is_sync():
|
1148
1148
|
await close(exchange)
|
1149
1149
|
return True
|
1150
1150
|
|
@@ -1159,7 +1159,7 @@ class testMainClass:
|
|
1159
1159
|
# we expect an error here, we're only interested in the headers
|
1160
1160
|
req_headers = exchange.last_request_headers
|
1161
1161
|
assert req_headers['Referer'] == id, 'bybit - id: ' + id + ' not in headers.'
|
1162
|
-
if not
|
1162
|
+
if not is_sync():
|
1163
1163
|
await close(exchange)
|
1164
1164
|
return True
|
1165
1165
|
|
@@ -1177,7 +1177,7 @@ class testMainClass:
|
|
1177
1177
|
req_headers = exchange.last_request_headers
|
1178
1178
|
id = 'ccxt'
|
1179
1179
|
assert req_headers['KC-API-PARTNER'] == id, 'kucoin - id: ' + id + ' not in headers.'
|
1180
|
-
if not
|
1180
|
+
if not is_sync():
|
1181
1181
|
await close(exchange)
|
1182
1182
|
return True
|
1183
1183
|
|
@@ -1194,7 +1194,7 @@ class testMainClass:
|
|
1194
1194
|
except Exception as e:
|
1195
1195
|
req_headers = exchange.last_request_headers
|
1196
1196
|
assert req_headers['KC-API-PARTNER'] == id, 'kucoinfutures - id: ' + id + ' not in headers.'
|
1197
|
-
if not
|
1197
|
+
if not is_sync():
|
1198
1198
|
await close(exchange)
|
1199
1199
|
return True
|
1200
1200
|
|
@@ -1208,7 +1208,7 @@ class testMainClass:
|
|
1208
1208
|
except Exception as e:
|
1209
1209
|
req_headers = exchange.last_request_headers
|
1210
1210
|
assert req_headers['X-CHANNEL-API-CODE'] == id, 'bitget - id: ' + id + ' not in headers.'
|
1211
|
-
if not
|
1211
|
+
if not is_sync():
|
1212
1212
|
await close(exchange)
|
1213
1213
|
return True
|
1214
1214
|
|
@@ -1223,7 +1223,7 @@ class testMainClass:
|
|
1223
1223
|
except Exception as e:
|
1224
1224
|
req_headers = exchange.last_request_headers
|
1225
1225
|
assert req_headers['source'] == id, 'mexc - id: ' + id + ' not in headers.'
|
1226
|
-
if not
|
1226
|
+
if not is_sync():
|
1227
1227
|
await close(exchange)
|
1228
1228
|
return True
|
1229
1229
|
|
@@ -1254,7 +1254,7 @@ class testMainClass:
|
|
1254
1254
|
assert client_order_id_swap.startswith(id_string), 'htx - swap channel_code ' + client_order_id_swap + ' does not start with id: ' + id_string
|
1255
1255
|
client_order_id_inverse = swap_inverse_order_request['channel_code']
|
1256
1256
|
assert client_order_id_inverse.startswith(id_string), 'htx - swap inverse channel_code ' + client_order_id_inverse + ' does not start with id: ' + id_string
|
1257
|
-
if not
|
1257
|
+
if not is_sync():
|
1258
1258
|
await close(exchange)
|
1259
1259
|
return True
|
1260
1260
|
|
@@ -1280,7 +1280,7 @@ class testMainClass:
|
|
1280
1280
|
stop_order_request = json_parse(exchange.last_request_body)
|
1281
1281
|
client_order_id_stop = stop_order_request['brokerId']
|
1282
1282
|
assert client_order_id_stop.startswith(id_string), 'woo - brokerId: ' + client_order_id_stop + ' does not start with id: ' + id_string
|
1283
|
-
if not
|
1283
|
+
if not is_sync():
|
1284
1284
|
await close(exchange)
|
1285
1285
|
return True
|
1286
1286
|
|
@@ -1295,7 +1295,7 @@ class testMainClass:
|
|
1295
1295
|
except Exception as e:
|
1296
1296
|
req_headers = exchange.last_request_headers
|
1297
1297
|
assert req_headers['X-BM-BROKER-ID'] == id, 'bitmart - id: ' + id + ' not in headers'
|
1298
|
-
if not
|
1298
|
+
if not is_sync():
|
1299
1299
|
await close(exchange)
|
1300
1300
|
return True
|
1301
1301
|
|
@@ -1311,7 +1311,7 @@ class testMainClass:
|
|
1311
1311
|
client_order_id = spot_order_request['client_id']
|
1312
1312
|
id_string = str(id)
|
1313
1313
|
assert client_order_id.startswith(id_string), 'coinex - clientOrderId: ' + client_order_id + ' does not start with id: ' + id_string
|
1314
|
-
if not
|
1314
|
+
if not is_sync():
|
1315
1315
|
await close(exchange)
|
1316
1316
|
return True
|
1317
1317
|
|
@@ -1326,7 +1326,7 @@ class testMainClass:
|
|
1326
1326
|
# we expect an error here, we're only interested in the headers
|
1327
1327
|
req_headers = exchange.last_request_headers
|
1328
1328
|
assert req_headers['X-SOURCE-KEY'] == id, 'bingx - id: ' + id + ' not in headers.'
|
1329
|
-
if not
|
1329
|
+
if not is_sync():
|
1330
1330
|
await close(exchange)
|
1331
1331
|
|
1332
1332
|
async def test_phemex(self):
|
@@ -1340,7 +1340,7 @@ class testMainClass:
|
|
1340
1340
|
client_order_id = request['clOrdID']
|
1341
1341
|
id_string = str(id)
|
1342
1342
|
assert client_order_id.startswith(id_string), 'phemex - clOrdID: ' + client_order_id + ' does not start with id: ' + id_string
|
1343
|
-
if not
|
1343
|
+
if not is_sync():
|
1344
1344
|
await close(exchange)
|
1345
1345
|
|
1346
1346
|
async def test_blofin(self):
|
@@ -1354,7 +1354,7 @@ class testMainClass:
|
|
1354
1354
|
broker_id = request['brokerId']
|
1355
1355
|
id_string = str(id)
|
1356
1356
|
assert broker_id.startswith(id_string), 'blofin - brokerId: ' + broker_id + ' does not start with id: ' + id_string
|
1357
|
-
if not
|
1357
|
+
if not is_sync():
|
1358
1358
|
await close(exchange)
|
1359
1359
|
|
1360
1360
|
async def test_hyperliquid(self):
|
@@ -1367,7 +1367,7 @@ class testMainClass:
|
|
1367
1367
|
request = json_parse(exchange.last_request_body)
|
1368
1368
|
broker_id = str((request['action']['brokerCode']))
|
1369
1369
|
assert broker_id == id, 'hyperliquid - brokerId: ' + broker_id + ' does not start with id: ' + id
|
1370
|
-
if not
|
1370
|
+
if not is_sync():
|
1371
1371
|
await close(exchange)
|
1372
1372
|
|
1373
1373
|
async def test_coinbaseinternational(self):
|
@@ -1382,7 +1382,7 @@ class testMainClass:
|
|
1382
1382
|
request = json_parse(exchange.last_request_body)
|
1383
1383
|
client_order_id = request['client_order_id']
|
1384
1384
|
assert client_order_id.startswith(str(id)), 'clientOrderId does not start with id'
|
1385
|
-
if not
|
1385
|
+
if not is_sync():
|
1386
1386
|
await close(exchange)
|
1387
1387
|
return True
|
1388
1388
|
|
@@ -1397,7 +1397,7 @@ class testMainClass:
|
|
1397
1397
|
request = json_parse(exchange.last_request_body)
|
1398
1398
|
client_order_id = request['client_order_id']
|
1399
1399
|
assert client_order_id.startswith(str(id)), 'clientOrderId does not start with id'
|
1400
|
-
if not
|
1400
|
+
if not is_sync():
|
1401
1401
|
await close(exchange)
|
1402
1402
|
return True
|
1403
1403
|
|
@@ -1413,7 +1413,7 @@ class testMainClass:
|
|
1413
1413
|
request = json_parse(exchange.last_request_body)
|
1414
1414
|
broker_id = request['order_tag']
|
1415
1415
|
assert broker_id == id, 'woofipro - id: ' + id + ' different from broker_id: ' + broker_id
|
1416
|
-
if not
|
1416
|
+
if not is_sync():
|
1417
1417
|
await close(exchange)
|
1418
1418
|
return True
|
1419
1419
|
|
@@ -1450,7 +1450,7 @@ class testMainClass:
|
|
1450
1450
|
swap_order_request = json_parse(exchange.last_request_body)
|
1451
1451
|
swap_media = swap_order_request['clientMedia']
|
1452
1452
|
assert swap_media == id, 'xt - id: ' + id + ' different from swap tag: ' + swap_media
|
1453
|
-
if not
|
1453
|
+
if not is_sync():
|
1454
1454
|
await close(exchange)
|
1455
1455
|
return True
|
1456
1456
|
|
@@ -1473,7 +1473,7 @@ class testMainClass:
|
|
1473
1473
|
order = request['place_order']
|
1474
1474
|
broker_id = order['id']
|
1475
1475
|
assert broker_id == id, 'vertex - id: ' + str(id) + ' different from broker_id: ' + str(broker_id)
|
1476
|
-
if not
|
1476
|
+
if not is_sync():
|
1477
1477
|
await close(exchange)
|
1478
1478
|
return True
|
1479
1479
|
|
@@ -1515,7 +1515,7 @@ class testMainClass:
|
|
1515
1515
|
except Exception as e:
|
1516
1516
|
req_headers = exchange.last_request_headers
|
1517
1517
|
assert req_headers['PARADEX-PARTNER'] == id, 'paradex - id: ' + id + ' not in headers'
|
1518
|
-
if not
|
1518
|
+
if not is_sync():
|
1519
1519
|
await close(exchange)
|
1520
1520
|
return True
|
1521
1521
|
|
@@ -1529,6 +1529,6 @@ class testMainClass:
|
|
1529
1529
|
# we expect an error here, we're only interested in the headers
|
1530
1530
|
req_headers = exchange.last_request_headers
|
1531
1531
|
assert req_headers['INPUT-SOURCE'] == id, 'hashkey - id: ' + id + ' not in headers.'
|
1532
|
-
if not
|
1532
|
+
if not is_sync():
|
1533
1533
|
await close(exchange)
|
1534
1534
|
return True
|