diff --git a/freqtrade/configuration/folder_operations.py b/freqtrade/configuration/folder_operations.py index d43dd1bf1..2ea9cd268 100644 --- a/freqtrade/configuration/folder_operations.py +++ b/freqtrade/configuration/folder_operations.py @@ -33,4 +33,4 @@ def create_userdata_dir(directory: str) -> str: if not subfolder.is_dir(): subfolder.mkdir(parents=False) # TODO: convert this to return Path - return str(folder.resolve()) + return folder diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index dde6f78f0..948964462 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -308,7 +308,7 @@ def generate_plot_filename(pair, ticker_interval) -> str: return file_name -def store_plot_file(fig, filename: str, auto_open: bool = False) -> None: +def store_plot_file(fig, filename: str, folder: Path, auto_open: bool = False) -> None: """ Generate a plot html file from pre populated fig plotly object :param fig: Plotly Figure to plot @@ -317,7 +317,7 @@ def store_plot_file(fig, filename: str, auto_open: bool = False) -> None: :return: None """ - Path("user_data/plots").mkdir(parents=True, exist_ok=True) + folder.mkdir(parents=True, exist_ok=True) - plot(fig, filename=str(Path('user_data/plots').joinpath(filename)), + plot(fig, filename=str(folder.joinpath(filename)), auto_open=auto_open) diff --git a/freqtrade/tests/test_plotting.py b/freqtrade/tests/test_plotting.py index 0ebadf720..c80d0e780 100644 --- a/freqtrade/tests/test_plotting.py +++ b/freqtrade/tests/test_plotting.py @@ -1,5 +1,6 @@ from copy import deepcopy +from pathlib import Path from unittest.mock import MagicMock import plotly.graph_objs as go @@ -209,7 +210,8 @@ def test_generate_Plot_filename(): def test_generate_plot_file(mocker, caplog): fig = generage_empty_figure() plot_mock = mocker.patch("freqtrade.plot.plotting.plot", MagicMock()) - store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html") + store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html", + folder=Path("user_data/plots")) assert plot_mock.call_count == 1 assert plot_mock.call_args[0][0] == fig diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index 034a6f448..04911f93e 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -77,7 +77,8 @@ def analyse_and_plot_pairs(config: Dict[str, Any]): indicators2=config["indicators2"].split(",") ) - store_plot_file(fig, generate_plot_filename(pair, config['ticker_interval'])) + store_plot_file(fig, filename=generate_plot_filename(pair, config['ticker_interval']), + folder=config['user_data_dir'] / "plot") logger.info('End of ploting process %s plots generated', pair_counter) diff --git a/scripts/plot_profit.py b/scripts/plot_profit.py index 4290bca45..c83ad1088 100755 --- a/scripts/plot_profit.py +++ b/scripts/plot_profit.py @@ -32,7 +32,8 @@ def plot_profit(config: Dict[str, Any]) -> None: # Create an average close price of all the pairs that were involved. # this could be useful to gauge the overall market trend fig = generate_profit_graph(plot_elements["pairs"], plot_elements["tickers"], trades) - store_plot_file(fig, filename='freqtrade-profit-plot.html', auto_open=True) + store_plot_file(fig, filename='freqtrade-profit-plot.html', + folder=config['user_data_dir'] / "plot", auto_open=True) def plot_parse_args(args: List[str]) -> Dict[str, Any]: