以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 交易策略发布专区 (http://www.weistock.com/bbs/list.asp?boardid=10) ---- [模板]对冲策略 (http://www.weistock.com/bbs/dispbbs.asp?boardid=10&id=58877) |
-- 作者:z7c9 -- 发布时间:2013/11/17 18:08:15 -- [模板]对冲策略 以下内容为程序代码:
1 runmode:0; 2 3 variable:currentholding=0; 4 5 holding1:=stkindi(stklabel,\'f1a.持仓\',0,dataperiod,0); 6 holding2:=stkindi(stklabel,\'f2a.持仓\',0,dataperiod,0); 7 8 targetholding:=holding1+holding2; 9 10 if targetholding=0 then begin 11 if currentholding>0 then 12 sell(1,currentholding,limitr,close); 13 14 if currentholding<0 then 15 sellshort(1,-currentholding,limitr,close); 16 end 17 18 if targetholding>0 then begin 19 if currentholding=0 then 20 buy(1,targetholding,limitr,close); 21 22 if currentholding>0 then begin 23 if targetholding>currentholding then 24 buy(1,targetholding-currentholding,limitr,close); 25 26 if targetholding<currentholding then 27 sell(1,currentholding-targetholding,limitr,close); 28 end 29 30 if currentholding<0 then begin 31 sellshort(1,-currentholding,limitr,close); 32 buy(1,targetholding,limitr,close); 33 end 34 end 35 36 if targetholding<0 then begin 37 if currentholding=0 then 38 buyshort(1,-targetholding,limitr,close); 39 40 if currentholding>0 then begin 41 sell(1,currentholding,limitr,close); 42 buyshort(1,-targetholding,limitr,close); 43 end 44 45 if currentholding<0 then begin 46 if targetholding>currentholding then 47 sellshort(1,targetholding-currentholding,limitr,close); 48 49 if targetholding<currentholding then 50 buyshort(1,currentholding-targetholding,limitr,close); 51 end 52 end 53 54 currentholding:=targetholding; 55 56 仓位:holding,noaxis,linethick0; 57 收益:asset-500000,noaxis,colormagenta,linethick2; [此贴子已经被作者于2013/11/17 18:33:53编辑过]
|
-- 作者:z7c9 -- 发布时间:2013/11/21 0:07:37 -- runmode:0; holding1:=stkindi(stklabel,\'f1a.持仓\',0,dataperiod,0); targetholding:=holding1+holding2; if holding<> targetholding then begin |
-- 作者:z7c9 -- 发布时间:2013/11/21 0:07:51 -- 以下内容为程序代码:
1 runmode:0; 2 3 holding1:=stkindi(stklabel,\'f1a.持仓\',0,dataperiod,0); 4 holding2:=stkindi(stklabel,\'f2a.持仓\',0,dataperiod,0); 5 6 targetholding:=holding1+holding2; 7 8 if holding<> targetholding then begin 9 if holding=0 then begin 10 if targetholding>0 then 11 buy(1,targetholding,limitr,close); 12 13 if targetholding<0 then 14 buyshort(1,-targetholding,limitr,close); 15 end 16 17 if holding>0 then begin 18 if targetholding=0 then 19 sell(1,holding,limitr,close); 20 21 if targetholding>0 then begin 22 if targetholding>holding then 23 buy(1,targetholding-holding,limitr,close); 24 25 if targetholding<holding then 26 sell(1,holding-targetholding,limitr,close); 27 end 28 29 if targetholding<0 then begin 30 sell(1,holding,limitr,close); 31 buyshort(1,targetholding,limitr,close); 32 end 33 end 34 35 if holding<0 then begin 36 if targetholding=0 then 37 sellshort(1,holding,limitr,close); 38 39 if targetholding>0 then begin 40 sellshort(1,holding,limitr,close); 41 buy(1,targetholding,limitr,close); 42 end 43 44 if targetholding<0 then begin 45 if targetholding>holding then 46 sellshort(1,targetholding-holding,limitr,close); 47 48 if targetholding<holding then 49 buyshort(1,holding-targetholding,limitr,close); 50 end 51 end 52 end |
-- 作者:z7c9 -- 发布时间:2013/11/22 22:19:59 -- runmode:0; variable:currentholding=0; holding1:=stkindi(stklabel,\'f1a.持仓\',0,dataperiod,0); targetholding:=holding1+holding2; if targetholding=0 then begin if targetholding>0 then begin if targetholding<0 then begin currentholding:=targetholding; 仓位:holding,noaxis,linethick0; |
-- 作者:sdrzhq -- 发布时间:2014/1/9 19:36:56 -- 借鉴 |