Move make_testdata_path to conftest
This commit is contained in:
parent
df481eb642
commit
bde82e9654
@ -1047,3 +1047,8 @@ def rpc_balance():
|
|||||||
'used': 0.0
|
'used': 0.0
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_testdata_path(datadir) -> Path:
|
||||||
|
"""Return the path where testdata files are stored"""
|
||||||
|
return (Path(__file__).parent / "testdata").resolve()
|
||||||
|
@ -11,8 +11,8 @@ from freqtrade.data.btanalysis import (BT_DATA_COLUMNS,
|
|||||||
extract_trades_of_period,
|
extract_trades_of_period,
|
||||||
load_backtest_data, load_trades,
|
load_backtest_data, load_trades,
|
||||||
load_trades_from_db)
|
load_trades_from_db)
|
||||||
from freqtrade.data.history import (load_data, load_pair_history,
|
from freqtrade.data.history import load_data, load_pair_history
|
||||||
make_testdata_path)
|
from freqtrade.tests.conftest import make_testdata_path
|
||||||
from freqtrade.tests.test_persistence import create_mock_trades
|
from freqtrade.tests.test_persistence import create_mock_trades
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,14 +16,14 @@ from freqtrade.configuration import TimeRange
|
|||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.history import (download_pair_history,
|
from freqtrade.data.history import (download_pair_history,
|
||||||
load_cached_data_for_updating,
|
load_cached_data_for_updating,
|
||||||
load_tickerdata_file, make_testdata_path,
|
load_tickerdata_file,
|
||||||
refresh_backtest_ohlcv_data,
|
refresh_backtest_ohlcv_data,
|
||||||
trim_tickerlist)
|
trim_tickerlist)
|
||||||
from freqtrade.exchange import timeframe_to_minutes
|
from freqtrade.exchange import timeframe_to_minutes
|
||||||
from freqtrade.misc import file_dump_json
|
from freqtrade.misc import file_dump_json
|
||||||
from freqtrade.strategy.default_strategy import DefaultStrategy
|
from freqtrade.strategy.default_strategy import DefaultStrategy
|
||||||
from freqtrade.tests.conftest import (get_patched_exchange, log_has,
|
from freqtrade.tests.conftest import (get_patched_exchange, log_has,
|
||||||
patch_exchange)
|
patch_exchange, make_testdata_path)
|
||||||
|
|
||||||
# Change this if modifying UNITTEST/BTC testdatafile
|
# Change this if modifying UNITTEST/BTC testdatafile
|
||||||
_BTC_UNITTEST_LENGTH = 13681
|
_BTC_UNITTEST_LENGTH = 13681
|
||||||
|
@ -19,7 +19,8 @@ from freqtrade.plot.plotting import (add_indicators, add_profit,
|
|||||||
generate_profit_graph, init_plotscript,
|
generate_profit_graph, init_plotscript,
|
||||||
plot_profit, plot_trades, store_plot_file)
|
plot_profit, plot_trades, store_plot_file)
|
||||||
from freqtrade.strategy.default_strategy import DefaultStrategy
|
from freqtrade.strategy.default_strategy import DefaultStrategy
|
||||||
from freqtrade.tests.conftest import get_args, log_has, log_has_re
|
from freqtrade.tests.conftest import (get_args, log_has, log_has_re,
|
||||||
|
make_testdata_path)
|
||||||
|
|
||||||
|
|
||||||
def fig_generating_mock(fig, *args, **kwargs):
|
def fig_generating_mock(fig, *args, **kwargs):
|
||||||
@ -46,9 +47,8 @@ def test_init_plotscript(default_conf, mocker):
|
|||||||
default_conf['timerange'] = "20180110-20180112"
|
default_conf['timerange'] = "20180110-20180112"
|
||||||
default_conf['trade_source'] = "file"
|
default_conf['trade_source'] = "file"
|
||||||
default_conf['ticker_interval'] = "5m"
|
default_conf['ticker_interval'] = "5m"
|
||||||
default_conf["datadir"] = history.make_testdata_path(None)
|
default_conf["datadir"] = make_testdata_path(None)
|
||||||
default_conf['exportfilename'] = str(
|
default_conf['exportfilename'] = str(make_testdata_path(None) / "backtest-result_test.json")
|
||||||
history.make_testdata_path(None) / "backtest-result_test.json")
|
|
||||||
ret = init_plotscript(default_conf)
|
ret = init_plotscript(default_conf)
|
||||||
assert "tickers" in ret
|
assert "tickers" in ret
|
||||||
assert "trades" in ret
|
assert "trades" in ret
|
||||||
@ -101,7 +101,7 @@ def test_plot_trades(caplog):
|
|||||||
assert fig == fig1
|
assert fig == fig1
|
||||||
assert log_has("No trades found.", caplog)
|
assert log_has("No trades found.", caplog)
|
||||||
pair = "ADA/BTC"
|
pair = "ADA/BTC"
|
||||||
filename = history.make_testdata_path(None) / "backtest-result_test.json"
|
filename = make_testdata_path(None) / "backtest-result_test.json"
|
||||||
trades = load_backtest_data(filename)
|
trades = load_backtest_data(filename)
|
||||||
trades = trades.loc[trades['pair'] == pair]
|
trades = trades.loc[trades['pair'] == pair]
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ def test_generate_plot_file(mocker, caplog):
|
|||||||
|
|
||||||
|
|
||||||
def test_add_profit():
|
def test_add_profit():
|
||||||
filename = history.make_testdata_path(None) / "backtest-result_test.json"
|
filename = make_testdata_path(None) / "backtest-result_test.json"
|
||||||
bt_data = load_backtest_data(filename)
|
bt_data = load_backtest_data(filename)
|
||||||
timerange = TimeRange.parse_timerange("20180110-20180112")
|
timerange = TimeRange.parse_timerange("20180110-20180112")
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ def test_add_profit():
|
|||||||
|
|
||||||
|
|
||||||
def test_generate_profit_graph():
|
def test_generate_profit_graph():
|
||||||
filename = history.make_testdata_path(None) / "backtest-result_test.json"
|
filename = make_testdata_path(None) / "backtest-result_test.json"
|
||||||
trades = load_backtest_data(filename)
|
trades = load_backtest_data(filename)
|
||||||
timerange = TimeRange.parse_timerange("20180110-20180112")
|
timerange = TimeRange.parse_timerange("20180110-20180112")
|
||||||
pairs = ["POWR/BTC", "XLM/BTC"]
|
pairs = ["POWR/BTC", "XLM/BTC"]
|
||||||
@ -296,9 +296,8 @@ def test_start_plot_dataframe(mocker):
|
|||||||
|
|
||||||
def test_analyse_and_plot_pairs(default_conf, mocker, caplog):
|
def test_analyse_and_plot_pairs(default_conf, mocker, caplog):
|
||||||
default_conf['trade_source'] = 'file'
|
default_conf['trade_source'] = 'file'
|
||||||
default_conf["datadir"] = history.make_testdata_path(None)
|
default_conf["datadir"] = make_testdata_path(None)
|
||||||
default_conf['exportfilename'] = str(
|
default_conf['exportfilename'] = str(make_testdata_path(None) / "backtest-result_test.json")
|
||||||
history.make_testdata_path(None) / "backtest-result_test.json")
|
|
||||||
default_conf['indicators1'] = ["sma5", "ema10"]
|
default_conf['indicators1'] = ["sma5", "ema10"]
|
||||||
default_conf['indicators2'] = ["macd"]
|
default_conf['indicators2'] = ["macd"]
|
||||||
default_conf['pairs'] = ["ETH/BTC", "LTC/BTC"]
|
default_conf['pairs'] = ["ETH/BTC", "LTC/BTC"]
|
||||||
@ -348,9 +347,8 @@ def test_start_plot_profit_error(mocker):
|
|||||||
|
|
||||||
def test_plot_profit(default_conf, mocker, caplog):
|
def test_plot_profit(default_conf, mocker, caplog):
|
||||||
default_conf['trade_source'] = 'file'
|
default_conf['trade_source'] = 'file'
|
||||||
default_conf["datadir"] = history.make_testdata_path(None)
|
default_conf["datadir"] = make_testdata_path(None)
|
||||||
default_conf['exportfilename'] = str(
|
default_conf['exportfilename'] = str(make_testdata_path(None) / "backtest-result_test.json")
|
||||||
history.make_testdata_path(None) / "backtest-result_test.json")
|
|
||||||
default_conf['pairs'] = ["ETH/BTC", "LTC/BTC"]
|
default_conf['pairs'] = ["ETH/BTC", "LTC/BTC"]
|
||||||
|
|
||||||
profit_mock = MagicMock()
|
profit_mock = MagicMock()
|
||||||
|
Loading…
Reference in New Issue
Block a user