From 395414ccde7a426ea9d696ef902bbaacc8587937 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 22 Aug 2019 20:32:06 +0200 Subject: [PATCH] Refactor init_plotscript a bit (strategy is not needed for plot_profit) --- freqtrade/configuration/arguments.py | 5 +++-- freqtrade/plot/plotting.py | 15 +++++++++------ freqtrade/tests/test_plotting.py | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index 794e8466d..4bd4410a6 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -35,9 +35,10 @@ ARGS_CREATE_USERDIR = ["user_data_dir"] ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "exchange", "timeframes", "erase"] ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", "db_url", - "trade_source", "export", "exportfilename", "timerange"] + "trade_source", "export", "exportfilename", "timerange", "ticker_interval"] -ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source"] +ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", + "trade_source", "ticker_interval"] NO_CONF_REQURIED = ["start_download_data"] diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index 900e9e90c..5966f8ae9 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -26,10 +26,9 @@ except ImportError: def init_plotscript(config): """ Initialize objects needed for plotting - :return: Dict with tickers, trades, pairs and strategy + :return: Dict with tickers, trades and pairs """ - strategy = StrategyResolver(config).strategy if "pairs" in config: pairs = config["pairs"] else: @@ -41,7 +40,7 @@ def init_plotscript(config): tickers = history.load_data( datadir=Path(str(config.get("datadir"))), pairs=pairs, - ticker_interval=config['ticker_interval'], + ticker_interval=config.get('ticker_interval', '5m'), timerange=timerange, ) @@ -49,10 +48,10 @@ def init_plotscript(config): db_url=config.get('db_url'), exportfilename=config.get('exportfilename'), ) + return {"tickers": tickers, "trades": trades, "pairs": pairs, - "strategy": strategy, } @@ -329,9 +328,10 @@ def analyse_and_plot_pairs(config: Dict[str, Any]): - Generate plot files :return: None """ + strategy = StrategyResolver(config).strategy + plot_elements = init_plotscript(config) trades = plot_elements['trades'] - strategy = plot_elements["strategy"] pair_counter = 0 for pair, data in plot_elements["tickers"].items(): @@ -367,7 +367,10 @@ def plot_profit(config: Dict[str, Any]) -> None: in helping out to find a good algorithm. """ plot_elements = init_plotscript(config) - trades = plot_elements['trades'] + trades = load_trades(config['trade_source'], + db_url=config.get('db_url'), + exportfilename=config.get('exportfilename'), + ) # Filter trades to relevant pairs trades = trades[trades['pair'].isin(plot_elements["pairs"])] diff --git a/freqtrade/tests/test_plotting.py b/freqtrade/tests/test_plotting.py index 2790fc7db..9f53809d1 100644 --- a/freqtrade/tests/test_plotting.py +++ b/freqtrade/tests/test_plotting.py @@ -51,7 +51,6 @@ def test_init_plotscript(default_conf, mocker): assert "tickers" in ret assert "trades" in ret assert "pairs" in ret - assert "strategy" in ret default_conf['pairs'] = ["POWR/BTC", "XLM/BTC"] ret = init_plotscript(default_conf)