Skip to content

Commit

Permalink
Add some initial tests for plot_dataframe
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 24, 2019
1 parent 69c2b12 commit f8c72fe
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
6 changes: 2 additions & 4 deletions freqtrade/configuration/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@

ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "exchange", "timeframes", "erase"]

ARGS_PLOT_DATAFRAME = (ARGS_COMMON + ARGS_STRATEGY +
["pairs", "indicators1", "indicators2", "plot_limit", "db_url",
"trade_source", "export", "exportfilename", "timerange",
"refresh_pairs"])
ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", "db_url",
"trade_source", "export", "exportfilename", "timerange", "refresh_pairs"]

ARGS_PLOT_PROFIT = (ARGS_COMMON + ARGS_STRATEGY +
["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source"])
Expand Down
2 changes: 1 addition & 1 deletion freqtrade/plot/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def start_plot_dataframe(args: Namespace) -> None:
"""
Plotting dataframe
Plotting dataframe helper
"""
# Import here to avoid errors if plot-dependencies are not installed.
from freqtrade.plot.plotting import analyse_and_plot_pairs
Expand Down
10 changes: 5 additions & 5 deletions freqtrade/plot/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
"""
From configuration provided
- Initializes plot-script
-Get tickers data
-Generate Dafaframes populated with indicators and signals
-Load trades excecuted on same periods
-Generate Plotly plot objects
-Generate plot files
- Get tickers data
- Generate Dafaframes populated with indicators and signals based on configured strategy
- Load trades excecuted during the selected period
- Generate Plotly plot objects
- Generate plot files
:return: None
"""
plot_elements = init_plotscript(config)
Expand Down
18 changes: 17 additions & 1 deletion freqtrade/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from freqtrade.configuration import TimeRange
from freqtrade.data import history
from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data
from freqtrade.plot.plot_utils import start_plot_dataframe
from freqtrade.plot.plotting import (add_indicators, add_profit,
generate_candlestick_graph,
generate_plot_filename,
generate_profit_graph, init_plotscript,
plot_trades, store_plot_file)
from freqtrade.strategy.default_strategy import DefaultStrategy
from freqtrade.tests.conftest import log_has, log_has_re
from freqtrade.tests.conftest import get_args, log_has, log_has_re


def fig_generating_mock(fig, *args, **kwargs):
Expand Down Expand Up @@ -270,3 +271,18 @@ def test_generate_profit_graph():
for pair in pairs:
profit_pair = find_trace_in_fig_data(figure.data, f"Profit {pair}")
assert isinstance(profit_pair, go.Scattergl)


def test_start_plot_dataframe(mocker):
aup = mocker.patch("freqtrade.plot.plotting.analyse_and_plot_pairs", MagicMock())
args = [
"--config", "config.json.example",
"plot-dataframe",
"--pairs", "ETH/BTC"
]
start_plot_dataframe(get_args(args))

assert aup.call_count == 1
called_config = aup.call_args_list[0][0][0]
assert "pairs" in called_config
assert called_config['pairs'] == ["ETH/BTC"]

0 comments on commit f8c72fe

Please sign in to comment.