Allow setting the exchange explicitly
This commit is contained in:
@@ -84,6 +84,10 @@ def pairlists_evaluate(payload: PairListsPayload, background_tasks: BackgroundTa
|
|||||||
config_loc = deepcopy(config)
|
config_loc = deepcopy(config)
|
||||||
config_loc['stake_currency'] = payload.stake_currency
|
config_loc['stake_currency'] = payload.stake_currency
|
||||||
config_loc['pairlists'] = payload.pairlists
|
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?
|
# TODO: overwrite blacklist? make it optional and fall back to the one in config?
|
||||||
# Outcome depends on the UI approach.
|
# Outcome depends on the UI approach.
|
||||||
config_loc['exchange']['pair_blacklist'] = payload.blacklist
|
config_loc['exchange']['pair_blacklist'] = payload.blacklist
|
||||||
|
|||||||
@@ -432,6 +432,8 @@ class PairListsPayload(BaseModel):
|
|||||||
pairlists: List[Dict[str, Any]]
|
pairlists: List[Dict[str, Any]]
|
||||||
blacklist: List[str]
|
blacklist: List[str]
|
||||||
stake_currency: str
|
stake_currency: str
|
||||||
|
trading_mode: Optional[TradingMode]
|
||||||
|
exchange: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
class FreqAIModelListResponse(BaseModel):
|
class FreqAIModelListResponse(BaseModel):
|
||||||
|
|||||||
@@ -1645,7 +1645,7 @@ def test_api_pairlists_available(botclient, tmpdir):
|
|||||||
assert len(volumepl['params']) > 2
|
assert len(volumepl['params']) > 2
|
||||||
|
|
||||||
|
|
||||||
def test_api_pairlists_evaluate(botclient, tmpdir):
|
def test_api_pairlists_evaluate(botclient, tmpdir, mocker):
|
||||||
ftbot, client = botclient
|
ftbot, client = botclient
|
||||||
ftbot.config['user_data_dir'] = Path(tmpdir)
|
ftbot.config['user_data_dir'] = Path(tmpdir)
|
||||||
|
|
||||||
@@ -1709,6 +1709,24 @@ def test_api_pairlists_evaluate(botclient, tmpdir):
|
|||||||
response = rc.json()
|
response = rc.json()
|
||||||
assert response['result']['whitelist'] == ['ETH/BTC', 'LTC/BTC', ]
|
assert response['result']['whitelist'] == ['ETH/BTC', 'LTC/BTC', ]
|
||||||
assert response['result']['length'] == 2
|
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):
|
def test_list_available_pairs(botclient):
|
||||||
|
|||||||
Reference in New Issue
Block a user