网站标志
当前日期时间
当前时间:
发两个对冲程序源码供大家学习
作者:管理员    发布于:2015-06-07 15:14:03    文字:【】【】【

对冲源码一:

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\\WWW.JGY8.COM
 
 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);
   \\www.jgy8.com
  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);
    \\www.jgy8.com
   if targetholding<holding then
    buyshort(1,holding-targetholding,limitr,close);
  end
 end
end


 

对冲源码二:

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 \\WWW.JGY8.COM

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
 \\WWW.JGY8.COM
 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;


 

浏览 (1135) | 评论 (0) | 评分(0) | 支持(0) | 反对(0) | 发布人:管理员
将本文加入收藏夹
文章评论
最新点评
更多点评 发表点评
发表评论
您的评价
差(1) 一般(2) 好(3) 很好(4) 非常好(5)
评论标题
评论内容
验 证 码
看不清?更换一张
匿名发表 
脚注信息

Copyright @ 2009-2011  金广元投资咨询有限公司 福建省泉州安溪金融中心4#楼4楼 4000 258 130