mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Add initial plotting test
This commit is contained in:
parent
cae2185460
commit
2891d7cccb
|
@ -91,7 +91,7 @@ def generate_graph(
|
|||
trades: pd.DataFrame = None,
|
||||
indicators1: List[str] = [],
|
||||
indicators2: List[str] = [],
|
||||
) -> tools.make_subplots:
|
||||
) -> go.Figure:
|
||||
"""
|
||||
Generate the graph from the data generated by Backtesting or from DB
|
||||
Volume will always be ploted in row2, so Row 1 and are to our disposal for custom indicators
|
||||
|
|
52
freqtrade/tests/test_plotting.py
Normal file
52
freqtrade/tests/test_plotting.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import plotly.graph_objs as go
|
||||
|
||||
from freqtrade.arguments import Arguments, TimeRange
|
||||
from freqtrade.data import history
|
||||
from freqtrade.plot.plotting import (generate_graph, generate_plot_file,
|
||||
generate_row, plot_trades)
|
||||
|
||||
|
||||
def fig_generating_mock(fig, *args, **kwargs):
|
||||
""" Return Fig - used to mock generate_row and plot_trades"""
|
||||
return fig
|
||||
|
||||
|
||||
def test_generate_row():
|
||||
# TODO: implement me
|
||||
pass
|
||||
|
||||
|
||||
def test_plot_trades():
|
||||
# TODO: implement me
|
||||
pass
|
||||
|
||||
|
||||
def test_generate_graph(default_conf, mocker):
|
||||
row_mock = mocker.patch('freqtrade.plot.plotting.generate_row',
|
||||
MagicMock(side_effect=fig_generating_mock))
|
||||
trades_mock = mocker.patch('freqtrade.plot.plotting.plot_trades',
|
||||
MagicMock(side_effect=fig_generating_mock))
|
||||
|
||||
timerange = TimeRange(None, 'line', 0, -100)
|
||||
data = history.load_pair_history(pair='UNITTEST/BTC', ticker_interval='1m',
|
||||
datadir=None, timerange=timerange)
|
||||
|
||||
indicators1 = []
|
||||
indicators2 = []
|
||||
fig = generate_graph(pair="UNITTEST/BTC", data=data, trades=None,
|
||||
indicators1=indicators1, indicators2=indicators2)
|
||||
assert isinstance(fig, go.Figure)
|
||||
assert fig.layout.title.text == "UNITTEST/BTC"
|
||||
figure = fig.layout.figure
|
||||
# Candlesticks are plotted first
|
||||
assert isinstance(figure.data[0], go.Candlestick)
|
||||
assert figure.data[0].name == "Price"
|
||||
|
||||
assert isinstance(figure.data[1], go.Bar)
|
||||
assert figure.data[1].name == "Volume"
|
||||
|
||||
assert row_mock.call_count == 2
|
||||
assert trades_mock.call_count == 1
|
|
@ -32,7 +32,6 @@ from typing import Any, Dict, List
|
|||
|
||||
import pandas as pd
|
||||
import pytz
|
||||
from plotly.offline import plot
|
||||
|
||||
from freqtrade import persistence
|
||||
from freqtrade.arguments import Arguments, TimeRange
|
||||
|
@ -87,7 +86,6 @@ def load_trades(db_url: str = None, exportfilename: str = None) -> pd.DataFrame:
|
|||
return trades
|
||||
|
||||
|
||||
|
||||
def get_trading_env(args: Namespace):
|
||||
"""
|
||||
Initalize freqtrade Exchange and Strategy, split pairs recieved in parameter
|
||||
|
@ -132,7 +130,7 @@ def get_tickers_data(strategy, exchange, pairs: List[str], timerange: TimeRange,
|
|||
refresh_pairs=_CONF.get('refresh_pairs', False),
|
||||
timerange=timerange,
|
||||
exchange=Exchange(_CONF),
|
||||
live=args.live,
|
||||
live=live,
|
||||
)
|
||||
|
||||
# No ticker found, impossible to download, len mismatch
|
||||
|
|
Loading…
Reference in New Issue
Block a user