Improve some tests

This commit is contained in:
Matthias 2019-06-16 19:53:48 +02:00
parent fc3e3c468c
commit 0eb109f8f7
3 changed files with 26 additions and 7 deletions

View File

@ -528,8 +528,8 @@ class Arguments(object):
) )
self.parser.add_argument( self.parser.add_argument(
'--indicators1', '--indicators1',
help='Set indicators from your strategy you want in the first row of the graph. Separate ' help='Set indicators from your strategy you want in the first row of the graph. '
'them with a comma. E.g: ema3,ema5 (default: %(default)s)', 'Separate them with a comma. E.g: ema3,ema5 (default: %(default)s)',
type=str, type=str,
default='sma,ema3,ema5', default='sma,ema3,ema5',
dest='indicators1', dest='indicators1',
@ -537,8 +537,8 @@ class Arguments(object):
self.parser.add_argument( self.parser.add_argument(
'--indicators2', '--indicators2',
help='Set indicators from your strategy you want in the third row of the graph. Separate ' help='Set indicators from your strategy you want in the third row of the graph. '
'them with a comma. E.g: macd,fastd,fastk (default: %(default)s)', 'Separate them with a comma. E.g: macd,fastd,fastk (default: %(default)s)',
type=str, type=str,
default='macd,macdsignal', default='macd,macdsignal',
dest='indicators2', dest='indicators2',

View File

@ -5,8 +5,9 @@ from plotly import tools
import plotly.graph_objs as go import plotly.graph_objs as go
from copy import deepcopy from copy import deepcopy
from freqtrade.arguments import Arguments, TimeRange from freqtrade.arguments import TimeRange
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.btanalysis import load_backtest_data
from freqtrade.plot.plotting import (generate_graph, generate_plot_file, from freqtrade.plot.plotting import (generate_graph, generate_plot_file,
generate_row, plot_trades) generate_row, plot_trades)
from freqtrade.strategy.default_strategy import DefaultStrategy from freqtrade.strategy.default_strategy import DefaultStrategy
@ -71,8 +72,26 @@ def test_plot_trades():
# nothing happens when no trades are available # nothing happens when no trades are available
fig = plot_trades(fig1, None) fig = plot_trades(fig1, None)
assert fig == fig1 assert fig == fig1
pair = "ADA/BTC"
filename = history.make_testdata_path(None) / "backtest-result_test.json"
trades = load_backtest_data(filename)
trades = trades.loc[trades['pair'] == pair]
# TODO: implement tests that do something fig = plot_trades(fig, trades)
figure = fig1.layout.figure
# Check buys - color, should be in first graph, ...
trade_buy = find_trace_in_fig_data(figure.data, "trade_buy")
assert isinstance(trade_buy, go.Scatter)
assert trade_buy.yaxis == 'y'
assert len(trades) == len(trade_buy.x)
assert trade_buy.marker.color == 'green'
trade_sell = find_trace_in_fig_data(figure.data, "trade_sell")
assert isinstance(trade_sell, go.Scatter)
assert trade_sell.yaxis == 'y'
assert len(trades) == len(trade_sell.x)
assert trade_sell.marker.color == 'red'
def test_generate_graph_no_signals_no_trades(default_conf, mocker, caplog): def test_generate_graph_no_signals_no_trades(default_conf, mocker, caplog):

View File

@ -141,7 +141,7 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
logger.info('End of ploting process %s plots generated', pair_counter) logger.info('End of ploting process %s plots generated', pair_counter)
def plot_parse_args(args: List[str]) -> Namespace: def plot_parse_args(args: List[str]) -> Dict[str, Any]:
""" """
Parse args passed to the script Parse args passed to the script
:param args: Cli arguments :param args: Cli arguments