您現(xiàn)在的位置:程序化交易>> 期貨公式>> 金字塔等>> 金字塔知識>>正文內(nèi)容

原來在3.3版本正常的代碼現(xiàn)在升級3.4后老是提示編譯缺少history對象 [金字塔]

  • 咨詢內(nèi)容: 原來在3.3版本正常的代碼現(xiàn)在升級3.4后老是提示編譯缺少history對象麻煩高手給看看是什么原因for pzindex=0 To 5 step 1  for zhouqi = 0 to 5 step 1   if zhouqi<2 or zhouqi>4 then    set History = marketdata.GetHistoryData(code(pzindex),market(pzindex),zhouqi)    Xa=today    set mkt = marketdata.GetMarketInfo2(market(pzindex))    if zhouqi<2 then Xa=cdate(today+mkt.opentime-cdate("1975-1-1")+cdate("00:0" & zhouqimin(zhouqi) & ":00"))    a=History.GetPosFromDate(Xa)    aaa=History.GetPosFromDate(cdate(today+mkt.closetime-cdate("1975-1-1")))    copentime=cdate(mkt.opentime-cdate("1975-1-1"))    if zhouqi<2 then Kn = mkt.TradeSeconds / 60 / zhouqimin(zhouqi)        if zhouqi=5 then     if cdate(time)>cdate(copentime) and History.Date(aaa)<>cdate(today) then strcon=strcon & code(pzindex) & " 當天日線缺失" & vbCrLf    else     if History.Date(a)<cdate(today) then aa=aaa-a else aa=aaa-a+1     mins = DateDiff("n",cdate(copentime),cdate(time))     if mins>-1 and (cdate(time)<cdate("11:30:00") or cdate(time)>cdate("13:00:00")) then'中午休市時不檢查      if cdate(time)<cdate("11:30:00") then       mins = mins \ zhouqimin(zhouqi)+1      elseif cdate(time)>cdate("13:00:00") then       mins = mins \ zhouqimin(zhouqi)+1-90 \ zhouqimin(zhouqi)      end if      if mins<>aa and aa<Kn then       strcon=strcon & code(pzindex) & " 當天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應為" & mins & vbCrLf      elseif aa>Kn then       strcon=strcon & code(pzindex) & " 當天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應為" & Kn & vbCrLf      end if     end if    end if   end if  next next

     

  • 金字塔客服: 是不是因為有夜盤后  xa的寫法有問題了Xa=cdate(today+mkt.opentime-cdate("1975-1-1")+cdate("00:0" & zhouqimin(zhouqi) & ":00"))

     

  • 用戶回復:

    是否方便給出一個完整可以運行的代碼.

    不過從現(xiàn)象看應該是取到的history對象為空導致的,你可以調(diào)試一下,看看調(diào)取那個品種的數(shù)據(jù)取不到了

     

  • 網(wǎng)友回復:

    Sub Chashuju2()'盤中數(shù)據(jù)檢查
     today=Date()
     if Weekday(today)=1 or Weekday(today)=7 or  todaystop=1 then Exit Sub'星期6和7不檢查
     if cdate(time)>=cdate("08:59:00") and cdate(time)<=cdate("09:00:00") then '開盤前8點59分先做一次賬戶檢查
      Set mail = CreateObject("WWSCommon.SmtpMail")
      strcon= ""
      if order.Account2(2,"你的ctp賬戶")<>1 then strcon = strcon & "交易帳號未登陸" & vbCrLf
      if application.ReceiveDataStatus = 0 then strcon = strcon & "金字塔數(shù)據(jù)接收未啟動" & vbCrLf
         with mail
              .SenderName = "程序化監(jiān)督"
              .SenderAddress = "email@163.com"
              if strcomp(strcon,"")=0 then
               .Subject = "盤中檢測已準備就緒" & cdate(date+time)
               strcon = "盤中檢測已準備就緒"
              else
               .Subject = "盤中檢測異常" & cdate(date+time)
              end if
          end with
          call mail.AddReceiver("139","13688888888@139.com")
          call mail.AddTextContent(strcon)
          call mail.Sender("smtp.163.com","email@163.com","123456")
          Set mail = nothing
     end if
     if cdate(time)<cdate("09:15:00") or cdate(time)>cdate("15:15:00") then exit Sub'只在所交易的合約開盤的時間內(nèi)做檢查,我交易合約是股指,所以定這個時間
     dim code(6)
     dim market(6)
     dim zhouqimin(2)
     strcon= ""
     if application.ReceiveDataStatus = 0 then application.ReceiveData(1)
     Application.PeekAndPump
     if order.Account2(2,"你的ctp賬戶")<>1 then strcon = strcon & "交易帳號未登陸" & vbCrLf
     if application.ReceiveDataStatus = 0 then strcon = strcon & "金字塔數(shù)據(jù)接收未啟動" & vbCrLf
     code(0)=Document.GetExtString("股指交易合約")
     market(0)="ZJ"


     Holding = Document.GetExtData("IFHOLDING")
     dim BuyHoding
     dim BuyTodayHoding
     dim SellHoding
     dim SellTodayHoding
     dim BuyCost
     dim SellCost
     dim PNL
     Dim UseMargin
     Result = Order.HoldingInfoByCode2(code(0),market(0),BuyHoding,BuyCost,BuyTodayHoding,SellHoding,SellCost,SellTodayHoding,PNL,UseMargin,"你的ctp登陸資金賬號")
     If Result = 1 Then
      if Round(BuyHoding-SellHoding)<>Round(Holding) then
       strcon = strcon & code(0) & "持倉不同步,實際持倉" & Round(BuyHoding-SellHoding) & "手,應為" & Holding & "手" & vbCrLf
      end if
     End If

     code(1)=Document.GetExtString("股指主力合約")
     market(1)="ZJ"
     code(2)="000001"
     market(2)="SH"
     code(3)="1Z2016"
     market(3)="SH"
     code(4)="1Z2056"
     market(4)="SH"
     code(5)="000300"
     market(5)="SH"
     zhouqimin(0)=1
     zhouqimin(1)=5
     for pzindex=0 To 5 step 1
      for zhouqi = 0 to 5 step 1
       if zhouqi<2 or zhouqi>4 then
        set History = marketdata.GetHistoryData(code(pzindex),market(pzindex),zhouqi)
        Xa=today
        set mkt = marketdata.GetMarketInfo2(market(pzindex))
        if zhouqi<2 then Xa=cdate(today+mkt.opentime-cdate("1975-1-1")+cdate("00:0" & zhouqimin(zhouqi) & ":00"))
        a=History.GetPosFromDate(Xa)
        aaa=History.GetPosFromDate(cdate(today+mkt.closetime-cdate("1975-1-1")))
        copentime=cdate(mkt.opentime-cdate("1975-1-1"))
        if zhouqi<2 then Kn = mkt.TradeSeconds / 60 / zhouqimin(zhouqi)
        
        if zhouqi=5 then
         if cdate(time)>cdate(copentime) and History.Date(aaa)<>cdate(today) then strcon=strcon & code(pzindex) & " 當天日線缺失" & vbCrLf
        else
         if History.Date(a)<cdate(today) then aa=aaa-a else aa=aaa-a+1
         mins = DateDiff("n",cdate(copentime),cdate(time))
         if mins>-1 and (cdate(time)<cdate("11:30:00") or cdate(time)>cdate("13:00:00")) then'中午休市時不檢查
          if cdate(time)<cdate("11:30:00") then
           mins = mins \ zhouqimin(zhouqi)+1
          elseif cdate(time)>cdate("13:00:00") then
           mins = mins \ zhouqimin(zhouqi)+1-90 \ zhouqimin(zhouqi)
          end if
          if mins<>aa and aa<Kn then
           strcon=strcon & code(pzindex) & " 當天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應為" & mins & vbCrLf
          elseif aa>Kn then
           strcon=strcon & code(pzindex) & " 當天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應為" & Kn & vbCrLf
          end if
         end if
        end if
       end if
      next
     next
     
     secs = 100
     for i=0 to SigCount-1 step 1
      if states(i)=1 and (cdate(time)<cdate("11:30:00") or cdate(time)>cdate("13:00:00")) then'進對已加載的公式檢查狀態(tài),中午休市不檢查
       secs = DateDiff("s",cdate(newtime(i)),cdate(time))
       if cdate(time)>cdate("09:31:00") and secs>60 then '由于我的所有公式均是1分鐘調(diào)用一次VBA函數(shù)READSIG,所以公式最近一次運行時間應該在60秒內(nèi),如果你的公式是5分鐘的,那么這個時間要加大
        strcon = strcon & "策略" & i & "已超過" & secs & "秒沒有執(zhí)行" & vbCrLf
       end if
      end if
     next
     
     if strcomp(strcon,"")=0 then
      errorcount=0
      if (cdate(time)<cdate("09:16:05") or (cdate(time)>cdate("13:00:00") and cdate(time)<cdate("13:01:05"))) and secs<120 then

    '固定在上午和下午開盤后的第一次檢查時發(fā)郵件通知,即使是一切正常時
       Set mail = CreateObject("WWSCommon.SmtpMail")
          with mail
               .SenderName = "程序化監(jiān)督"
               .SenderAddress = "email@163.com"
               .Subject = "公式已開始運行" & cdate(date+time)
           end with
           call mail.AddReceiver("139","13688888888@139.com")
           call mail.AddTextContent("公式已開始運行")
           call mail.Sender("smtp.163.com","email@163.com","123456")
           Set mail = nothing
      end if
     else
      errorcount=errorcount+1
      if errorcount<3 or errorcount=5 then'連續(xù)異常時,會有第1、第2、第5次通知;如果出現(xiàn)異常后,又恢復正常,異常通知次數(shù)會重新計算
       Set mail = CreateObject("WWSCommon.SmtpMail")
          with mail
               .SenderName = "程序化監(jiān)督"
               .SenderAddress = "email@163.com"
               .Subject = "盤中異常通知第" & errorcount & "次 " & cdate(date+time)
           end with
           call mail.AddReceiver("139","13688888888@139.com")
           call mail.AddTextContent(strcon)
           call mail.Sender("smtp.163.com","email@163.com","123456")
           Set mail = nothing
          end if
        end if
    End Sub

     

  • 網(wǎng)友回復:

    or pzindex=0 To 5 step 1
      for zhouqi = 0 to 5 step 1
       if zhouqi<2 or zhouqi>4 then
        Application.MsgOut code(pzindex) & "--" & market(pzindex)
        set History = marketdata.GetHistoryData(code(pzindex),market(pzindex),zhouqi)
        Xa=today

     

    建議你多學習一下調(diào)試方法吧, 將code數(shù)組打印輸出一下你就能看到, 是因為你沒有讀取到品種代碼引起的History 為空導致的

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

