 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
- gxx978
|
参考如下范例,仅供参考:
a:stkindiex('','一箭穿心.cc0',0,21,3,15000); //引用3分钟周期上的策略a的仓位。
b:stkindiex('','震荡反转.cc0',0,3,0,5000); //引用15分钟周期上的策略b的仓位。
t_holding:=a+b; //理论持仓
bh_new_month_t:=tbuyholdingex('','',0); //多头今仓
bh_new_month_y:=tbuyholdingex('','',1)-tbuyholdingex('','',0); //多头老仓
sh_new_month_t:=tsellholdingex('','',0); //空头近今仓
sh_new_month_y:=tsellholdingex('','',1)-tsellholdingex('','',0); //空头老仓
new_month_kd_w:=tisremainex(1,'',stklabel); //未成交开多单
new_month_pd_w:=tisremainex(2,'',stklabel); //未成交开多单
new_month_kk_w:=tisremainex(3,'',stklabel); //未成交开空单
new_month_pk_w:=tisremainex(4,'',stklabel); //未成交开多单
new_month_jcc:=(bh_new_month_y+bh_new_month_t)-(sh_new_month_y+sh_new_month_t)+(new_month_kd_w-new_month_kk_w); //实际账户净持仓(不含平仓未成交单)
//理论持仓与实际持仓的判断
if total_holding-new_month_jcc>0 and new_month_jcc>=0 then
tbuy(1,total_holding-new_month_jcc,mkt,0,0,zh);
if total_holding-new_month_jcc>0 and new_month_jcc<0 then begin
tsellshort(total_holding<0,total_holding-new_month_jcc,mkt,0,0,zh);
if total_holding>=0 then begin
tsellshort(1,new_month_jcc,mkt,0,0,zh);
tbuy(total_holding>0,total_holding,mkt,0,0,zh);
end
end
if total_holding-new_month_jcc<0 and new_month_jcc<=0 then
tbuyshort(1,abs(total_holding-new_month_jcc),mkt,0,0,zh);
if total_holding-new_month_jcc<0 and new_month_jcc>0 then begin
tsell(total_holding>0,abs(total_holding-new_month_jcc),mkt,0,0,zh);
if total_holding<=0 then begin
tsell(1,new_month_jcc,mkt,0,0,zh);
tbuyshort(total_holding<0,abs(total_holding),mkt,0,0,zh);
end
end |
|