金字塔獲取主力合約最簡(jiǎn)單的VBA代碼[金字塔模型]
- 內(nèi)容:
'本過程需要兩個(gè)參數(shù)
'1.sMarketCode市場(chǎng)代碼,如中金所是ZJ,上期所SQ,鄭商所ZQ,大連所DQ
'2.sStockPre品種代碼的前綴,如股指IF,螺紋鋼RB等,就是合約代碼的符號(hào),不要月份。
'調(diào)用方法:GetContractCode 'ZJ','IF' '返回股指期貨的主力合約
'調(diào)用上述過程之后,ZhuLiCode就保存了主力合約的代碼
'本方法是通過判斷那個(gè)合約的成交量與連續(xù)合約的成交量相等的方式來判斷主力合約的,跟金字塔內(nèi)部的方式一致。
public ZhuLiCode '主力合約代碼
Sub GetContractCode(sMarketCode,sStockPre) '根據(jù)市場(chǎng)編碼取得主力合約編碼
If sMarketCode="" then
sMarketCode="ZJ"
End if
n = marketdata.GetReportCount(sMarketCode)
For j = 0 To n - 1
Set report1 = marketdata.GetReportDataByIndex(sMarketCode, j)
suffixlabel = Right(report1.Label, 2)
If sStockPre=left(report1.Label,len(sStockPre)) then
If suffixlabel = "00" Then
ZhuLiVol=report1.volume
End If
If cdbl(suffixlabel) >= 1 And cdbl(suffixlabel) <= 12 Then
If report1.volume = ZhuLiVol Then
ZhuLiCode = report1.Label
'application.MsgOut ZhuLiCode
exit for
End If
End If
End if
Next
End Sub
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容