def plotCCI(p, df, plotwidth=800, upcolor='orange', downcolor='yellow'):
# create y axis for rsi
p.extra_y_ranges = {"cci": Range1d(start=min(df['cci'].values),
end=max(df['cci'].values))}
p.add_layout(LinearAxis(y_range_name="cci"), 'right')
candleWidth = (df.iloc[2]['date'].timestamp() -
df.iloc[1]['date'].timestamp()) * plotwidth
# plot green bars
inc = df.cci >= 0
p.vbar(x=df.date[inc],
width=candleWidth,
top=df.cci[inc],
bottom=0,
fill_color=upcolor,
line_color=upcolor,
alpha=0.5,
y_range_name="cci",
legend='cci')
# Plot red bars
dec = df.cci < 0
p.vbar(x=df.date[dec],
width=candleWidth,
top=0,
bottom=df.cci[dec],
fill_color=downcolor,
line_color=downcolor,
alpha=0.5,
y_range_name="cci",
legend='cci')
评论列表
文章目录