文章声明:本内容为个人的业余研究,和任何单位,机构没有关系,文章出现的股票代码,全部只是测试例子,不做投资参考,投资有风险,代码学习使用,不做商业用途
最近写miniqmt的使用教程,也在录视频,截图给大家一套大qmt的学习代码参考怎么样写qmt策略,在写miniqmt的使用教程
网页http://14.103.193.242:9999/xms_quants.html

大qmt的工具代码使用教程我写完了

我在给大家录的miniqmt使用视频目前上线了8个可以直接看,全部视频我亲自录制


大qmt代码教程可以直接网页下载,点击网页的资料,点击大qmt例子

输入账户下载就可以

点击下载

里面的内容




导入qmt看看



点击运行看看,可以学习里面的代码怎么样建立框架,在这里输入账户就可以

这个代码学习可以,里面很多细节需要处理

真正的实盘比这个复杂太多


全部内容我上传了,直接下载就可以,知识星球全部有

不懂的问我就可以,全部学习例子,找我要就可以,备注大qmt资料

需要可以找我朋友,资料免费使用

里面的例子参考,学习使用
#encoding:gbk
import numpy as np
def init(ContextInfo):
ContextInfo.trade_code_list=['002415.SZ','601318.SH','000651.SZ','000333.SZ','600519.SH','000002.SZ']
ContextInfo.set_universe(ContextInfo.trade_code_list)
ContextInfo.accID = '账户'
ContextInfo.short=5
ContextInfo.middle=20
ContextInfo.long=40
ContextInfo.t=0
ContextInfo.buys=0
ContextInfo.tc=5
ContextInfo.ZY = dict.fromkeys(ContextInfo.trade_code_list,0)
def handlebar(ContextInfo):
ContextInfo.t+=1
if ContextInfo.t%ContextInfo.tc==0: #每5天进行一次调仓
index=ContextInfo.barpos
h=ContextInfo.get_history_data(41,'1d','close')
holdings=get_holdings(ContextInfo.accID,'STOCK')
for stk in ContextInfo.trade_code_list:
ma5=np.mean(h[stk][-ContextInfo.short-1:-1])
ma20=np.mean(h[stk][-ContextInfo.middle-1:-1])
ma40=np.mean(h[stk][-ContextInfo.long-1:-1])
pc=h[stk][-1]
if ma20>ma40 and stk not in holdings.keys():
order_target_value(stk,100000,ContextInfo,ContextInfo.accID)
ContextInfo.buys=1
ContextInfo.ZY[stk] = pc
for i in holdings.keys():
if ma5<ma20 and pc<ma5 and pc*(1-0.05*ContextInfo.buys)> h[i][-1] and ContextInfo.buys<4:
ContextInfo.buys+=1
order_value(i,100000*ContextInfo.buys,ContextInfo,ContextInfo.accID)
elif ma20<ma40:
order_target_value(i,0,ContextInfo,ContextInfo.accID)
ContextInfo.buys=0
ContextInfo.ZY[stk]=0
for j in ContextInfo.ZY.keys():
mc=max(h[j])
if ContextInfo.ZY[j]*0.78> h[j][-1]:
order_target_value(j,0,ContextInfo,ContextInfo.accID)
print("止损",j)
elif ContextInfo.ZY[j]*1.2<h[j][-1]<mc*0.97:
order_target_value(j,0,ContextInfo,ContextInfo.accID)
print("止盈",j)
#获取持仓信息{code.market:手数}
def get_holdings(accountid,datatype):
holdinglist={}
resultlist=get_trade_detail_data(accountid,datatype,"POSITION")
for obj in resultlist:
holdinglist[obj.m_strInstrumentID+"."+obj.m_strExchangeID]=obj.m_nVolume/100
return holdinglist
#获取账户总权益m_dBalance
def get_totalvalue(accountid,datatype):
result=0
resultlist=get_trade_detail_data(accountid,datatype,"ACCOUNT")
for obj in resultlist:
result=obj.m_dBalance
return result