一、修改对话框数量
def main_diagram(df):
charts_num=3
二、划线函数 折线为例: E:\echarts\main_\tools_charts.py
def single_line(df, target):
'''
target:df中的列名
'''
datetime_list = list(df['candle_begin_time'])
line = (
Line()
.add_xaxis(xaxis_data=datetime_list)
.add_yaxis(
series_name=target,
y_axis=df[target],
is_smooth=True,
is_hover_animation=False,
linestyle_opts=opts.LineStyleOpts(width=3, opacity=0.5),
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(xaxis_opts=opts.AxisOpts(type_="category"))
)
return line
三、画新的副图
def grid_simple_layout(df, signal_name):
grid_chart.add(
single_line(df, 'equity_curve'),
grid_opts=opts.GridOpts(
pos_left="10%", pos_right="8%", pos_top="63%", height="16%"
),
)
四、叠加到副图或主图 4.1 主图叠加
def main_diagram(df):
'''
根据不同的信号输入,完成主图K线与指标叠加
'''
kline = candle_with_markpoint(df)
kline.overlap(single_line(df, 'equity_curve'))
4.2副图叠加 成交量柱状图,叠加成交量均线图
def volumn_bar_line(df):
_bar = volume_bar(df)
n_list = [5, 20]
for i in range(len(n_list)):
_bar.overlap(single_ma_line(df, 'volume', n_list[i]))
return _bar
5、叠加图Y轴等比显示 好像不行。。。 用close/close[0]换算成等比
|