
等级: 专业版
- 注册:
- 2024-6-21
- 曾用名:
|

楼主 |
发表于 2024-12-16 16:09
|
显示全部楼层
实盘账户原先就有2手十年债,这一开一平的程序执行肯定也读取了实际持仓2手才发的单,问题是不应该发单啊!
下面是净持仓代码,
//连续交易阶段
If 连续交易 then
begin
//直接对比前一个周期的理论持仓和当前实际持仓是否存在差异,有差异执行矫正
//多头部分
if ho>=0 and tsellho>0 then tsellshort(1,tsellho,mkt);
//理论持仓大于0,补仓
if ho>0 and ho>tbuyho then
begin
tbuy(1,ho-tbuyho,mkt);
end
//理论持仓大于0,减仓
if ho>0 and ho<tbuyho then
begin
tsell(1,tbuyho-ho,mkt);
end
//空头部分
if ho<=0 and tbuyho>0 then tsell(1,tbuyho,mkt);
//理论持仓小于0,补仓
if ho<0 and abs(ho)>tsellho then
begin
tbuyshort(1,abs(ho)-tsellho,mkt);
end
//理论持仓小于0,减仓
if ho<0 and abs(ho)<tsellho then
begin
tsellshort(1,tsellho-abs(ho),mkt);
end
end |
|