可聯(lián)系技術人員 QQ: 1145508240  點擊這里給我發(fā)消息進行 有償 編寫!不貴!點擊查看價格!


【字體: 】【打印文章】【查看評論

相關文章

    沒有相關內(nèi)容
主站蜘蛛池模板: 四虎最新紧急更新地址| 在线免费观看你懂的| 亚洲一区二区精品视频| av区无码字幕中文色| 日韩毛片最新看| 亚洲精品夜夜夜妓女网| 窝窝午夜色视频国产精品东北| 成人毛片免费观看视频在线| 亚洲人成电影在线观看网| 精品97国产免费人成视频| 国产卡一卡二卡三卡四| 91啦中文成人| 尤物国产精品福利三区| 久久天天躁狠狠躁夜夜网站 | 亚洲乱码在线播放| 男人j进美女p动态图片| 国产精品亚洲专区在线播放| 一级特黄录像在线观看| 欧美大香线蕉线伊人图片| 免费高清资源黄网站在线观看| 高清欧美性猛交xxxx黑人猛交| 国模精品一区二区三区| 两个人看的www视频日本| 日韩三级一区二区| 偷自视频区视频真实在线| 视频免费1区二区三区| 天天影院成人免费观看| 亚洲乱码无限2021芒果| 熟妇人妻中文字幕无码老熟妇| 四虎永久免费影院在线| 黄色毛片小视频| 国产精品毛片va一区二区三区| jizzjizz18日本人| 成年女人免费视频播放体验区| 久久青草国产免费观看| 欧美性69式xxxx护士| 亚洲精品无码不卡在线播放| 精品久久欧美熟妇WWW| 国产720刺激在线视频| 91制片厂天美传媒鲸鱼传媒| 好男人社区神马www|