Merge branch 'leverage-tiers' of https://github.com/samgermain/freqtrade into leverage-tiers

This commit is contained in:
Sam Germain
2022-02-16 03:50:24 -06:00
9 changed files with 81 additions and 45 deletions

View File

@@ -486,7 +486,7 @@ def test_fill_leverage_tiers_binance(default_conf, mocker):
api_mock,
"binance",
"fill_leverage_tiers",
"fetch_leverage_tiers"
"fetch_leverage_tiers",
)

View File

@@ -341,9 +341,9 @@ class TestCCXTExchange():
def test_ccxt_get_max_leverage_futures(self, exchange_futures):
futures, futures_name = exchange_futures
# TODO-lev: binance, gateio, and okx test
if futures:
leverage_in_market_futures = EXCHANGES[futures_name]['leverage_in_market']['futures']
# TODO-lev: binance, gateio, and okx don't have leverage_in_market
if leverage_in_market_futures:
futures_pair = EXCHANGES[futures_name].get(
'futures_pair',

View File

@@ -3003,8 +3003,9 @@ def test_get_valid_pair_combination(default_conf, mocker, markets):
# 'XLTCUSDT': 'active': True, not a pair
# 'XRP/BTC': 'active': False
([], [], False, False, False, False,
['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD',
'LTC/USDT', 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC'],
['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD', 'LTC/USDT',
'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC', 'ADA/USDT:USDT',
'ETH/USDT:USDT'],
'all markets'),
([], [], False, False, True, False,
['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'),
([], [], False, True, False, False,
['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'),
([], [], True, False, False, False,
['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'],
'active pairs'),
(['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'),
(['LTC'], [], False, False, False, False,
['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'],
'spot markets, base=LTC'),
([], ['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'),
([], ['USDT'], False, False, False, True,
['ETH/USDT', 'LTC/USDT'],
['ADA/USDT:USDT', 'ETH/USDT:USDT'],
'Futures markets, quote=USDT'),
([], ['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'),
([], ['USDT', 'USD'], False, False, True, False,
['ETH/USDT', 'LTC/USD', 'LTC/USDT'],
@@ -4247,7 +4249,7 @@ def test_load_leverage_tiers(mocker, default_conf, leverage_tiers):
mocker,
default_conf,
api_mock,
"binance",
"ftx",
"load_leverage_tiers",
"fetch_leverage_tiers",
)

View File

@@ -309,7 +309,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
exchange.trading_mode = TradingMode.FUTURES
exchange.margin_mode = MarginMode.ISOLATED
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': [
{
'tier': 1,