This commit is contained in:
Christof 2020-05-25 09:05:24 +02:00
parent fb3d82ccb9
commit 4531c924da

View File

@ -237,7 +237,7 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str],
:return: plot_config - eventually with indicators 1 and 2 :return: plot_config - eventually with indicators 1 and 2
""" """
if plot_config: if plot_config:
#maybe main or sub is given, not both. # maybe main or sub is given, not both.
if 'main_plot' not in plot_config.keys(): if 'main_plot' not in plot_config.keys():
plot_config['main_plot'] = {} plot_config['main_plot'] = {}
@ -245,15 +245,15 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str],
plot_config['subplots'] = {} plot_config['subplots'] = {}
if indicators1: if indicators1:
for ind in indicators1: for ind in indicators1:
#add indicators with NO advanced plot_config, only! to be sure # add indicators with NO advanced plot_config, only! to be sure
#indicator colors given in advanced plot_config will not be # indicator colors given in advanced plot_config will not be
#overwritten. # overwritten.
if ind not in plot_config['main_plot'].keys(): if ind not in plot_config['main_plot'].keys():
plot_config['main_plot'][ind] = {} plot_config['main_plot'][ind] = {}
if indicators2: if indicators2:
#add other indicators given on cmd line to advanced plot_config. # add other indicators given on cmd line to advanced plot_config.
plot_config['subplots'].update( plot_config['subplots'].update(
{'Other' : {ind : {} for ind in indicators2}} {'Other': {ind: {} for ind in indicators2}}
) )
if not plot_config: if not plot_config:
@ -378,15 +378,15 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
del plot_config['main_plot']['bb_upperband'] del plot_config['main_plot']['bb_upperband']
del plot_config['main_plot']['bb_lowerband'] del plot_config['main_plot']['bb_lowerband']
#fill area betwenn traces i.e. for ichimoku # fill area betwenn traces i.e. for ichimoku
if 'fill_area' in plot_config.keys(): if 'fill_area' in plot_config.keys():
for label, area in plot_config['fill_area'].items(): for label, area in plot_config['fill_area'].items():
traces = area['traces'] traces = area['traces']
if len(traces) != 2: if len(traces) != 2:
raise Exception( raise Exception(
f"plot_config.fill_area.traces = {traces}: " \ f"plot_config.fill_area.traces = {traces}: " +
+ f"needs exactly 2 indicators. " \ f"needs exactly 2 indicators. " +
+ f"{len(traces)} is given." f"{len(traces)} is given."
) )
color = area['color'] color = area['color']
if traces[0] in data and traces[1] in data: if traces[0] in data and traces[1] in data:
@ -406,6 +406,7 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
) )
fig.add_trace(trace_b) fig.add_trace(trace_b)
fig.add_trace(trace_a) fig.add_trace(trace_a)
# 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)