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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → 【高频策略】利用挂单价差实现高频交易的策略

   

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


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

主题:【高频策略】利用挂单价差实现高频交易的策略

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


加好友 发短信
等级:新手上路 帖子:16 积分:0 威望:0 精华:0 注册:2018/5/6 14:33:55
  发帖心情 Post By:2018/9/26 9:10:57 [显示全部帖子]

用在锌上试试
diff:=5;手数:=1;多持:=tbuyholding(1);空持:=tsellholding(1);
持价:=TAVGENTERPRICE;
挂单价差:(ASKPRICE-BIDPRICE)/diff,NOAXIS;
DEBUGFILE('C:\TEST.TXT','挂单价差 %.0f', 挂单价差);DEBUGOUT('挂单价差 %.0f', 挂单价差);
//开平仓条件
开仓条件:=挂单价差>=5;平仓条件:=挂单价差<=2;
//开仓挂单
if 多持=0 and 空持=0  then begin
    tcancel(开仓条件=0 and tisremain(1)>0 ,1); //不满足条件就撤单
    tcancel(开仓条件=0 and tisremain(3)>0 ,3); 
    tbuy     (开仓条件  and tisremain(1)=0,手数,lmt,BIDPRICE+diff,0);
    tbuyshort(开仓条件  and tisremain(3)=0,手数,lmt,ASKPRICE-diff,0);
end
//平仓挂单
if 多持>0 and 空持>0  then begin
    tcancel(平仓条件=0 and tisremain(2)>0 ,2); //不满足条件就撤单
    tcancel(平仓条件=0 and tisremain(4)>0 ,4);
    tsell     (平仓条件 and tisremain(2)=0,多持,lmt,ASKPRICE,0);
    tsellshort(平仓条件 and tisremain(4)=0,空持,lmt,BIDPRICE,0);
end
//单腿处理
if 多持=0 and 空持>0  then begin
    买单挂条件 :=BIDPRICE<=持价-3*diff;卖单止损条件:=ASKPRICE>=持价+3*diff and not(买单挂条件);
    tcancel   (卖单止损条件   or  TSUBMIT(1)>60,1); //满足卖单止损条件,就撤开多单
    tcancel   (卖单止损条件=0 or  TSUBMIT(4)>60,4); //不满足卖单止损条件或者平空单60秒未成交,就撤平空单
    tbuy      (卖单止损条件=0 and tisremain(4)=0 and tisremain(1)=0,手数,lmt,BIDPRICE+diff,0);
    tsellshort(卖单止损条件   and tisremain(4)=0 and tisremain(1)=0,空持,lmt,BIDPRICE+diff,0);//满足卖单止损条件,就平空单,追单
end
if 多持>0 and 空持=0 then begin
    卖单挂条件 :=ASKPRICE>=持价+3*diff;买单止损条件:=BIDPRICE<=持价-3*diff and not(卖单挂条件);
    tcancel   (买单止损条件   or  TSUBMIT(1)>60,3);
    tcancel   (买单止损条件=0 or  TSUBMIT(1)>60,2);
    tbuyshort (买单止损条件=0 and tisremain(3)=0 and tisremain(2)=0,手数,lmt,ASKPRICE-diff,0);
    tsell     (买单止损条件   and tisremain(3)=0 and tisremain(2)=0,多持,lmt,ASKPRICE-diff,0);
end


 回到顶部
帅哥哟,离线,有人找我吗?
量化资产
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:16 积分:0 威望:0 精华:0 注册:2018/5/6 14:33:55
  发帖心情 Post By:2018/9/26 14:48:02 [显示全部帖子]

如果双边可以顺利成交的话,把后成交的一边直接改为平仓,即可盈利!

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


加好友 发短信
等级:新手上路 帖子:16 积分:0 威望:0 精华:0 注册:2018/5/6 14:33:55
  发帖心情 Post By:2018/9/26 15:33:39 [显示全部帖子]

diff:=5;手数:=1;
多持:=tbuyholdingex('623637' ,'',2 );空持:=tsellholdingex('623637' ,'',2 );
DEBUGFILE('C:\TEST.TXT','多持 %.0f', 多持);DEBUGOUT('多持 %.0f', 多持);
DEBUGFILE('C:\TEST.TXT','空持 %.0f', 空持);DEBUGOUT('空持 %.0f', 空持);
持价:=TAVGENTERPRICE;挂单价差:(ASKPRICE-BIDPRICE)/diff,NOAXIS;
DEBUGFILE('C:\TEST.TXT','挂单价差 %.0f', 挂单价差);DEBUGOUT('挂单价差 %.0f', 挂单价差);

//开仓
开仓条件:=挂单价差>=5;
if 多持=0 and 空持=0  then begin
    tbuy     (开仓条件  and tisremain(1)=0,手数,lmt,BIDPRICE+diff,0);
    tbuyshort(开仓条件  and tisremain(3)=0,手数,lmt,ASKPRICE-diff,0);
end
//平仓
if 多持=0 and 空持>0  then begin
    tcancel   (1,1); //撤开多单
    //钓鱼挂止盈单//3跳利润
    tsellshort(tisremain(4)=0,手数,lmt,持价-3*diff,0);
    //即时成交
    即时成交止盈条件:=ASKPRICE<持价;//即时成交止盈单//1跳利润
    即时成交止损条件:=ASKPRICE>=持价+5*diff;//即时成交止损单//5跳止损    
    if 即时成交止盈条件 or 即时成交止损条件 then begin
        tcancel   (1,4); //撤钓鱼单
        tsellshort(tisremain(4)=0,手数,lmt,ASKPRICE,0);    
    end
