diff --git a/freqtrade/rpc/api_server/api_background_tasks.py b/freqtrade/rpc/api_server/api_background_tasks.py index 3aa432995..8538f1b9a 100644 --- a/freqtrade/rpc/api_server/api_background_tasks.py +++ b/freqtrade/rpc/api_server/api_background_tasks.py @@ -84,6 +84,10 @@ def pairlists_evaluate(payload: PairListsPayload, background_tasks: BackgroundTa config_loc = deepcopy(config) config_loc['stake_currency'] = payload.stake_currency config_loc['pairlists'] = payload.pairlists + if payload.exchange: + config_loc['exchange']['name'] = payload.exchange + if payload.trading_mode: + config_loc['trading_mode'] = payload.trading_mode # TODO: overwrite blacklist? make it optional and fall back to the one in config? # Outcome depends on the UI approach. config_loc['exchange']['pair_blacklist'] = payload.blacklist diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index c3f31b3c6..1f5a79aef 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -432,6 +432,8 @@ class PairListsPayload(BaseModel): pairlists: List[Dict[str, Any]] blacklist: List[str] stake_currency: str + trading_mode: Optional[TradingMode] + exchange: Optional[str] class FreqAIModelListResponse(BaseModel): diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 9d0193d4a..f4229e0a0 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -1645,7 +1645,7 @@ def test_api_pairlists_available(botclient, tmpdir): assert len(volumepl['params']) > 2 -def test_api_pairlists_evaluate(botclient, tmpdir): +def test_api_pairlists_evaluate(botclient, tmpdir, mocker): ftbot, client = botclient ftbot.config['user_data_dir'] = Path(tmpdir) @@ -1709,6 +1709,24 @@ def test_api_pairlists_evaluate(botclient, tmpdir): response = rc.json() assert response['result']['whitelist'] == ['ETH/BTC', 'LTC/BTC', ] assert response['result']['length'] == 2 + # Patch __run_pairlists + plm = mocker.patch('freqtrade.rpc.api_server.api_background_tasks.__run_pairlist', return_value=None) + body = { + "pairlists": [ + {"method": "StaticPairList", }, + ], + "blacklist": [ + ], + "stake_currency": "BTC", + "exchange": "randomExchange", + "trading_mode": "futures", + } + rc = client_post(client, f"{BASE_URI}/pairlists/evaluate", body) + assert_response(rc) + assert plm.call_count == 1 + call_config = plm.call_args_list[0][0][1] + assert call_config['exchange']['name'] == 'randomExchange' + assert call_config['trading_mode'] == 'futures' def test_list_available_pairs(botclient):