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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → [求助]关于VBS代码如何实现金字塔程序化

   

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


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

主题:[求助]关于VBS代码如何实现金字塔程序化

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


加好友 发短信 ateam
等级:论坛游侠 帖子:414 积分:0 威望:0 精华:0 注册:2016/12/8 10:33:23
[求助]关于VBS代码如何实现金字塔程序化  发帖心情 Post By:2016/12/19 13:53:23 [只看该作者]

以下是VBA的HELP文件范例,请问利用以下代码如何实现账户的程序化交易?还需要哪些步骤的操作?(打开交易账号等)

Sub TLStart()
'注册CF09和CF11品种
  call marketdata.RegReportNotify("CF09","ZQ")
  call marketdata.RegReportNotify("CF11","ZQ")
End Sub

Sub MARKETDATA_ReportNotify()
  '得到这两个品种的行情报价
  Set Report1 = marketdata.GetReportData("CF09","ZQ")
  Set Report2 = marketdata.GetReportData("CF11","ZQ")
'得到品种的持仓量等信息
  dim BuyHoding1
  dim BuyHlding2
  dim BuyTodayHoding1
  dim BuyTodayHoding2
  dim SellHoding1
  dim SellHoding2
  dim SellTodayHoding1
  dim SellTodayHoding2
  dim BuyCost
  dim SellCost
  dim PNL
  Dim UseMargin
  '取指定持仓品种信息
  call Order.HoldingInfoByCode2("CF09","ZQ",BuyHoding1,BuyCost,BuyTodayHoding1,SellHoding1,SellCost,SellTodayHoding1,PNL,UseMargin)
  call Order.HoldingInfoByCode2("CF11","ZQ",BuyHoding2,BuyCost,BuyTodayHoding2,SellHoding2,SellCost,SellTodayHoding2,PNL,UseMargin)
 
  '当差价出现大于1800时进行套利开仓
  '假设是09买 11卖
  Diff = Report1.SellPrice1 - Report2.BuyPrice1 '分别取卖价和买价计算差价 
  if Diff > 1800 and BuyHoding1 = 0 then
  call Order.Buy(0,1,Report1.SellPrice1,0,"CF09","ZQ","",0)
  call Order.BuyShort(0,1,Report2.BuyPrice1,0,"CF11","ZQ","",0)
  end if
  '当差价小于1000时进行套利平仓
  Diff = Report1.BuyPrice1 - Report2.SellPrice1
  if diff < 1000 and BuyHoding1 > 0 then
  call Order.Sell(0,1,Report1.BuyPrice1,0,"CF09","ZQ","",0)
  call Order.Sellshort(0,1,Report2.SellPrice1,0,"CF11","ZQ","",0)
  end if
End Sub

 回到顶部