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

楼主 |
发表于 2023-11-7 10:31
|
显示全部楼层
请问老师,下面的代码在多策略中能否实现按时间进行拆解
全策略:日内持仓+多策略持仓; //理论持仓
if 全策略=0 then
理论持仓:0;
if 全策略>0 and 理论持仓<全策略 then BEGIN
理论持仓:=理论持仓+1;
end
////***********************************************//账户仓位计算//***********************************************
zh:='19521578243';
可用买持:tbuyholdingex(zh,'',1);
可用卖持:tsellholdingex(zh,'',1);
多单总持仓:tbuyholdingex(zh,'',2);
空单总持仓:tsellholdingex(zh,'',2);
平空未成交:tsellholdingex(zh,'',3);
平多未成交:tbuyholdingex(zh,'',3);
开多未成交:tisremainex(1,zh,stklabel); //未成交开多单
开空未成交:tisremainex(3,zh,stklabel); //未成交开空单
账户总仓:多单总持仓-空单总持仓+开多未成交-开空未成交;
////***********************************************//交易模块//***********************************************
//理论持仓与实际持仓的判断
if 理论持仓-账户总仓>0 and 账户总仓>=0 then
tbuy(1,理论持仓-账户总仓,mkt,0,0,zh);
if 理论持仓-账户总仓>0 and 账户总仓<0 then begin
tsellshort(理论持仓<0,理论持仓-账户总仓,mkt,0,0,zh);
if 理论持仓>=0 then begin
tsellshort(1,账户总仓,mkt,0,0,zh);
tbuy(理论持仓>0,理论持仓,mkt,0,0,zh);
end
end
if 理论持仓-账户总仓<0 and 账户总仓<=0 then
tbuyshort(1,abs(理论持仓-账户总仓),mkt,0,0,zh);
if 理论持仓-账户总仓<0 and 账户总仓>0 then begin
tsell(理论持仓>0,abs(理论持仓-账户总仓),mkt,0,0,zh);
if 理论持仓<=0 then begin
tsell(1,账户总仓,mkt,0,0,zh);
tbuyshort(理论持仓<0,abs(理论持仓),mkt,0,0,zh);
end
end
if 全策略<0 and 理论持仓>全策略 then BEGIN
理论持仓:=理论持仓-1;
end
|
|