Adapt tests to new add_indicator methodology
This commit is contained in:
parent
f04873b0b0
commit
4628024de6
@ -177,6 +177,7 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str], plot_confi
|
|||||||
|
|
||||||
if 'subplots' not in plot_config:
|
if 'subplots' not in plot_config:
|
||||||
plot_config['subplots'] = {}
|
plot_config['subplots'] = {}
|
||||||
|
return plot_config
|
||||||
|
|
||||||
|
|
||||||
def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFrame = None, *,
|
def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFrame = None, *,
|
||||||
@ -195,7 +196,7 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
|
|||||||
:param plot_config: Dict of Dicts containing advanced plot configuration
|
:param plot_config: Dict of Dicts containing advanced plot configuration
|
||||||
:return: Plotly figure
|
:return: Plotly figure
|
||||||
"""
|
"""
|
||||||
plot_config = create_plotconfig(indicators1, indicators2)
|
plot_config = create_plotconfig(indicators1, indicators2, plot_config)
|
||||||
|
|
||||||
rows = 2 + len(plot_config['subplots'])
|
rows = 2 + len(plot_config['subplots'])
|
||||||
row_widths = [1 for _ in plot_config['subplots']]
|
row_widths = [1 for _ in plot_config['subplots']]
|
||||||
|
@ -66,8 +66,8 @@ def test_add_indicators(default_conf, testdatadir, caplog):
|
|||||||
|
|
||||||
data = history.load_pair_history(pair=pair, timeframe='1m',
|
data = history.load_pair_history(pair=pair, timeframe='1m',
|
||||||
datadir=testdatadir, timerange=timerange)
|
datadir=testdatadir, timerange=timerange)
|
||||||
indicators1 = ["ema10"]
|
indicators1 = {"ema10": {}}
|
||||||
indicators2 = ["macd"]
|
indicators2 = {"macd": {"color": "red"}}
|
||||||
|
|
||||||
# Generate buy/sell signals and indicators
|
# Generate buy/sell signals and indicators
|
||||||
strat = DefaultStrategy(default_conf)
|
strat = DefaultStrategy(default_conf)
|
||||||
@ -86,9 +86,10 @@ def test_add_indicators(default_conf, testdatadir, caplog):
|
|||||||
macd = find_trace_in_fig_data(figure.data, "macd")
|
macd = find_trace_in_fig_data(figure.data, "macd")
|
||||||
assert isinstance(macd, go.Scatter)
|
assert isinstance(macd, go.Scatter)
|
||||||
assert macd.yaxis == "y3"
|
assert macd.yaxis == "y3"
|
||||||
|
assert macd.line.color == "red"
|
||||||
|
|
||||||
# No indicator found
|
# No indicator found
|
||||||
fig3 = add_indicators(fig=deepcopy(fig), row=3, indicators=['no_indicator'], data=data)
|
fig3 = add_indicators(fig=deepcopy(fig), row=3, indicators={'no_indicator': {}}, data=data)
|
||||||
assert fig == fig3
|
assert fig == fig3
|
||||||
assert log_has_re(r'Indicator "no_indicator" ignored\..*', caplog)
|
assert log_has_re(r'Indicator "no_indicator" ignored\..*', caplog)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user