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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → [原创]高频交易

   

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


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

主题:[原创]高频交易

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


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

sub marketdata_reportnotify(reportdata) 
  dim multiplier
  dim mintick
  dim shortpercent
  dim longpercent
 
  dim buyhoding
  dim buytodayhoding
  dim sellhoding
  dim selltodayhoding
  dim buycost
  dim sellcost
  dim pnl
  dim usemargin
    
  dim orderid1
  dim consign1
  dim filled1
  dim remaining1
  dim ordertype1
  dim lmtprice1 
  
  dim orderid2
  dim consign2
  dim filled2
  dim remaining2
  dim ordertype2
  dim lmtprice2
  
   dim orderid3
  dim consign3
  dim filled3
  dim remaining3
  dim ordertype3
  dim lmtprice3
  
  dim orderid4
  dim consign4
  dim filled4
  dim remaining4
  dim ordertype4
  dim lmtprice4  
 
  lots=1
  account="888888"
  
  code=reportdata.label
  market=reportdata.marketname
  
  t0=code&"_trend0"
  t1=code&"_trend1"
  
  mybarpos=code&"_barpos"  
  
  set md=marketdata.getminutedata(code,market)
  
  barpos=md.count-1
  
  if barpos<=document.getextdata(mybarpos) then
  exit sub
  end if
  
  call document.setextdata(mybarpos,barpos)
  
  call document.setextdata(t1,document.getextdata(t0))
  
  if md.newprice(barpos)>md.newprice(barpos-1) then
   call document.setextdata(t0,1)
  end if
  
  if md.newprice(barpos)<md.newprice(barpos-1) then
   call document.setextdata(t0,-1)
  end if
 
  entrylongcond=document.getextdata(t0)=1 and document.getextdata(t1)=1 and md.newprice(barpos)>md.newprice(barpos-1)
  entryshortcond=document.getextdata(t0)=-1 and document.getextdata(t1)=-1 and md.newprice(barpos)<md.newprice(barpos-1)

'  sleeptime=2
'  
'  actiontime=code&"_actiontime"
'  
'  if document.getextstring(actiontime)="" then
'    actiondiff=sleeptime
'  else
'    actiondiff=datediff("s",document.getextstring(actiontime),now)  
'  end if
'  
'  if actiondiff<sleeptime then
'    exit sub
'  end if  
  
  call order.contract(code,market,multiplier,mintick,shortpercent,longpercent)
  call order.holdinginfobycode2(code,market,buyholding,buycost,buytodayholding,sellholding,sellcost,selltodayholding,pnl,usemargin,account)    

  call getpendingorder(orderid1,consign1,filled1,remaining1,0,ordertype1,lmtprice1,account,0,code,market)
  call getpendingorder(orderid2,consign2,filled2,remaining2,1,ordertype2,lmtprice2,account,2,code,market)
  call getpendingorder(orderid3,consign3,filled3,remaining3,1,ordertype3,lmtprice3,account,0,code,market)
  call getpendingorder(orderid4,consign4,filled4,remaining4,0,ordertype4,lmtprice4,account,2,code,market)
  
  'application.MsgOut("lmtprice1="&lmtprice1)
  application.MsgOut("lmtprice2="&lmtprice2)
  'application.MsgOut("lmtprice3="&lmtprice3)
  application.MsgOut("lmtprice4="&lmtprice4)
  
  a=orderid2>0 and md.askprice(barpos)<lmtprice2
  b=orderid4>0 and md.bidprice(barpos)>lmtprice4
  
  application.MsgOut("多头追价:"&a )
  application.MsgOut("空头追价:"&b )
  
  order.orderqueue=0
  
  offset=3*mintick   

  '多头条件成立时,将卖平和卖开未成交单撤单
  if entrylongcond then
   call order.cancelorder(orderid2)
   call order.cancelorder(orderid3)
   'call document.setextstring(actiontime,now)
  end if
  
  '空头条件成立时,将买开和买平未成交单撤单
  if entryshortcond then
   call order.cancelorder(orderid1)
   call order.cancelorder(orderid4)
   'call document.setextstring(actiontime,now)
  end if
  
  '多头开仓
  if buyholding=0 then
   if entrylongcond then
    if orderid1=0 then
     call order.buy(0,lots,md.bidprice(barpos),0,code,market,account,0)
     'call document.setextstring(actiontime,now)
    end if
   end if 
  end if   
  
  '多头平仓
  if buyholding>0 then   
   if entryshortcond then    
    if orderid2=0 then
     '多头止盈
     call order.sell(0,buyholding,md.askprice(barpos),0,code,market,account,0)
     'call document.setextstring(actiontime,now)
    end if    
   end if
   
   '多头追价
   if orderid2>0 and md.askprice(barpos)<lmtprice2 then
    order.orderqueue=1
   call order.cancelorder(orderid2)
   call order.sell(0,buyholding,md.askprice(barpos),0,code,market,account,0)
   'call document.setextstring(actiontime,now)   
   end if
   
   '多头止损
   if buycost-md.bidprice(barpos)>=offset then
    order.orderqueue=1
    call order.cancelorder(orderid2)
    call order.sell(0,buyholding,md.bidprice(barpos),0,code,market,account,0)
    'call document.setextstring(actiontime,now)
   end if    
  end if
  
  '空头开仓
  if sellholding=0 then   
   if entryshortcond then    
    if orderid3=0 then
     call order.buyshort(0,lots,md.askprice(barpos),0,code,market,account,0)
     'call document.setextstring(actiontime,now)
    end if  
   end if
  end if  
  
  '空头平仓
  if sellholding>0 then
   if entrylongcond then    
    if orderid4=0 then
     '空头止盈
     call order.sellshort(0,sellholding,md.bidprice(barpos),0,code,market,account,0)
     'call document.setextstring(actiontime,now)
    end if     
   end if
   
   '空头追价
   if orderid4>0 and md.bidprice(barpos)>lmtprice4 then
    order.orderqueue=1
   call order.cancelorder(orderid4)
   call order.sellshort(0,sellholding,md.bidprice(barpos),0,code,market,account,0)
   'call document.setextstring(actiontime,now)   
   end if
   
   '空头止损
   if md.askprice(barpos)-sellcost>=offset then
    order.orderqueue=1
    call order.cancelorder(orderid4)
    call order.sellshort(0,sellholding,md.askprice(barpos),0,code,market,account,0)
    'call document.setextstring(actiontime,now)
   end if    
  end if
