MarketDataIncrementalRefresh 消息中的 FieldNotFoundException 错误 QuickFix

发布于 2025-01-06 04:43:07 字数 6076 浏览 0 评论 0原文

我正在开发具有 FixAcceptor 和 FixInitiator 的示例应用程序。我从发起者发送 MarketDataRequest 消息,并从接受者发送 MarketDataIncrementalRefresh 消息,但收到 NoMDEntries 消息的 FieldNotFound 异常错误。我很确定我从接受者那里发送了错误的消息,但无法找到。如果有人可以的话请帮忙。

这是修复发起者消息

发送 MarketDataRequest

字符串符号 =“MSFT”; //发送市场数据请求 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 message, SessionID session) { 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);
        }
    }

但在

message.getGroup(i + 1, group); 处收到错误 FieldNotFoundException;

I am working on sample application which has FixAcceptor and FixInitiator. I am sending MarketDataRequest message from initiator and send MarketDataIncrementalRefresh message from Acceptor but getting error of FieldNotFound exception for NoMDEntries message. I am pretty sure I am send wrong message from acceptor but not able to find. please help if any body can.

This is Fix initiator message

Send MarketDataRequest

string symbol = "MSFT";
//Sending MarketData Requests
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 Code

public override void onMessage(QuickFix42.MarketDataRequest message, SessionID session)
{
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) { }


    }

Receiving MarketDataIncrementalRefresh message in FixAcceptor

 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);
        }
    }

but getting error FieldNotFoundException at

message.getGroup(i + 1, group);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黒涩兲箜 2025-01-13 04:43:07
int list = nomdentries.getValue();

你的问题是这一行。仅当 list 不为 0 时才使用 getGroup。您有此值但不需要此您

if (message.isSetNoMDEntries())

为什么不这样做

for (uint i = 1; i <= list; ++i)
{
    message.getGroup(i, group);

并且您可以粘贴您收到的 FIX 消息(正确分解),而不是模糊的字符串。如果您尝试分解 FIX 字符串,您会处于更好的位置。

您的消息不完整,因为缺少强制标签 279。请检查此网站,了解所需的内容以及消息中不是必填字段。将帮助您更轻松地发现错误。

int list = nomdentries.getValue();

Your problem is this line. Only use getGroup if list isn't 0. You have this value and you don't need this

if (message.isSetNoMDEntries())

And why aren't you doing this

for (uint i = 1; i <= list; ++i)
{
    message.getGroup(i, group);

And could you paste across a FIX message you receive, broken down properly, rather than a hazy string. You would be in a better position if you try breaking down your FIX string.

Your message is incomplete as it is missing a mandatory tag 279. Check this website for what are the required and not required fields in a message. Would help you in finding your error more easily.

寻找一个思念的角度 2025-01-13 04:43:07

我解决了这个问题,问题是数据字典的路径错误,并且没有指向正确的数据字典文件。

I resolved it and issue was path for data dictionary was wrong and was not point to right data dictionary file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文