以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 高级功能研发区 (http://weistock.com/bbs/list.asp?boardid=5) ---- [求助]能把这个老代码改一下吗? (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=72371) |
-- 作者:bbking -- 发布时间:2014/11/25 21:20:06 -- [求助]能把这个老代码改一下吗? \'窗体启动时初始化编辑框内容 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 用来搜索主力合约的 但是没有搜索夜盘品种好像 谁能补充一下? |
-- 作者:yukizzc -- 发布时间:2014/11/26 10:00:41 -- marketName=Array("SQ","DQ","ZQ","ZJ","SY") 你这里夜盘市场有了啊,本地这边运行后有夜盘品种的 |
-- 作者:王锋 -- 发布时间:2014/11/26 13:46:27 -- 这个代码可能由于论坛限制,有些不全 |
-- 作者:bbking -- 发布时间:2014/11/27 13:18:52 -- 老大~论坛里以前有搜索主力合约的VBA代码 的~现在出了夜盘了~ 能否更新一下? |
-- 作者:bbking -- 发布时间:2014/11/27 13:21:42 -- 你们这几个股票指数一放进来~这个vba一运行老是搜出来好多股票指数 |
-- 作者:王锋 -- 发布时间:2014/11/27 13:21:47 -- 现在金字塔都自带这个功能了啊, 板块菜单上你都能看见 |
-- 作者:bbking -- 发布时间:2014/11/27 13:42:39 -- 才发现... 终于有个主力合约板块了 |