欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → [模板]对冲策略

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有10541人关注过本帖树形打印复制链接

主题:[模板]对冲策略

帅哥哟,离线,有人找我吗?
z7c9
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
[模板]对冲策略  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2013/11/21 0:07:37 [只看该作者]

runmode:0;

holding1:=stkindi(stklabel,'f1a.持仓',0,dataperiod,0);
holding2:=stkindi(stklabel,'f2a.持仓',0,dataperiod,0);

targetholding:=holding1+holding2;

if holding<> targetholding then begin
 if holding=0 then begin
  if targetholding>0 then
   buy(1,targetholding,limitr,close);
   
  if targetholding<0 then
   buyshort(1,-targetholding,limitr,close); 
 end
 
 if holding>0 then begin
  if targetholding=0 then
   sell(1,holding,limitr,close);
  
  if targetholding>0 then begin
   if targetholding>holding then
    buy(1,targetholding-holding,limitr,close);
   
   if targetholding<holding then
    sell(1,holding-targetholding,limitr,close); 
  end  
  
  if targetholding<0 then begin
   sell(1,holding,limitr,close);
   buyshort(1,targetholding,limitr,close);
  end
 end
 
 if holding<0 then begin
  if targetholding=0 then
   sellshort(1,holding,limitr,close);
  
  if targetholding>0 then begin
   sellshort(1,holding,limitr,close);
   buy(1,targetholding,limitr,close);
  end  
  
  if targetholding<0 then begin
   if targetholding>holding then
    sellshort(1,targetholding-holding,limitr,close);
    
   if targetholding<holding then
    buyshort(1,holding-targetholding,limitr,close); 
  end
 end
end


 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By: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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2013/11/22 22:19:59 [只看该作者]

runmode:0;

variable:currentholding=0;

holding1:=stkindi(stklabel,'f1a.持仓',0,dataperiod,0);
holding2:=stkindi(stklabel,'f2a.持仓',0,dataperiod,0);

targetholding:=holding1+holding2;

if targetholding=0 then begin  
 if currentholding>0 then
  sell(1,currentholding,limitr,close);
 
 if currentholding<0 then
  sellshort(1,-currentholding,limitr,close);
end

if targetholding>0 then begin
 if currentholding=0 then
  buy(1,targetholding,limitr,close);
 
 if currentholding>0 then begin
  if targetholding>currentholding then
   buy(1,targetholding-currentholding,limitr,close);
  
  if targetholding<currentholding then
   sell(1,currentholding-targetholding,limitr,close); 
 end 
 
 if currentholding<0 then begin
  sellshort(1,-currentholding,limitr,close);
  buy(1,targetholding,limitr,close);
 end
end

if targetholding<0 then begin
 if currentholding=0 then
  buyshort(1,-targetholding,limitr,close);
  
 if currentholding>0 then begin
  sell(1,currentholding,limitr,close);
  buyshort(1,-targetholding,limitr,close);
 end 
 
 if currentholding<0 then begin
  if targetholding>currentholding then
   sellshort(1,targetholding-currentholding,limitr,close);
   
  if targetholding<currentholding then
   buyshort(1,currentholding-targetholding,limitr,close); 
 end
end

currentholding:=targetholding;

仓位:holding,noaxis,linethick0;
收益:asset-500000,noaxis,colormagenta,linethick2;


 回到顶部
帅哥哟,离线,有人找我吗?
sdrzhq
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:120 积分:0 威望:0 精华:0 注册:2013/8/7 11:03:57
  发帖心情 Post By:2014/1/9 19:36:56 [只看该作者]

借鉴

 回到顶部