Test pairlist evaluation

This commit is contained in:
Matthias 2023-05-21 10:08:32 +02:00
parent 01984a06af
commit 756e1f5d5b
2 changed files with 54 additions and 2 deletions

View File

@ -374,7 +374,7 @@ def pairlists_evaluate_get():
raise HTTPException(status_code=400, detail='Pairlist evaluation is currently running.')
if not ApiBG.pairlist_result:
raise HTTPException(status_code=400, detail='Pairlist not started yet.')
raise HTTPException(status_code=400, detail='Pairlist evaluation not started yet.')
return ApiBG.pairlist_result

View File

@ -1616,7 +1616,7 @@ def test_api_freqaimodels(botclient, tmpdir, mocker):
]}
def test_api_available_pairlists(botclient, tmpdir):
def test_api_pairlists_available(botclient, tmpdir):
ftbot, client = botclient
ftbot.config['user_data_dir'] = Path(tmpdir)
@ -1639,6 +1639,58 @@ def test_api_available_pairlists(botclient, tmpdir):
assert len(volumepl['params']) > 2
def test_api_pairlists_evaluate(botclient, tmpdir):
ftbot, client = botclient
ftbot.config['user_data_dir'] = Path(tmpdir)
rc = client_get(client, f"{BASE_URI}/pairlists/evaluate")
assert_response(rc, 400)
assert rc.json()['detail'] == 'Pairlist evaluation not started yet.'
ApiBG.pairlist_running = True
rc = client_get(client, f"{BASE_URI}/pairlists/evaluate")
assert_response(rc, 400)
assert rc.json()['detail'] == 'Pairlist evaluation is currently running.'
body = {
"pairlists": [
{"method": "StaticPairList", },
],
"blacklist": [
],
"stake_currency": "BTC"
}
# Fail, already running
rc = client_post(client, f"{BASE_URI}/pairlists/evaluate", body)
assert_response(rc, 400)
assert rc.json()['detail'] == 'Pairlist evaluation is already running.'
# should start the run
ApiBG.pairlist_running = False
rc = client_post(client, f"{BASE_URI}/pairlists/evaluate", body)
assert_response(rc)
assert rc.json()['status'] == 'Pairlist evaluation started in background.'
rc = client_get(client, f"{BASE_URI}/pairlists/evaluate")
assert_response(rc)
response = rc.json()
assert response['whitelist'] == ['ETH/BTC', 'LTC/BTC', 'XRP/BTC', 'NEO/BTC',]
assert response['length'] == 4
# Restart with additional filter, reducing the list to 2
body['pairlists'].append({"method": "OffsetFilter", "number_assets": 2})
rc = client_post(client, f"{BASE_URI}/pairlists/evaluate", body)
assert_response(rc)
assert rc.json()['status'] == 'Pairlist evaluation started in background.'
rc = client_get(client, f"{BASE_URI}/pairlists/evaluate")
rc = client_get(client, f"{BASE_URI}/pairlists/evaluate")
assert_response(rc)
response = rc.json()
assert response['whitelist'] == ['ETH/BTC', 'LTC/BTC', ]
assert response['length'] == 2
def test_list_available_pairs(botclient):
ftbot, client = botclient