Skip to content

Commit

Permalink
0.9.42 add_macd 优先按计算好的值绘图
Browse files Browse the repository at this point in the history
  • Loading branch information
zengbin93 committed Feb 8, 2024
1 parent 047110c commit 6e02628
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion czsc/utils/plotly_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def add_macd(self, kline: pd.DataFrame, row=3, **kwargs):
slowperiod = kwargs.get('slowperiod', 26)
signalperiod = kwargs.get('signalperiod', 9)
line_width = kwargs.get('line_width', 0.6)
diff, dea, macd = MACD(df["close"], fastperiod=fastperiod, slowperiod=slowperiod, signalperiod=signalperiod)

if 'DIFF' in df.columns and 'DEA' in df.columns and 'MACD' in df.columns:
diff, dea, macd = df['DIFF'], df['DEA'], df['MACD']
else:
diff, dea, macd = MACD(df["close"], fastperiod=fastperiod, slowperiod=slowperiod, signalperiod=signalperiod)

macd_colors = np.where(macd > 0, self.color_red, self.color_green)
self.add_scatter_indicator(df['dt'], diff, name="DIFF", row=row,
line_color='white', show_legend=False, line_width=line_width)
Expand Down

0 comments on commit 6e02628

Please sign in to comment.