我正在研究具有FixAcceptor和FixInitiator的示例应用程序。我从发起者发送MarketDataRequest消息并从Acceptor发送MarketDataIncrementalRefresh消息但是收到NoMDEntries消息的FieldNotFound异常错误。我很确定我发送了来自接受者的错误信息但却无法找到。如果有任何身体可以帮助。
这是修复发起人消息
发送MarketDataRequest
string symbol =“MSFT”; //发送MarketData请求 QuickFix42.MarketDataRequest marketDataRequest = new QuickFix42.MarketDataRequest();
marketDataRequest.set(new MDReqID("1"));
marketDataRequest.set(new SubscriptionRequestType('1'));
marketDataRequest.set(new MarketDepth(1));
marketDataRequest.set(new MDUpdateType(1));
marketDataRequest.set(new AggregatedBook(true));
marketDataRequest.set(new NoMDEntryTypes(2));
QuickFix42.MarketDataRequest.NoMDEntryTypes group = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
group.set(new MDEntryType('0'));
marketDataRequest.addGroup(group);
group.set(new MDEntryType('1'));
marketDataRequest.addGroup(group);
marketDataRequest.set(new NoRelatedSym(1));
QuickFix42.MarketDataRequest.NoRelatedSym group2 = new QuickFix42.MarketDataRequest.NoRelatedSym();
group2.set(new Symbol(symbol));
marketDataRequest.addGroup(group2);
//Send message
Session.sendToTarget(marketDataRequest, sessionID);
FixAcceptor代码
public override void onMessage(QuickFix42.MarketDataRequest消息,SessionID会话) { var relatedSymbol = new QuickFix42.MarketDataRequest.NoRelatedSym();
Group g = message.getGroup(1, relatedSymbol);
string symbol=relatedSymbol.get(new Symbol()).getValue();
Console.WriteLine("Got marketdata request for Symbol {0}", symbol );
// Thread.Sleep(1000);
QuickFix42.MarketDataIncrementalRefresh prices = new QuickFix42.MarketDataIncrementalRefresh();
prices.set(new MDReqID("1"));
var mp = new QuickFix42.MarketDataIncrementalRefresh.NoMDEntries();
mp.set(new MDUpdateAction('0'));//tag 279
//price type
mp.set(new MDEntryType('0'));//tag:269
mp.set(new MDEntrySize(2345));
//Symbol
mp.set(new Symbol(symbol));
//Price of the Market Data Entry.
mp.set(new MDEntryPx(36.45d));
prices.addGroup(mp);
try
{
Session.sendToTarget(prices, session);
}
catch (SessionNotFound) { }
}
在FixAcceptor
中接收MarketDataIncrementalRefresh消息 public override void onMessage(MarketDataIncrementalRefresh message, SessionID session)
{
try
{
System.Console.WriteLine("MarketDataIncrementalRefresh : " + message.ToString());
MDReqID mdreqid = new MDReqID();
NoMDEntries nomdentries = new NoMDEntries();
QuickFix42.MarketDataIncrementalRefresh.NoMDEntries group
= new QuickFix42.MarketDataIncrementalRefresh.NoMDEntries();
MDUpdateAction mdupdateaction = new MDUpdateAction();
DeleteReason deletereason = new DeleteReason();
MDEntryType mdentrytype = new MDEntryType();
MDEntryID mdentryid = new MDEntryID();
Symbol symbol = new Symbol();
MDEntryOriginator mdentryoriginator = new MDEntryOriginator();
MDEntryPx mdentrypx = new MDEntryPx();
Currency currency = new Currency();
MDEntrySize mdentrysize = new MDEntrySize();
ExpireDate expiredate = new ExpireDate();
ExpireTime expiretime = new ExpireTime();
NumberOfOrders numberoforders = new NumberOfOrders();
MDEntryPositionNo mdentrypositionno = new MDEntryPositionNo();
Text text = new Text();
//message.get(mdreqid);
message.get(nomdentries);
int list = nomdentries.getValue();
if (message.isSetNoMDEntries())
for (uint i = 0; i < list; i++)
{
message.getGroup(i + 1, group);
//group.get(mdupdateaction);
//if (mdupdateaction.getValue() == '2')
// Console.WriteLine("Enter");
////group.get(deletereason);
//group.get(mdentrytype);
group.get(mdentryid);
group.get(symbol);
//group.get(mdentryoriginator);
if (mdupdateaction.getValue() == '0')
group.get(mdentrypx);
//group.get(currency);
//if (mdupdateaction.getValue() == '0')
// group.get(mdentrysize);
//group.get(expiredate);
//group.get(expiretime);
//if (mdupdateaction.getValue() == '0')
// group.get(numberoforders);
//group.get(mdentrypositionno);
//group.get(text);
//if (mdupdateaction.getValue() == '0')
//{
// for (int x = 0; x < mainapp.MDlist.Length; x++)
// {
// if (symbol.ToString() == mainapp.MDlist[x].Symbol)
// {
// if (mdentrytype.getValue() == '0')
// mainapp.MDlist[x].Bid = (float)mdentrypx.getValue();
// else if (mdentrytype.getValue() == '1')
// mainapp.MDlist[x].Ask = (float)mdentrypx.getValue();
// }
// }
//}
}
Console.WriteLine("Got Symbol {0} Price {1}", symbol.getValue(), mdentrypx.getValue());
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
但在
处收到错误FieldNotFoundExceptionmessage.getGroup(i + 1,group);
答案 0 :(得分:0)
int list = nomdentries.getValue();
你的问题是这一行。如果list不是0,则仅使用getGroup。您有此值且不需要此
if (message.isSetNoMDEntries())
你为什么不这样做
for (uint i = 1; i <= list; ++i)
{
message.getGroup(i, group);
你可以粘贴你收到的FIX消息,正确分解,而不是朦胧的字符串。如果你尝试分解你的FIX字符串,你会处于更好的位置。
您的邮件不完整,因为它缺少必填标记279.请检查此website,了解邮件中的必填字段和非必填字段。可以帮助您更轻松地找到错误。
答案 1 :(得分:0)
我解决了它并且问题是数据字典的路径错误并且没有指向正确的数据字典文件。