[求助]能把這個老代碼改一下嗎? [金字塔]
- 咨詢內容:
'窗體啟動時初始化編輯框內容
Sub SearchMaincode_Load()
SearchMaincode_TextBoxType.Text = Document.GetPrivateProfileString("JZT","TextBoxType","概念","C:\JTZSetting.INI")
SearchMaincode_TextBoxBlock.Text = Document.GetPrivateProfileString("JZT","TextBoxBlock","主力合約","C:\JTZSetting.INI")
End Sub
Sub SearchMaincode_CommandButton1_Click()
SearchStart()
End Sub
'該函數查找主力合約
Sub SearchStart()
application.MsgOut Date &" " &Time& "檢索主力合約"
Dim marketName
Set dominantContract=CreateObject("Scripting.Dictionary") '創建一個字典
marketName=Array("SQ","DQ","ZQ","ZJ","SY")
prefixStockNameOld=""
c"
contractVol=0
'找到的主力合約代碼放這里
dim labels
dim markets
For j=0 To UBound(marketName)
n=marketData.GetReportCount(marketName(j))
For i=0 To n-1
Set reportData=marketdata.GetReportDataByIndex(marketName(j),i)
prefixStockNameCur=left(reportData.StockName,2)
suffixStockNameCur=right(reportData.StockName,2)
If suffixStockNameCur>="00" And suffixStockNameCur<"99" And reportData.Volume>0 Then
If prefixStockNameCur<>prefixStockNameOld Then
If contractLabel<>"" Then
dominantContract.Add contractMarket & contractLabel, 0
End If
prefixStockNameOld=prefixStockNameCur
contractLabel=reportData.Label
contractMarket=marketName(j)
contractVol=reportData.Volume
ElseIf reportData.Volume>contractVol then
contractLabel=reportData.Label
contractVol=reportData.Volume
End If
End If
Next
Next
dominantContract.Add contractMarket & contractLabel,0
labels=dominantContract.Keys
markets=dominantContract.Keys
FndCount = UBound(dominantContract.Keys)
Application.MsgOut "共找到"&FndCount&"個合約"
If FndCount > 0 Then
'整理一下數據,將市場和代碼分開
For j=0 To FndCount
markets(j) = left(labels(j),2)
labels(j) = right(labels(j),len(labels(j))-2)
Next
SaveBlockAndOpen labels, markets
Else
MsgBox "沒有找到主力合約"
End if
End Sub
'將找到的合約存于板塊,并打開動態盤
Sub SaveBlockAndOpen(labels, markets)
Document.WritePrivateProfileString "JZT","TextBoxType",SearchMaincode_TextBoxType.Text,"C:\JTZSetting.INI"
Document.WritePrivateProfileString "JZT","TextBoxBlock",SearchMaincode_TextBoxBlock.Text,"C:\JTZSetting.INI"
'保存到板塊
Set b = CreateObject("Stock.Block")
For j=0 To UBound(labels)
call b.AddStock(markets(j),labels(j))
Next
call b.toSave(SearchMaincode_TextBoxType.Text,SearchMaincode_TextBoxBlock.Text)
'打開動態顯示牌
Application.ActivateFrame "Report"
Set Table = Report.GetGridByName("上海指數").GetTable()
Table.SwitchBlock SearchMaincode_TextBoxBlock.Text, 1
End Sub
SearchMaincode
用來搜索主力合約的
但是沒有搜索夜盤品種好像
誰能補充一下?
- 金字塔客服:
marketName=Array("SQ","DQ","ZQ","ZJ","SY")
你這里夜盤市場有了啊,本地這邊運行后有夜盤品種的 - 用戶回復:
這個代碼可能由于論壇限制,有些不全
- 網友回復:
老大~論壇里以前有搜索主力合約的VBA代碼 的~現在出了夜盤了~
能否更新一下?
- 網友回復: 你們這幾個股票指數一放進來~這個vba一運行老是搜出來好多股票指數
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 1145508240 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容