等级: 免费版
- 注册:
- 2022-4-2
- 曾用名:
|

楼主 |
发表于 2023-6-27 15:03
|
显示全部楼层
不对上面的还是有问题,应该是
ah:stkindiex('','策略A.cc',0,21,3,10000); //引用3分钟周期上的策略a的仓位。
bh:stkindiex('','策略B.cc',0,3,0,5000); //引用15分钟周期上的策略b的仓位。
ch:stkindiex('','策略Ccc',0,2,0,15000); //引用15分钟周期上的策略b的仓位。
zh:='';
strategy_hold:ah+bh+ch; //理论持仓
多单总持仓:=tbuyholdingex(zh,'',2); //多头总仓
空单总持仓:=tsellholdingex(zh,'',2); //空头近今仓
多单未成交委托:=tisremainex(1,zh,stklabel);
空单未成交委托:=tisremainex(3,zh,stklabel);
tot_account_hold:多单总持仓-空单总持仓+多单未成交委托-空单未成交委托;
//理论持仓与实际持仓的判断
if strategy_hold-tot_account_hold>0 and tot_account_hold>=0 then
tbuy(1,strategy_hold-tot_account_hold,mkt,0,0,zh);
if strategy_hold-tot_account_hold>0 and tot_account_hold<0 then begin
tsellshort(strategy_hold<0,strategy_hold-tot_account_hold,mkt,0,0,zh);
if strategy_hold>=0 then begin
tsellshort(1,tot_account_hold,mkt,0,0,zh);
tbuy(strategy_hold>0,strategy_hold,mkt,0,0,zh);
end
end
if strategy_hold-tot_account_hold<0 and tot_account_hold<=0 then
tbuyshort(1,abs(strategy_hold-tot_account_hold),mkt,0,0,zh);
if strategy_hold-tot_account_hold<0 and tot_account_hold>0 then begin
tsell(strategy_hold>0,abs(strategy_hold-tot_account_hold),mkt,0,0,zh);
if strategy_hold<=0 then begin
tsell(1,tot_account_hold,mkt,0,0,zh);
tbuyshort(strategy_hold<0,abs(strategy_hold),mkt,0,0,zh);
end
end |
|