等级: 免费版
- 注册:
- 2021-5-20
- 曾用名:
|

楼主 |
发表于 2022-7-7 06:48
|
显示全部楼层
1:优先平老仓的后台程序实现
switch0:hold0;//获取的拟下单数(多单)
Is_orderBuy:=TISREMAINEX(1,'',STKLABEL);//开多未成交单
Is_orderSell:=TISREMAINEX(2,'',STKLABEL);//平多未成交单
Is_orderBuyshort:=TISREMAINEX(3,'',STKLABEL);//开空未成交单
Is_orderSellshort:=TISREMAINEX(4,'',STKLABEL);//平空未成交单
//-----------------------账户多头持仓-----------------------
TbuyH0:=tbuyholdingex('',STKLABEL,0)+Is_orderSell;//取:当日买持-多头平仓未成交单
TbuyH1:=tbuyholdingex('',STKLABEL,1)+Is_orderSell;//取:全部买持-多头平仓未成交单
TbuyHY:=TbuyH1-TbuyH0;//多头老仓()
//-----------------------账户空头持仓-----------------------
TsellH0:=tsellholdingex('',STKLABEL,0)+Is_orderSellshort;//取:当日卖持-空头平仓未成交单
TsellH1:=tsellholdingex('',STKLABEL,1)+Is_orderSellshort;//取:全部卖持-空头平仓未成交单
TsellHY:=TsellH1-TsellH0;//空头老仓()
//------------------------------------------优先平老仓后平今仓下单程序-------------------------------------------------
if switch0>0 then BEGIN
if TbuyHY>=switch0 then BEGIN
CLOSEPOSMODE:1;
tsell(1,switch0,mkt);
end
if TbuyHY>0&&TbuyHY<switch0 then BEGIN
CLOSEPOSMODE:1;
tsell(1,TbuyHY,mkt);
CLOSEPOSMODE:0;
tsell(1,switch0-TbuyHY,mkt);
end
if TbuyHY<=0 then BEGIN
CLOSEPOSMODE:0;
tsell(1,switch0,mkt);
end
//tsell(1,switch0,mkt);
//EXTGBDATASET(mswitch0,0);
end
2:平仓对锁的实现:就是将准备平今空仓的改为开多仓;就是将准备平今多仓的改为开空仓。
|
|