end sub

sub getpendingorder(myorderid,myconsign,myfilled,myremaining,myaction,myordertype,mylmtprice,myaccount,mykaiping,mycode,mymarket)
  dim orderid
  dim consign
  dim filled
  dim remaining
  dim action
  dim ordertype
  dim lmtprice
  dim account
  dim kaiping
  dim code
  dim market
  
  for i=0 to order.ordernum2-1
    call order.orderinfo2(i,orderid,consign,filled,remaining,action,ordertype,lmtprice,account,kaiping,code,market)
        
    if code=mycode and market=mymarket and action=myaction and kaiping=mykaiping and account=myaccount then        
      myorderid=orderid
      myconsign=consign
      myfilled=filled
      myremaining=remaining
      myordertype=ordertype
      mylmtprice=lmtprice
      exit for 
    else
      myorderid=0
      myconsign=0
      myfilled=0
      myremaining=0
      myordertype=0
      mylmtprice=0  
    end if
  next
end sub

sub test2()

end sub


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


加好友 发短信
等级:论坛游侠 帖子:426 积分:1074 威望:0 精华:0 注册:2011/10/21 13:03:36
  发帖心情 Post By:2013/7/19 14:07:56 [只看该作者]

看不懂!想学点高频,但对高频没有一点概念,阿有人说说上面的高频什么思路啊!谢谢!


 回到顶部
美女呀,离线,留言给我吧!
jiangsen
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:992 积分:4305 威望:0 精华:0 注册:2012/8/3 10:50:38
  发帖心情 Post By:2013/7/20 11:53:07 [只看该作者]

我也不懂

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


加好友 发短信
等级:黑侠 帖子:993 积分:1787 威望:0 精华:5 注册:2012/11/28 17:37:20
  发帖心情 Post By:2013/9/3 19:23:04 [只看该作者]

我已经学到了,谢谢

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


加好友 发短信
等级:罗宾汉 帖子:11808 积分:20695 威望:0 精华:10 注册:2009/8/18 8:15:13
  发帖心情 Post By:2013/11/27 15:39:09 [只看该作者]

这是VBA的代码,用户要学习请到高级区看看精华帖子或者视频教程


金字塔—专业程序化软件提供商

金字塔-技术部

-----------------------------------------------------------------------------------------------------

工作时间:周一至周五 08:30 - 17:30   周末及法定节假日休息

Email:service@weistock.com
 回到顶部
帅哥哟,离线,有人找我吗?
sdrzhq
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

难度超大图片点击可在新窗口打开查看

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


加好友 发短信
等级:黑侠 帖子:830 积分:911 威望:0 精华:0 注册:2012/9/1 9:19:48
网络切换金字塔没有运行  发帖心情 Post By:2014/1/6 16:28:21 [只看该作者]

看不懂 图片点击可在新窗口打开查看

 回到顶部