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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → 怎样用VBS实现指定账户权益低于90万时强行平仓?

   

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


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

主题:怎样用VBS实现指定账户权益低于90万时强行平仓?

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


加好友 发短信
等级:论坛游侠 帖子:150 积分:735 威望:0 精华:0 注册:2012/1/30 10:53:14
怎样用VBS实现指定账户权益低于90万时强行平仓?  发帖心情 Post By:2012/5/15 22:24:19 [只看该作者]

如题


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


加好友 发短信
等级:金字塔养老院 帖子:509 积分:2425 威望:0 精华:0 注册:2012/3/2 12:50:05
  发帖心情 Post By:2012/5/16 8:56:51 [只看该作者]

楼主可以打开帮助参考下VBA中的Order对象

另外软件内下单设置——止盈止损中中也是可以设置的


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


加好友 发短信
等级:论坛游侠 帖子:150 积分:735 威望:0 精华:0 注册:2012/1/30 10:53:14
  发帖心情 Post By:2012/5/16 11:28:16 [只看该作者]

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

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


加好友 发短信
等级:管理员 帖子:7302 积分:32559 威望:1000 精华:45 注册:2003/12/30 16:34:32
  发帖心情 Post By:2012/5/16 12:04:09 [只看该作者]

使用VBA编写的代码量较大,在此无法给你编写完整的,给出你一个实现的想法思路

 

1、你应该了解金字塔VBA的定时器功能,定期1秒检测帐户的动态权益,有关定时器的部分论坛已经很多讨论了,你可以自行搜索一下

2、这里给你摘抄部分的判断动态权益全部强平的部分代码

 

IsAlarm = 0'是否已经有过预警动作

 dynamicpower= order.Account2(6,account)'得到账户动态权益
 cash= order.Account2(3,account)'得到账户里的现金余额

'//////////////////////////////////////////////////////////////////////////////////////////达到全平警戒线 强平资金:103,5000        当前权益只有103.5W的时候强平当前所有持仓
 if dynamicpower<Forced_liquidation_capital and Count1 + Count2 > 0 then
     application.PlaySoundFile "OrderNotify.wav"
        IsAlarm = 1
  Forced=1
  
  if count1 > 0 Or Count2 > 0 then
   application.MsgOut "强平"&Account&"账户所有持仓"
   application.MsgOut "动态权益: "&dynamicpower
   application.MsgOut "强平资金: "&Forced_liquidation_capital
  
   Document.DebugFile "C:\OrderLog.txt","执行了强平:"&Account&"账户所有持仓", 1
  End if
  
'//////////////////////////////////////////////////////////////////////////////////////////全平操作
  dim BuyHoding
  dim BuyCost
  dim BuyTodayHoding
  dim SellHoding
  dim SellCost
  dim SellTodayHoding
  dim PNL
  dim UseMargin
  dim Code
  dim Market
    

 for i=0 to count1 - 1

  Result = Order.HoldingInfo2(i,BuyHoding,BuyCost,BuyTodayHoding,SellHoding,SellCost,SellTodayHoding,PNL,UseMargin ,Code,Market)
  If Result <> 1 Then
   exit sub
  End If
 
     set Report1 = marketdata.GetReportData(Code,Market)
     'application.MsgOut Report1.NewPrice

    if  BuyHoding<>0 then
     call order.Sell(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
     application.MsgOut "品种:"&Code & "   平多:"&BuyHoding &"  账户:"&account
    end if
  if  SellHoding<>0 then
     call order.Sellshort(1,SellHoding,Report1.NewPrice,0,Code,Market,account,0)
     application.MsgOut  "品种:"&Code & "    平空:"&SellHoding&"  账户:"&account   
  end if  
 next
 
 for i=0 to count2 - 1

  Result = Order.HoldingInfo(i, BuyHoding, BuyCost, BuyTodayHoding, SellHoding, SellCost, PNL, Code, Market)
  If Result <> 1 Then
   exit sub
  End If
 
     set Report1 = marketdata.GetReportData(Code,Market)
     'application.MsgOut Report1.NewPrice

    if  BuyHoding>0 then
     call order.Sell(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
     application.MsgOut "品种:"&Code & "   平多:"&BuyHoding &"  账户:"&account
  end if
  if  BuyHoding<0 then
     call order.Sellshort(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
     application.MsgOut "品种:"&Code & "   平空:"&abs(BuyHoding) &"  账户:"&account

  end if  
 next
    
end if


 回到顶部