2011-08-12 126 views
0

我在嘗試訂閱外匯交易品種報價時經常遇到FieldNotFound異常。 雖然我添加了所有必需的標籤和更多。市場數據請求 - FieldNotFound異常

(它們是:。MDReqID,SubscriptionRequestType,MarketDepth,NoMDEntryTypes,MDEntryType,NoRelatedSym,象徵,這裏指定:http://www.onixs.biz/tools/fixdictionary/4.2/msgType_V_86.html

這裏是我的代碼:

Dim l_msg As New QuickFix42.MarketDataRequest(
New MDReqID(System.Guid.NewGuid.ToString), 
New SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES), 
New MarketDepth(1)) 

l_msg.setField(New MDUpdateType(1)) 
l_msg.setField(New AggregatedBook(False)) 
l_msg.setField(New NoMDEntryTypes(2)) 
l_msg.setField(New MDEntryType("0"c))  
l_msg.setField(New NoRelatedSym(1)) 
l_msg.setField(New Symbol("EUR/USD")) 

Session.sendToTarget(l_msg, SENDER_COMP_ID.Value, TARGET_COMP_ID.Value) 

缺少什麼我在這裏?

+0

我的壞。固定... – skaffman

回答

0

發現問題:

toApp方法是檢查使用PossDupFlag 重複而如果它不存在,FieldNotFound異常被拋出。

解決方案是要麼與檢查是否PossDupFlag存在,或發送之前加入該字段的消息的情況下把它包裝:

Public Sub toApp(p_msg As QuickFix.Message, Param1 As QuickFix.SessionID) Implements QuickFix.Application.toApp 
     Try 
      Dim l_possDupFlag As New QuickFix.PossDupFlag 

      If p_msg.isSetField(l_possDupFlag) Then 
       p_msg.getHeader().getField(l_possDupFlag) 
       If (l_possDupFlag.getValue()) Then 
        Dim donotsendEx As New QuickFix.DoNotSend 
        Throw donotsendEx 
       End If 
      End If    

     Catch ex As QuickFix.FieldNotFound 
      Log.WriteLine("toApp", ex.ToString) 
     Catch ex As Exception 
      Log.WriteLine("toApp", ex.ToString) 
     End Try 
    End Sub