Allow setting the exchange explicitly

This commit is contained in:
Matthias 2023-06-02 10:14:11 +02:00
parent af16ce874c
commit ac046d6a2d
3 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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):

View File

@ -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):