Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:如何合并多个模型的开仓信号?

1楼
yanxc 发表于:2014/4/5 21:48:27
多个模型,各自有若干对开平策略,写法也各不相同,没法整合为一个模型。 有没办法通过引用各模型的持仓状态,来达到以下目的: 当每个模型都holding<0的时候,开仓做空; 其中一个模型反多或平仓的时候,平空。
2楼
Ivan 发表于:2014/4/8 0:39:56

可以的,通过stkindi函数,引用N个模型的持仓,然后汇总起来处理即可:

if c1+c2+...=N and holding=0 then buyshort(1,1,market);

if c1+c2+...>N and holding<0 then sellshort(1,1,market);

 

3楼
yanxc 发表于:2014/4/8 16:51:56
以下是引用Ivan在2014/4/8 0:39:56的发言:

可以的,通过stkindi函数,引用N个模型的持仓,然后汇总起来处理即可:

if c1+c2+...=N and holding=0 then buyshort(1,1,market);

if c1+c2+...>N and holding<0 then sellshort(1,1,market);

 


问题就是如何引用持仓?

如下写法正确吗?

C1:=stkindi('','holding,模型1',0,1);

 

貌似不对。

4楼
jinzhe 发表于:2014/4/8 17:17:23

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=63632

 

[此贴子已经被作者于2014/4/8 17:17:29编辑过]
5楼
qwer123 发表于:2014/4/8 21:22:04
rr1:=stkindiex('if00','qq20.持仓',0,21,2,0);
rr2:=stkindi('if00','qq7.持仓',0,1);
//rr3:=stkindi('if00','qq12.持仓',0,22,110);
//rr4:=stkindi('if00','qq12.持仓',0,22,125);
//rr5:=stkindi('if00','qq12.持仓',0,22,130);
//rr6:=stkindi('if00','qq12.持仓',0,22,95);
//rr7:=stkindi('if00','qq12.持仓',0,22,90);

//r11:=stkindi('if00','qq31.持仓',0,11);

r12:=rr1+rr2;

//********************************
hd:=if(islastbar,3,2.0);
hd1:=if(islastbar,3,0.1);

//********************************
if holding=0 and r12>0 then buy(1,r12,limitr,c+hd1);
if holding=0 and r12<0 then buyshort(1,abs(r12),limitr,c-hd1);

if holding>0 and r12>0 and holding>r12 then sell(1,holding-r12,limitr,c-hd1);
if holding>0 and r12>0 and holding<r12 then buy(1,r12-holding,limitr,c+hd1);
if holding>0 and r12<0 then
begin
sell(1,holding,limitr,c-hd1);
buyshort(1,abs(r12),limitr,c-hd1);
end

if holding<0 and r12<0 and holding>r12 then buyshort(1,holding-r12,limitr,c-hd1);
if holding<0 and r12<0 and holding<r12 then sellshort(1,r12-holding,limitr,c+hd1);
if holding<0 and r12>0 then
begin
sellshort(1,holding,limitr,c+hd1);
buy(1,r12,limitr,c+hd1);
end 
[此贴子已经被作者于2014/4/8 21:22:51编辑过]
共5 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.04688 s, 3 queries.