Add cleanup, adjust _print_table for indicators, add rsi to test output
This commit is contained in:
parent
edd474e663
commit
2873ca6d38
@ -26,7 +26,6 @@ def _load_signal_candles(backtest_dir: Path):
|
||||
get_latest_backtest_filename(backtest_dir))[0] + "_signals.pkl"
|
||||
)
|
||||
|
||||
print(scpf)
|
||||
try:
|
||||
scp = open(scpf, "rb")
|
||||
signal_candles = joblib.load(scp)
|
||||
@ -213,11 +212,9 @@ def _print_results(analysed_trades, stratname, group,
|
||||
if ind in bigdf:
|
||||
available_inds.append(ind)
|
||||
ilist = ["pair", "enter_reason", "exit_reason"] + available_inds
|
||||
print(tabulate(bigdf[ilist].sort_values(['exit_reason']),
|
||||
headers='keys', tablefmt='psql', showindex=False))
|
||||
_print_table(bigdf[ilist], sortcols=['exit_reason'], show_index=False)
|
||||
else:
|
||||
print(tabulate(bigdf[columns].sort_values(['pair']),
|
||||
headers='keys', tablefmt='psql', showindex=False))
|
||||
_print_table(bigdf[columns], sortcols=['pair'], show_index=False)
|
||||
else:
|
||||
print("\\_ No trades to show")
|
||||
|
||||
|
@ -2,13 +2,22 @@ from pathlib import Path
|
||||
from unittest.mock import MagicMock, PropertyMock
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
|
||||
from freqtrade.commands.analyze_commands import start_analysis_entries_exits
|
||||
from freqtrade.commands.optimize_commands import start_backtesting
|
||||
from freqtrade.enums import ExitType
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
from tests.conftest import get_args, patch_exchange, patched_configuration_load_config_file
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def backtesting_cleanup() -> None:
|
||||
yield None
|
||||
|
||||
Backtesting.cleanup()
|
||||
|
||||
|
||||
def test_backtest_analysis_nomock(default_conf, mocker, caplog, testdatadir, capsys):
|
||||
default_conf.update({
|
||||
"use_exit_signal": True,
|
||||
@ -18,7 +27,7 @@ def test_backtest_analysis_nomock(default_conf, mocker, caplog, testdatadir, cap
|
||||
'analysis_groups': "0",
|
||||
'enter_reason_list': "all",
|
||||
'exit_reason_list': "all",
|
||||
'indicator_list': "bb_upperband,ema_10"
|
||||
'indicator_list': "rsi"
|
||||
})
|
||||
patch_exchange(mocker)
|
||||
result1 = pd.DataFrame({'pair': ['ETH/BTC', 'LTC/BTC'],
|
||||
@ -84,6 +93,7 @@ def test_backtest_analysis_nomock(default_conf, mocker, caplog, testdatadir, cap
|
||||
'--config', 'config.json',
|
||||
'--datadir', str(testdatadir),
|
||||
'--analysis_groups', '0',
|
||||
'--indicator_list', 'rsi',
|
||||
'--strategy',
|
||||
'StrategyTestV3Analysis',
|
||||
]
|
||||
@ -92,3 +102,6 @@ def test_backtest_analysis_nomock(default_conf, mocker, caplog, testdatadir, cap
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert 'enter_tag_long' in captured.out
|
||||
assert '34.049' in captured.out
|
||||
|
||||
Backtesting.cleanup()
|
||||
|
Loading…
Reference in New Issue
Block a user