Update static-markets to include futures pair

This commit is contained in:
Matthias 2022-02-15 07:42:40 +01:00
parent 1bae18c60a
commit c37f03a638
5 changed files with 33 additions and 30 deletions

View File

@ -86,9 +86,7 @@ class Okx(Exchange):
for symbol in sorted(symbols): for symbol in sorted(symbols):
res = self._api.fetch_leverage_tiers(symbol) res = self._api.fetch_leverage_tiers(symbol)
tiers[symbol] = [] tiers[symbol] = res[symbol]
for tier in res[symbol]:
tiers[symbol].append(self.parse_leverage_tier(tier))
logger.info(f"Done initializing {len(symbols)} markets.") logger.info(f"Done initializing {len(symbols)} markets.")
return tiers return tiers

View File

@ -231,9 +231,9 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 10 active markets: " assert ("Exchange Bittrex has 12 active markets: "
"BLK/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, NEO/BTC, " "ADA/USDT:USDT, BLK/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, "
"TKN/BTC, XLTCUSDT, XRP/BTC.\n" "LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n"
in captured.out) in captured.out)
patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static) patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static)
@ -246,7 +246,7 @@ def test_list_markets(mocker, markets_static, capsys):
pargs['config'] = None pargs['config'] = None
start_list_markets(pargs, False) start_list_markets(pargs, False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("\nExchange Binance has 10 active markets:\n", assert re.match("\nExchange Binance has 12 active markets:\n",
captured.out) captured.out)
patch_exchange(mocker, api_mock=api_mock, id="bittrex", mock_markets=markets_static) patch_exchange(mocker, api_mock=api_mock, id="bittrex", mock_markets=markets_static)
@ -258,9 +258,9 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 12 markets: " assert ("Exchange Bittrex has 14 markets: "
"BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, " "ADA/USDT:USDT, BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, "
"TKN/BTC, XLTCUSDT, XRP/BTC.\n" "LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n"
in captured.out) in captured.out)
# Test list-pairs subcommand: active pairs # Test list-pairs subcommand: active pairs
@ -297,8 +297,8 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 6 active markets with ETH, LTC as base currencies: " assert ("Exchange Bittrex has 7 active markets with ETH, LTC as base currencies: "
"ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n" "ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, base=LTC # active markets, base=LTC
@ -323,8 +323,8 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 3 active markets with USDT, USD as quote currencies: " assert ("Exchange Bittrex has 5 active markets with USDT, USD as quote currencies: "
"ETH/USDT, LTC/USD, XLTCUSDT.\n" "ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, LTC/USD, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, quote=USDT # active markets, quote=USDT
@ -336,8 +336,8 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 2 active markets with USDT as quote currency: " assert ("Exchange Bittrex has 4 active markets with USDT as quote currency: "
"ETH/USDT, XLTCUSDT.\n" "ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, base=LTC, quote=USDT # active markets, base=LTC, quote=USDT
@ -399,7 +399,7 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 10 active markets:\n" assert ("Exchange Bittrex has 12 active markets:\n"
in captured.out) in captured.out)
# Test tabular output, no markets found # Test tabular output, no markets found
@ -422,8 +422,8 @@ def test_list_markets(mocker, markets_static, capsys):
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ('["BLK/BTC","ETH/BTC","ETH/USDT","LTC/BTC","LTC/ETH","LTC/USD","NEO/BTC",' assert ('["ADA/USDT:USDT","BLK/BTC","ETH/BTC","ETH/USDT","ETH/USDT:USDT",'
'"TKN/BTC","XLTCUSDT","XRP/BTC"]' '"LTC/BTC","LTC/ETH","LTC/USD","NEO/BTC","TKN/BTC","XLTCUSDT","XRP/BTC"]'
in captured.out) in captured.out)
# Test --print-csv # Test --print-csv

View File

@ -846,7 +846,7 @@ def get_markets():
'option': False, 'option': False,
'active': True, 'active': True,
'contract': None, 'contract': None,
'linear': True, 'linear': None,
'inverse': None, 'inverse': None,
'taker': 0.0006, 'taker': 0.0006,
'maker': 0.0002, 'maker': 0.0002,
@ -891,7 +891,7 @@ def get_markets():
'future': True, 'future': True,
'swap': True, 'swap': True,
'margin': True, 'margin': True,
'linear': True, 'linear': None,
'inverse': False, 'inverse': False,
'type': 'spot', 'type': 'spot',
'contractSize': None, 'contractSize': None,
@ -1398,7 +1398,9 @@ def markets_static():
# market list. Do not modify this list without a good reason! Do not modify market parameters # market list. Do not modify this list without a good reason! Do not modify market parameters
# of listed pairs in get_markets() without a good reason either! # of listed pairs in get_markets() without a good reason either!
static_markets = ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', static_markets = ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD',
'LTC/USDT', 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC'] 'LTC/USDT', 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC',
'ADA/USDT:USDT', 'ETH/USDT:USDT',
]
all_markets = get_markets() all_markets = get_markets()
return {m: all_markets[m] for m in static_markets} return {m: all_markets[m] for m in static_markets}

