diff --git a/freqtrade/tests/data/test_btanalysis.py b/freqtrade/tests/data/test_btanalysis.py new file mode 100644 index 000000000..dd7cbe0d9 --- /dev/null +++ b/freqtrade/tests/data/test_btanalysis.py @@ -0,0 +1,21 @@ +import pytest +from pandas import DataFrame + +from freqtrade.data.btanalysis import BT_DATA_COLUMNS, load_backtest_data +from freqtrade.data.history import make_testdata_path + + +def test_load_backtest_data(): + + filename = make_testdata_path(None) / "backtest-result_test.json" + bt_data = load_backtest_data(filename) + assert isinstance(bt_data, DataFrame) + assert list(bt_data.columns) == BT_DATA_COLUMNS + ["profitabs"] + assert len(bt_data) == 179 + + # Test loading from string (must yield same result) + bt_data2 = load_backtest_data(str(filename)) + assert bt_data.equals(bt_data2) + + with pytest.raises(ValueError, match=r"File .* does not exist\."): + load_backtest_data(str("filename") + "nofile") diff --git a/freqtrade/tests/optimize/test_backtesting.py b/freqtrade/tests/optimize/test_backtesting.py index ea3aa95b3..40754cfbc 100644 --- a/freqtrade/tests/optimize/test_backtesting.py +++ b/freqtrade/tests/optimize/test_backtesting.py @@ -14,8 +14,8 @@ from arrow import Arrow from freqtrade import DependencyException, constants from freqtrade.arguments import Arguments, TimeRange from freqtrade.data import history -from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.data.btanalysis import evaluate_result_multi +from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.optimize import get_timeframe from freqtrade.optimize.backtesting import (Backtesting, setup_configuration, start)