对接API火币/币安/OK/欧易交易所合约跟单系统开发成熟方案/案例详细/项目开发/源码版
现货合约量化交易所机器人系统是指通过计算机程序实现自动化交易的系统,它可以根据事先设定的交易策略和规则进行自动交易。
策略设计:在开发量化交易机器人系统前,需要制定一个可行的交易策略,Including factors such as buying and selling points,stop loss points,etc.Only in this way can corresponding robot systems be developed based on strategies.
数据获取与处理:In transaction robot systems,data acquisition is very important.main要获取市场行情数据、技术指标数据、基本面数据等,以便于对市场趋势的分析。
mc=mpf.make_marketcolors(
up='red',
down='green',
edge='i',
wick='i',
volume='in',
inherit=True)
#设置图形风格
#gridaxis:设置网格线位置
#gridstyle:设置网格线线型
#y_on_right:设置y轴位置是否在右
s=mpf.make_mpf_style(
gridaxis='both',
gridstyle='-.',
y_on_right=False,
marketcolors=mc)
#设置均线颜色,配色表可见下图
#建议设置较深的颜色且与红色、绿色形成对比
#此处设置七条均线的颜色,也可应用默认设置
mpl.rcParams['axes.prop_cycle']=cycler(
color=['dodgerblue','deeppink',
'navy','teal','maroon','darkorange',
'indigo'])
#设置线宽
mpl.rcParams['lines.linewidth']=.5
#图形绘制
#show_nontrading:是否显示非交易日,默认False
#savefig:导出图片,填写文件名及后缀
mpf.plot(df,
**kwargs,
style=s,
show_nontrading=False,
savefig='%s_begin%d_end%d'
%(ts_codes,begin_count,end_count)+'.png')
#candlestick2_ochl(ax,opens=opens,closes=closes,highs=highs,lows=lows,width=0.75,colorup='red',colordown='green')
#plt.legend(loc='best')
#plt.xticks(range(len(date)),date,rotation=30)
#plt.grid(True)
#plt.title(ts_codes)
#plt.show
#plot实例
def test_plot():
#绘制曲线
x=np.linspace(2,21,20)#取闭区间[2,21]之间的等差数列,列表长度20
y=np.log10(x)+0.5
plt.figure()#添加一个窗口。如果只显示一个窗口,可以省略该句。
plt.plot(x,y)#plot在一个figure窗口中添加一个图,绘制曲线,默认颜色
#绘制离散点
plt.plot(x,y,'.y')#绘制黄色的点,为了和曲线颜色不一样
x0,y0=15,np.log10(15)+0.5
plt.annotate('Interpolation point',xy=(x0,y0),xytext=(x0,y0-1),arrowprops=dict(arrowstyle='->'))#添加注释
for x0,y0 in zip(x,y):
plt.quiver(x0,y0-0.3,0,1,color='g',width=0.005)#绘制箭头
x=range(2,21,5)
y=np.log10(x)+0.5
plt.plot(x,y,'om')#绘制紫红色的圆形的点
x0,y0=7,np.log10(7)+0.5
plt.annotate('Original point',xy=(x0,y0),xytext=(x0,y0-1),arrowprops=dict(arrowstyle='->'))
for x0,y0 in zip(x,y):
plt.quiver(x0,y0+0.3,0,-1,color='g',width=0.005)#绘制箭头