fixed: too complex warning
This commit is contained in:
parent
d901a86165
commit
16baca5eeb
@ -263,10 +263,10 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str],
|
|||||||
return plot_config
|
return plot_config
|
||||||
|
|
||||||
|
|
||||||
def add_filled_traces(fig, row: int, data: pd.DataFrame, indicator_a: str,
|
def plot_area_between(fig, row: int, data: pd.DataFrame, indicator_a: str,
|
||||||
indicator_b: str, label: str = "",
|
indicator_b: str, label: str = "",
|
||||||
fill_color: str = "rgba(0,176,246,0.2)") -> make_subplots:
|
fill_color: str = "rgba(0,176,246,0.2)") -> make_subplots:
|
||||||
""" Adds plots for two traces, which are filled between to fig.
|
""" Plots the area between two traces and adds it to fig.
|
||||||
:param fig: Plot figure to append to
|
:param fig: Plot figure to append to
|
||||||
:param row: row number for this plot
|
:param row: row number for this plot
|
||||||
:param data: candlestick DataFrame
|
:param data: candlestick DataFrame
|
||||||
@ -290,6 +290,25 @@ def add_filled_traces(fig, row: int, data: pd.DataFrame, indicator_a: str,
|
|||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
|
def add_areas(fig, row: int, data: pd.DataFrame, indicators) -> make_subplots:
|
||||||
|
""" Adds all areas (from plot_config) to fig.
|
||||||
|
:param fig: Plot figure to append to
|
||||||
|
:param row: row number for this plot
|
||||||
|
:param data: candlestick DataFrame
|
||||||
|
:param indicators: dict with indicators. ie.: plot_config['main_plot'] or
|
||||||
|
plot_config['subplots'][subplot_label]
|
||||||
|
:return: fig with added filled_traces plot
|
||||||
|
"""
|
||||||
|
for indicator, ind_conf in indicators.items():
|
||||||
|
if 'fill_to' in ind_conf:
|
||||||
|
label = ind_conf.get('fill_label', '')
|
||||||
|
fill_color = ind_conf.get('fill_color', 'rgba(0,176,246,0.2)')
|
||||||
|
fig = plot_area_between(fig, row, data, indicator,
|
||||||
|
ind_conf['fill_to'], label=label,
|
||||||
|
fill_color=fill_color)
|
||||||
|
return fig
|
||||||
|
|
||||||
|
|
||||||
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, *,
|
||||||
indicators1: List[str] = [],
|
indicators1: List[str] = [],
|
||||||
indicators2: List[str] = [],
|
indicators2: List[str] = [],
|
||||||
@ -373,8 +392,8 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
|
|||||||
else:
|
else:
|
||||||
logger.warning("No sell-signals found.")
|
logger.warning("No sell-signals found.")
|
||||||
|
|
||||||
# Add Boilinger Bands
|
# Add Bollinger Bands
|
||||||
fig = add_filled_traces(fig, 1, data, 'bb_lowerband', 'bb_upperband',
|
fig = plot_area_between(fig, 1, data, 'bb_lowerband', 'bb_upperband',
|
||||||
label="Bollinger Band")
|
label="Bollinger Band")
|
||||||
# prevent bb_lower and bb_upper from plotting
|
# prevent bb_lower and bb_upper from plotting
|
||||||
try:
|
try:
|
||||||
@ -385,15 +404,8 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
|
|||||||
|
|
||||||
# Add indicators to main plot
|
# Add indicators to main plot
|
||||||
fig = add_indicators(fig=fig, row=1, indicators=plot_config['main_plot'], data=data)
|
fig = add_indicators(fig=fig, row=1, indicators=plot_config['main_plot'], data=data)
|
||||||
|
|
||||||
# fill area between indicators ( 'fill_to': 'other_indicator')
|
# fill area between indicators ( 'fill_to': 'other_indicator')
|
||||||
for indicator, ind_conf in plot_config['main_plot'].items():
|
fig = add_areas(fig, 1, data, plot_config['main_plot'])
|
||||||
if 'fill_to' in ind_conf:
|
|
||||||
label = ind_conf.get('fill_label', '')
|
|
||||||
fill_color = ind_conf.get('fill_color', 'rgba(0,176,246,0.2)')
|
|
||||||
fig = add_filled_traces(fig, 1, data, indicator,
|
|
||||||
ind_conf['fill_to'], label=label,
|
|
||||||
fill_color=fill_color)
|
|
||||||
|
|
||||||
fig = plot_trades(fig, trades)
|
fig = plot_trades(fig, trades)
|
||||||
|
|
||||||
@ -413,15 +425,9 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
|
|||||||
row = 3 + i
|
row = 3 + i
|
||||||
fig = add_indicators(fig=fig, row=row, indicators=sub_config,
|
fig = add_indicators(fig=fig, row=row, indicators=sub_config,
|
||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
# fill area between indicators ( 'fill_to': 'other_indicator')
|
# fill area between indicators ( 'fill_to': 'other_indicator')
|
||||||
for indicator, ind_config in sub_config.items():
|
fig = add_areas(fig, row, data, sub_config)
|
||||||
if 'fill_to' in ind_config:
|
|
||||||
label = ind_config.get('fill_label', '')
|
|
||||||
fill_color = ind_config.get('fill_color', 'rgba(0,176,246,0.2)')
|
|
||||||
fig = add_filled_traces(fig, row, data, indicator,
|
|
||||||
ind_config['fill_to'], label=label,
|
|
||||||
fill_color=fill_color)
|
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user