Add test for load_backtest_data
This commit is contained in:
parent
ddb9933c91
commit
a123246ac9
21
freqtrade/tests/data/test_btanalysis.py
Normal file
21
freqtrade/tests/data/test_btanalysis.py
Normal file
@ -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")
|
@ -14,8 +14,8 @@ from arrow import Arrow
|
|||||||
from freqtrade import DependencyException, constants
|
from freqtrade import DependencyException, constants
|
||||||
from freqtrade.arguments import Arguments, TimeRange
|
from freqtrade.arguments import Arguments, TimeRange
|
||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.converter import parse_ticker_dataframe
|
|
||||||
from freqtrade.data.btanalysis import evaluate_result_multi
|
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 import get_timeframe
|
||||||
from freqtrade.optimize.backtesting import (Backtesting, setup_configuration,
|
from freqtrade.optimize.backtesting import (Backtesting, setup_configuration,
|
||||||
start)
|
start)
|
||||||
|
Loading…
Reference in New Issue
Block a user