Api-backtest to test new functionality
This commit is contained in:
parent
a6c7f45545
commit
d549905856
@ -1326,7 +1326,7 @@ def test_sysinfo(botclient):
|
|||||||
assert 'ram_pct' in result
|
assert 'ram_pct' in result
|
||||||
|
|
||||||
|
|
||||||
def test_api_backtesting(botclient, mocker, fee, caplog):
|
def test_api_backtesting(botclient, mocker, fee, caplog, tmpdir):
|
||||||
ftbot, client = botclient
|
ftbot, client = botclient
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
||||||
|
|
||||||
@ -1347,6 +1347,11 @@ def test_api_backtesting(botclient, mocker, fee, caplog):
|
|||||||
assert result['status'] == 'reset'
|
assert result['status'] == 'reset'
|
||||||
assert not result['running']
|
assert not result['running']
|
||||||
assert result['status_msg'] == 'Backtest reset'
|
assert result['status_msg'] == 'Backtest reset'
|
||||||
|
ftbot.config['export'] = 'trades'
|
||||||
|
ftbot.config['backtest_cache'] = 'none'
|
||||||
|
ftbot.config['user_data_dir'] = Path(tmpdir)
|
||||||
|
ftbot.config['exportfilename'] = Path(tmpdir) / "backtest_results"
|
||||||
|
ftbot.config['exportfilename'].mkdir()
|
||||||
|
|
||||||
# start backtesting
|
# start backtesting
|
||||||
data = {
|
data = {
|
||||||
@ -1421,6 +1426,14 @@ def test_api_backtesting(botclient, mocker, fee, caplog):
|
|||||||
rc = client_post(client, f"{BASE_URI}/backtest", data=json.dumps(data))
|
rc = client_post(client, f"{BASE_URI}/backtest", data=json.dumps(data))
|
||||||
assert log_has("Backtesting caused an error: ", caplog)
|
assert log_has("Backtesting caused an error: ", caplog)
|
||||||
|
|
||||||
|
ftbot.config['backtest_cache'] = 'day'
|
||||||
|
|
||||||
|
# Rerun backtest (should get previous result)
|
||||||
|
rc = client_post(client, f"{BASE_URI}/backtest", data=json.dumps(data))
|
||||||
|
assert_response(rc)
|
||||||
|
result = rc.json()
|
||||||
|
assert log_has_re('Reusing result of previous backtest.*', caplog)
|
||||||
|
|
||||||
# Delete backtesting to avoid leakage since the backtest-object may stick around.
|
# Delete backtesting to avoid leakage since the backtest-object may stick around.
|
||||||
rc = client_delete(client, f"{BASE_URI}/backtest")
|
rc = client_delete(client, f"{BASE_URI}/backtest")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
|
Loading…
Reference in New Issue
Block a user