View File

@ -3003,8 +3003,9 @@ def test_get_valid_pair_combination(default_conf, mocker, markets):
# 'XLTCUSDT': 'active': True, not a pair # 'XLTCUSDT': 'active': True, not a pair
# 'XRP/BTC': 'active': False # 'XRP/BTC': 'active': False
([], [], False, False, False, False, ([], [], False, False, False, False,
['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT',
'LTC/USDT', 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC'], 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC', 'ADA/USDT:USDT',
'ETH/USDT:USDT'],
'all markets'), 'all markets'),
([], [], False, False, True, False, ([], [], False, False, True, False,
['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD',
@ -3012,7 +3013,7 @@ def test_get_valid_pair_combination(default_conf, mocker, markets):
'all markets, only spot pairs'), 'all markets, only spot pairs'),
([], [], False, True, False, False, ([], [], False, True, False, False,
['BLK/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'NEO/BTC', ['BLK/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'NEO/BTC',
'TKN/BTC', 'XLTCUSDT', 'XRP/BTC'], 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC', 'ADA/USDT:USDT', 'ETH/USDT:USDT'],
'active markets'), 'active markets'),
([], [], True, False, False, False, ([], [], True, False, False, False,
['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD',
@ -3023,7 +3024,8 @@ def test_get_valid_pair_combination(default_conf, mocker, markets):
'TKN/BTC', 'XRP/BTC'], 'TKN/BTC', 'XRP/BTC'],
'active pairs'), 'active pairs'),
(['ETH', 'LTC'], [], False, False, False, False, (['ETH', 'LTC'], [], False, False, False, False,
['ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT'], ['ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT',
'ETH/USDT:USDT'],
'all markets, base=ETH, LTC'), 'all markets, base=ETH, LTC'),
(['LTC'], [], False, False, False, False, (['LTC'], [], False, False, False, False,
['LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT'], ['LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT'],
@ -3032,13 +3034,13 @@ def test_get_valid_pair_combination(default_conf, mocker, markets):
['LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT'], ['LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT'],
'spot markets, base=LTC'), 'spot markets, base=LTC'),
([], ['USDT'], False, False, False, False, ([], ['USDT'], False, False, False, False,
['ETH/USDT', 'LTC/USDT', 'XLTCUSDT'], ['ETH/USDT', 'LTC/USDT', 'XLTCUSDT', 'ADA/USDT:USDT', 'ETH/USDT:USDT'],
'all markets, quote=USDT'), 'all markets, quote=USDT'),
([], ['USDT'], False, False, False, True, ([], ['USDT'], False, False, False, True,
['ETH/USDT', 'LTC/USDT'], ['ADA/USDT:USDT', 'ETH/USDT:USDT'],
'Futures markets, quote=USDT'), 'Futures markets, quote=USDT'),
([], ['USDT', 'USD'], False, False, False, False, ([], ['USDT', 'USD'], False, False, False, False,
['ETH/USDT', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT'], ['ETH/USDT', 'LTC/USD', 'LTC/USDT', 'XLTCUSDT', 'ADA/USDT:USDT', 'ETH/USDT:USDT'],
'all markets, quote=USDT, USD'), 'all markets, quote=USDT, USD'),
([], ['USDT', 'USD'], False, False, True, False, ([], ['USDT', 'USD'], False, False, True, False,
['ETH/USDT', 'LTC/USD', 'LTC/USDT'], ['ETH/USDT', 'LTC/USD', 'LTC/USDT'],

View File

@ -309,7 +309,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
exchange.trading_mode = TradingMode.FUTURES exchange.trading_mode = TradingMode.FUTURES
exchange.margin_mode = MarginMode.ISOLATED exchange.margin_mode = MarginMode.ISOLATED
exchange.markets = markets exchange.markets = markets
assert exchange.load_leverage_tiers() == { # Initialization of load_leverage_tiers happens as part of exchange init.
exchange._leverage_tiers == {
'ADA/USDT:USDT': [ 'ADA/USDT:USDT': [
{ {
'tier': 1, 'tier': 1,