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

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

  • 咨詢內(nèi)容: 原來(lái)在3.3版本正常的代碼現(xiàn)在升級(jí)3.4后老是提示編譯缺少history對(duì)象麻煩高手給看看是什么原因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) & " 當(dāng)天日線缺失" & 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'中午休市時(shí)不檢查      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) & " 當(dāng)天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應(yīng)為" & mins & vbCrLf      elseif aa>Kn then       strcon=strcon & code(pzindex) & " 當(dāng)天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應(yīng)為" & Kn & vbCrLf      end if     end if    end if   end if  next next

     

  • 金字塔客服: 是不是因?yàn)橛幸贡P(pán)后  xa的寫(xiě)法有問(wèn)題了Xa=cdate(today+mkt.opentime-cdate("1975-1-1")+cdate("00:0" & zhouqimin(zhouqi) & ":00"))

     

  • 用戶回復(fù):

    是否方便給出一個(gè)完整可以運(yùn)行的代碼.

    不過(guò)從現(xiàn)象看應(yīng)該是取到的history對(duì)象為空導(dǎo)致的,你可以調(diào)試一下,看看調(diào)取那個(gè)品種的數(shù)據(jù)取不到了

     

  • 網(wǎng)友回復(fù):

    Sub Chashuju2()'盤(pán)中數(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 '開(kāi)盤(pán)前8點(diǎn)59分先做一次賬戶檢查
      Set mail = CreateObject("WWSCommon.SmtpMail")
      strcon= ""
      if order.Account2(2,"你的ctp賬戶")<>1 then strcon = strcon & "交易帳號(hào)未登陸" & vbCrLf
      if application.ReceiveDataStatus = 0 then strcon = strcon & "金字塔數(shù)據(jù)接收未啟動(dòng)" & vbCrLf
         with mail
              .SenderName = "程序化監(jiān)督"
              .SenderAddress = "email@163.com"
              if strcomp(strcon,"")=0 then
               .Subject = "盤(pán)中檢測(cè)已準(zhǔn)備就緒" & cdate(date+time)
               strcon = "盤(pán)中檢測(cè)已準(zhǔn)備就緒"
              else
               .Subject = "盤(pán)中檢測(cè)異常" & 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'只在所交易的合約開(kāi)盤(pán)的時(shí)間內(nèi)做檢查,我交易合約是股指,所以定這個(gè)時(shí)間
     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 & "交易帳號(hào)未登陸" & vbCrLf
     if application.ReceiveDataStatus = 0 then strcon = strcon & "金字塔數(shù)據(jù)接收未啟動(dòng)" & 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登陸資金賬號(hào)")
     If Result = 1 Then
      if Round(BuyHoding-SellHoding)<>Round(Holding) then
       strcon = strcon & code(0) & "持倉(cāng)不同步,實(shí)際持倉(cāng)" & Round(BuyHoding-SellHoding) & "手,應(yīng)為" & 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) & " 當(dāng)天日線缺失" & 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'中午休市時(shí)不檢查
          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) & " 當(dāng)天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應(yīng)為" & mins & vbCrLf
          elseif aa>Kn then
           strcon=strcon & code(pzindex) & " 當(dāng)天" & zhouqimin(zhouqi) & "分鐘K線數(shù)目前為" & aa & ",應(yīng)為" & 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'進(jìn)對(duì)已加載的公式檢查狀態(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,所以公式最近一次運(yùn)行時(shí)間應(yīng)該在60秒內(nèi),如果你的公式是5分鐘的,那么這個(gè)時(shí)間要加大
        strcon = strcon & "策略" & i & "已超過(guò)" & secs & "秒沒(méi)有執(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

    '固定在上午和下午開(kāi)盤(pán)后的第一次檢查時(shí)發(fā)郵件通知,即使是一切正常時(shí)
       Set mail = CreateObject("WWSCommon.SmtpMail")
          with mail
               .SenderName = "程序化監(jiān)督"
               .SenderAddress = "email@163.com"
               .Subject = "公式已開(kāi)始運(yùn)行" & cdate(date+time)
           end with
           call mail.AddReceiver("139","13688888888@139.com")
           call mail.AddTextContent("公式已開(kāi)始運(yùn)行")
           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ù)異常時(shí),會(huì)有第1、第2、第5次通知;如果出現(xiàn)異常后,又恢復(fù)正常,異常通知次數(shù)會(huì)重新計(jì)算
       Set mail = CreateObject("WWSCommon.SmtpMail")
          with mail
               .SenderName = "程序化監(jiān)督"
               .SenderAddress = "email@163.com"
               .Subject = "盤(pán)中異常通知第" & 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)友回復(fù):

    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

     

    建議你多學(xué)習(xí)一下調(diào)試方法吧, 將code數(shù)組打印輸出一下你就能看到, 是因?yàn)槟銢](méi)有讀取到品種代碼引起的History 為空導(dǎo)致的

 

有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 1145508240  點(diǎn)擊這里給我發(fā)消息進(jìn)行 有償 編寫(xiě)!不貴!點(diǎn)擊查看價(jià)格!


【字體: 】【打印文章】【查看評(píng)論

相關(guān)文章

    沒(méi)有相關(guān)內(nèi)容
主站蜘蛛池模板: 日韩欧美色综合| а√天堂中文最新版地址| 琪琪色在线观看| 国产午夜无码视频免费网站| a级韩国乱理论片在线观看| 日韩欧美二区在线观看| 亚洲美女自拍视频| 色综合天天综合中文网| 国产精品国产三级国产普通话| 一本色道久久88综合亚洲精品高清 | 国产小视频你懂的| 99久re热视频这里只有精品6| 新版天堂中文在线8官网| 亚洲av无码欧洲av无码网站| 深夜A级毛片视频免费| 又黄又爽的视频免费看| 麻豆国产三级在线观看| 国产精品无码专区在线观看| а√最新版在线天堂| 日本特黄特黄刺激大片免费| 另类小说亚洲色图| 欧美一级久久久久久久大片| 在线播放免费播放av片| 中文字幕一精品亚洲无线一区| 爱情岛论坛亚洲永久入口口| 国产一区二区在线观看麻豆| 51影院成人影院| 在线免费污视频| 一日本道a高清免费播放| 日本按摩高潮a级中文片| 亚洲人成人77777网站| 美女邪恶色动图gig27报| 国产日韩欧美视频二区| 97精品国产高清自在线看超| 小小视频日本高清完整版| 久久久久久一品道精品免费看| 极品丝袜乱系列在线阅读| 亚洲欧美日韩中文字幕久久| 精品国产v无码大片在线观看| 国产乱人伦偷精品视频免下载 | 久久久xxxx|