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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → 发布vba追单(只为增加论坛信息资源)

   

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


  共有6981人关注过本帖平板打印复制链接

主题:发布vba追单(只为增加论坛信息资源)

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


加好友 发短信 czt
等级:蜘蛛侠 帖子:1445 积分:6114 威望:0 精华:3 注册:2012/1/16 10:31:19
发布vba追单(只为增加论坛信息资源)  发帖心情 Post By:2013/5/29 9:52:50 [只看该作者]

根据版主的代码,做了一个跟单的小插件,其中包含了正向和反向追单;还有相关的设置手数框。每次设置完之后,按下确定按钮,跟单账户就会乖乖的跟着被跟单账号下单了,结束程序代码只需按下shift+break即可。

 

'建议窗体对象内的代码只编写与本窗体事件有关的代码,不要使用作用于整个工程的变量及过程函数。
'''''''''''''''''''FX初始状态为-1 正向0 反向1
dim FX
dim ss
dim iCode
dim iMarket
dim SL
    SL = 0

'在vba运行之时,对控件进行赋值
sub application_vbastart()
    CoVer_combobox1.clear
    CoVer_combobox1.style=frmstyledropdownlist
    CoVer_ComboBox1.BoundColumn = 0 
    CoVer_ComboBox1.AddItem "正向"
    CoVer_ComboBox1.AddItem "反向"
    CoVer_ComboBox1.ListIndex=0
    FX = -1
    CoVer_Label2.Caption = " "
    ss = 0
end sub


'单击确认按钮之后确认跟单方向
Sub CoVer_CommandButton1_Click()
   
    if CoVer_ComboBox1.value = 0 then
    FX = 0
    ss = CoVer_textbox1.text       
    CoVer_Label2.caption = "正向跟单已确认 可点击最小化 " & " 跟踪手数为: " & ss

    end if
   
    if CoVer_ComboBox1.value = 1 then
    FX = 1 
    ss = CoVer_textbox1.text        
    CoVer_Label2.caption = "反向跟单已确认 可点击最小化" & " 跟踪手数为: " & ss
    end if
    CoVer.minbutton =true  
End Sub

'利用金字塔强大的order对象对每笔回报进行反馈
Sub ORDER_OrderStatusEx2(OrderID, Status, Filled, Remaining, Price, Code, Market, OrderType, Aspect, Kaiping, Account, AccountType)

''''''''''''''''''''''''跟从账户
if Status="Tradeing" and filled>0 and Account=CoVer_textbox2.text  then
  '正向跟踪
  IF FX =0 THEN
  if aspect=0 then
   if kaiping=0 then order.Buy 1,ss,0,0,code,market,CoVer_textbox3.text,0
   if kaiping>0 then order.sellshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
   'msgbox iCode & " " & iMarket
  end if
  if aspect=1 then
   if kaiping=0 then order.Buyshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
   if kaiping>0 then order.sell 1,ss,0,0,code,market,CoVer_textbox3.text,0
  end if
  end if
 
  '反向跟踪
  IF FX=1 THEN
   if aspect=1 then
   if kaiping=0 then order.Buy 1,ss,0,0,code,market,CoVer_textbox3.text,0
   if kaiping>0 then order.sellshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
   end if
   if aspect=0 then
   if kaiping=0 then order.Buyshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
   if kaiping>0 then order.sell 1,ss,0,0,code,market,CoVer_textbox3.text,0
  end if
  end if
END IF 
  

'未成交单查询,不断做提示,大家也可以+点代码 让他发出声音或者发群消息/邮件/短信,不断骚扰你
  IF Remaining<>0 then
     call application.SetTimer(1,1000)
  end if
End Sub

sub application_timer(id)
 dim Orderid   '订单ID
 dim Filled   '提交手数
 dim Remaining  '剩余手数
 dim Action   '买卖
 dim OrderType  '订单类型
 dim LmtPrice  '委托价
 dim Account   '账户
 dim Kaiping   '开平  
 dim i
     i=0
    
    if  id = 1 then
   
       if order.OrderNum2<>0 then

        For i=0 to order.OrderNum2-1         
            Call Order.OrderInfo2(i,OrderID,ConSign,Filled,Remaining,Action,OrderType,LmtPrice,Account,Kaiping,Code,Market)
           
            call application.MsgOut("有未成交单 市场代码: "&Market&" "&" "&"品种代码: " & Code)      
        Next
       end if
      
       if order.OrderNum2 = 0 then
        application.KillTimer(id)
       end if
    end if
   
   
   
end sub

sub application_vbaend()
    application.KillTimer(id)
end sub

 

 

 

 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:cover.rar


[本帖被加为精华]
 回到顶部