以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  套利中合约转化问题  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=15383)

--  作者:sunset0920
--  发布时间:2012/8/22 10:52:26
--  套利中合约转化问题

论坛上,版主们讨论了如何判断主力合约。但是在跨期套利中,涉及到多个合约到期转换问题?

我的本意是通过成交量的排序来确定 相应主力合约、次月合约及季度合约,但结果却无法显示

sub heyuezhuanhuan()
Count = MarketData.GetReportCount("zj")
For i = 0 To Count-1
 Set d = CreateObject("Stock.Array")
 Set Report1 = MarketData.GetReportDataByIndex("zj",i)
 if Left(Report1.Label,2) = "IF" Then
   if Right(Report1.Label,2) >= "01" And Right(Report1.Label,2) <= "12" Then
    d.AddBack(Report1.Volume)
    d.sort(0)
For n = 1 To 12
 application.MsgOut d.GetAt(n)
Next
   End if
  end if
Next
End Sub

结果数据都为0,请求大师们帮忙?

 


--  作者:guotx2010
--  发布时间:2012/8/22 11:48:31
--  

sub heyuezhuanhuan()
dim d
Set d = CreateObject("Stock.Array")                \'位置变了,你的代码放在循环中了,每次都会赋值
Count = MarketData.GetReportCount("ZJ")
application.MsgOut "Count:" &Count
For i = 0 To Count-1
 Set Report1 = MarketData.GetReportDataByIndex("zj",i)
 if Left(Report1.Label,2) = "IF" Then
   if Right(Report1.Label,2) >= "01" And Right(Report1.Label,2) <= "12" Then
    application.MsgOut "Volume:" &Report1.Volume
    d.AddBack(cdbl(Report1.Volume))
   End if
  end if
Next
d.sort(0)
application.MsgOut "d.count:"&d.count
For n = 0 To d.count-1
 application.MsgOut "数组中的值:"&n+1&":"&d.GetAt(n)
Next

End Sub

 

多使用信息输出可以快速发现问题。


--  作者:sunset0920
--  发布时间:2012/8/22 12:15:54
--  帮忙实现一想法

谢谢 guo大师 

您在套利方面的确深有研究

 

该贴对我和与之类似问题童鞋将有很大帮助的

 

 


--  作者:guotx2010
--  发布时间:2012/8/22 12:49:25
--  
哈哈,欢迎多多交流,有思路就有出路呀。
--  作者:solarhe2006
--  发布时间:2012/8/22 13:13:38
--  

通过成交量的排序来确定 相应主力合约、次月合约及季度合约

能把代码改成按持仓量的吗?


--  作者:sunset0920
--  发布时间:2012/8/22 14:42:37
--  

金字塔 这方面好像有点缺陷  也或许自己未找到

我之前找了好久,发现对象没有持仓量,只有成交量(volume)和成交额(Amount)。

 

所以 只好退而求次之,使用成交量。好在成交量与持仓量差距不是很大 。

[此贴子已经被作者于2012-8-22 14:44:15编辑过]

--  作者:王锋
--  发布时间:2012/8/22 14:54:06
--  
持仓量问题已经在下个升级版中增加了
--  作者:guotx2010
--  发布时间:2012/8/22 15:10:51
--  
越来越强了
--  作者:sunset0920
--  发布时间:2012/8/27 14:42:12
--  

郭大师,还是关于合约转换的问题。原意本来是通过成交量排序来确定主力、次月、季月合约等,在您的帮助下,已经完成这一步,但问题是成交量排序出来之后,无法返回去寻找到相对应的合约?

 譬如,我要设最大成交量为主力合约,代码应该是IF09。但结果所有代码都是IF22.请问该如何处理?

 

 

 {if Right(Report1.Label,2) >= "01" And Right(Report1.Label,2) <= "12" and  Report1.Volume>0 Then} ,锁定为四个合约。


--  作者:guotx2010
--  发布时间:2012/8/27 17:30:24
--  

使用2维数组,来记录合约和对应的成交量,然后排序。