END    
if 多持>0 and 空持=0 then begin
    tcancel   (1,3);//撤开空单
    tsell     (tisremain(2)=0,手数,lmt,持价+3*diff,0);
    即时成交止盈条件:=BIDPRICE>持价;
    即时成交止损条件:=BIDPRICE<=持价-5*diff;    
    if 即时成交止盈条件 or 即时成交止损条件 then begin
        tcancel   (1,2); 
        tsell     (tisremain(2)=0,手数,lmt,BIDPRICE,0);    
    end    
END

 回到顶部
帅哥哟,离线,有人找我吗?
量化资产
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:16 积分:0 威望:0 精华:0 注册:2018/5/6 14:33:55
  发帖心情 Post By:2018/9/26 23:12:57 [显示全部帖子]

后台 固定1秒轮询。
diff:=5;手数:=1;
多持:=tbuyholdingex('623637' ,'',2 );空持:=tsellholdingex('623637' ,'',2 );
DEBUGFILE('C:\TEST.TXT','多持 %.0f', 多持);DEBUGOUT('多持 %.0f', 多持);
DEBUGFILE('C:\TEST.TXT','空持 %.0f', 空持);DEBUGOUT('空持 %.0f', 空持);
持价:=TAVGENTERPRICE;挂单价差:(ASKPRICE-BIDPRICE)/diff,NOAXIS;
DEBUGFILE('C:\TEST.TXT','挂单价差 %.0f', 挂单价差);DEBUGOUT('挂单价差 %.0f', 挂单价差);

//开仓
开仓条件:=挂单价差>=5;
if 多持=0 and 空持=0  then begin
    tbuy     (开仓条件  and tisremain(1)=0,手数,lmt,BIDPRICE+diff,0);
    tbuyshort(开仓条件  and tisremain(3)=0,手数,lmt,ASKPRICE-diff,0);
end
//平仓
if 多持=0 and 空持>0  then begin
    tcancel   (1,1); //撤开多单
    //即时成交
    即时成交止盈条件:=ASKPRICE<持价;//即时成交止盈单//1跳利润
    即时成交止损条件:=ASKPRICE>=持价+5*diff;//即时成交止损单//5跳止损    
    if 即时成交止盈条件 or 即时成交止损条件 then begin
        tcancel   (1,4); //撤钓鱼单//撤单后,到下一个TICK才能发出平仓单,因为撤单回报需要时间。
        tsellshort(tisremain(4)=0,手数,lmt,ASKPRICE,0);    
    end
    //钓鱼挂止盈单//3跳利润
    tsellshort(tisremain(4)=0,手数,lmt,持价-3*diff,0);    
END    
if 多持>0 and 空持=0 then begin
    tcancel   (1,3);//撤开空单
    即时成交止盈条件:=BIDPRICE>持价;
    即时成交止损条件:=BIDPRICE<=持价-5*diff;    
    if 即时成交止盈条件 or 即时成交止损条件 then begin
        tcancel   (1,2); 
        tsell     (tisremain(2)=0,手数,lmt,BIDPRICE,0);    
    end    
    tsell     (tisremain(2)=0,手数,lmt,持价+3*diff,0);
END

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


加好友 发短信
等级:新手上路 帖子:16 积分:0 威望:0 精华:0 注册:2018/5/6 14:33:55
  发帖心情 Post By:2018/9/27 14:32:39 [显示全部帖子]

diff:=0.2;手数:=1;
多持:=tbuyholdingex('623637' ,'',2 );空持:=tsellholdingex('623637' ,'',2 );
持价:=TAVGENTERPRICE;挂单价差:(ASKPRICE-BIDPRICE)/diff,NOAXIS;
DEBUGFILE('C:\TEST.TXT','挂单价差 %.0f', 挂单价差);DEBUGOUT('挂单价差 %.0f', 挂单价差);

//开仓

if 多持=0 and 空持=0 and 挂单价差>=5 then begin
    tbuy     (tisremain(1)=0,手数,lmt,BIDPRICE+diff,0);
    tbuyshort(tisremain(3)=0,手数,lmt,ASKPRICE-diff,0);
end
//单腿
//即时成交止损单//5-10跳止损
if 多持=0 and 空持>0 and 挂单价差<3 and DYNAINFO(7)>=持价+10*diff then begin
    tsellshort(tisremain(4)=0,手数,lmt,ASKPRICE+5*diff,0);
    tcancel   (1,1);
END    
tcancel   ( TSUBMIT(4)>10,4);
if 多持>0 and 空持=0 and 挂单价差<3 and DYNAINFO(7)<=持价-10*diff then begin
    tsell     (tisremain(2)=0,手数,lmt,BIDPRICE-5*diff,0);
    tcancel   (1,3);   
END
tcancel   ( TSUBMIT(2)>10,2);
//平仓
//即时成交止损单
if 多持>0 and 空持>0 and 挂单价差<2 then begin
    tsellshort(tisremain(4)=0,手数,lmt,ASKPRICE+5*diff,0);
    tsell     (tisremain(2)=0,手数,lmt,BIDPRICE-5*diff,0);
END


 回到顶部