Merge branch 'fix-docs' of https://github.com/stash86/freqtrade into fix-docs

This commit is contained in:
Stefano Ariestasia
2022-01-22 06:54:57 +00:00
18 changed files with 195 additions and 68 deletions

View File

@@ -220,11 +220,17 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
assert "Since" in headers
assert "Pair" in headers
assert len(result[0]) == 4
assert 'instantly' == result[0][2]
assert 'ETH/BTC' in result[0][1]
assert '-0.41% (-0.06)' == result[0][3]
assert '-0.06' == f'{fiat_profit_sum:.2f}'
rpc._config['position_adjustment_enable'] = True
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
assert "# Buys" in headers
assert len(result[0]) == 5
mocker.patch('freqtrade.exchange.Exchange.get_rate',
MagicMock(side_effect=ExchangeError("Pair 'ETH/BTC' not available")))
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')

View File

@@ -1326,7 +1326,7 @@ def test_sysinfo(botclient):
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
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 not result['running']
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
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))
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.
rc = client_delete(client, f"{BASE_URI}/backtest")
assert_response(rc)