以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  日内后台多账户中某一个账户满仓反手  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=9540)

--  作者:弦外之音
--  发布时间:2011/12/30 9:54:50
--  日内后台多账户中某一个账户满仓反手

如题,后台多账户中,某一个账户有不同的交易策略组合,总仓位满仓,当所有的模型都开仓后,怎么解决其中某一个模型反手时保证金不足无法开仓的问题?


--  作者:fly
--  发布时间:2011/12/30 10:12:45
--  

平仓反手,又担心反手时保证金不足,无法开仓.

用ORDERQUEUE,结合多少秒不成交就撤单.


--  作者:弦外之音
--  发布时间:2011/12/30 10:16:25
--  
以下是引用fly在2011-12-30 10:12:45的发言:

平仓反手,又担心反手时保证金不足,无法开仓.

用ORDERQUEUE,结合多少秒不成交就撤单.

在指定满仓账户的开仓条件里面加入abb:

abb:=not(islastbar) or (islastbar and tholding2=0);

是否可行?


--  作者:弦外之音
--  发布时间:2011/12/30 10:24:31
--  

buycond:=ref(c>ma(c,5),1);
sellcond:=ref(c<ma(c,5),1);
nn:=barslast(date<>ref(date,1))+1;
entertime:=time>=91500 and time<143000;
exittime:=time>150000;
abb:=not(islastbar) or (islastbar and tholding2=0);
if holding>0 and sellcond then begin
 sell(1,1,limitr,o-1);
 tsell(abb,1,lmt,o-1,0,\'801019\');
 tsell(1,3,lmt,o-1,0,\'800435\');
end
if holding<0 and buycond then begin
 sellshort(1,1,limitr,o+1);
 tsellshort(abb,1,lmt,o+1,0,\'801019\');
 tsellshort(1,3,lmt,o+1,0,\'800435\');
end
if holding=0 and buycond and abb then begin
 buy(1,1,limitr,o+1);
 tbuy(abb,1,lmt,o+1,0,\'801019\');
 tbuy(abb,3,lmt,o+1,0,\'800435\');
end
if holding=0 and sellcond and abb then begin
 buyshort(1,1,limitr,o-1);
 tbuyshort(abb,1,lmt,o-1,0,\'801019\');
 tbuyshort(abb,3,lmt,o-1,0,\'800435\');
end

以上代码在模拟交易的时候运行正常。请问是否存在问题?


--  作者:fly
--  发布时间:2011/12/30 10:26:12
--  

不行,

tholding2会返回该帐户的所有实际持仓的,而不是该帐户该策略的实际持仓.

你是不同策略,又是满仓

 

 


--  作者:弦外之音
--  发布时间:2011/12/30 10:45:31
--  

buycond:=ref(c>ma(c,5),1);
sellcond:=ref(c<ma(c,5),1);
nn:=barslast(date<>ref(date,1))+1;
entertime:=time>=91500 and time<143000;
exittime:=time>150000;
abb:=not(islastbar);
if holding>0 and (sellcond or exittime) then begin
  sell(1,1,limitr,o-1);
  tsell(1,1,lmt,o-1,0,\'800435\');
end

if holding<0 and (buycond or exittime) then begin
  sellshort(1,1,limitr,o+1);
  tsellshort(1,1,lmt,o+1,0,\'800435\');
end

if holding=0 and entertime and buycond then begin
  buy(abb or tbuyholding(1)>0,1,limitr,o+1);
  tbuy(abb or tbuyholding(1)>0,1,lmt,o+1,0,\'800435\');
end

if holding=0 and entertime and sellcond then begin
  buyshort(abb or tsellholding(1)>0,1,limitr,o-1);
  tbuyshort(abb or tsellholding(1)>0,1,lmt,o-1,0,\'800435\');
end

这么写可以吗?


--  作者:fly
--  发布时间:2011/12/30 14:33:19
--  

不行

tsellholding(1)当前品种当前帐户空头持仓(而不一定是您写的800435这个帐户)

tbuyholding(1)当前品种当前帐户多头持仓

 

如果你的策略已经复杂了,就转成纯后台的执行吧,漫漫学着跟踪调试吧

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=1246&page=1&star=1