首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Quickfixn :如何编写执行报告来存储文件‏

Quickfixn :如何编写执行报告来存储文件‏
EN

Stack Overflow用户
提问于 2014-01-31 07:17:24
回答 1查看 1.4K关注 0票数 0

我已经创建了一个应用程序来在客户机-服务器之间发送消息,而且我在服务器端遇到了问题。

我想在服务器端的存储文件夹中写入传入的NewOrderSingle message( .body extension file)文件。

newordersingle消息和executionreport消息被写入客户端的存储文件中。但在服务器端,我没有在存储文件中获得application messages(file with .body extension)

如何将传入的应用程序消息写入文件,而不是管理消息。

我的示例代码如下所示:

代码语言:javascript
复制
    public class clsFIXServer : QuickFix.MessageCracker, QuickFix.IApplication

    {
        public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionID)

        {
            Console.WriteLine("IN:  " + message);

            Crack(message, sessionID);
        }

         public void OnCreate(QuickFix.SessionID sessionID)

        {
        }

        public void OnLogon(QuickFix.SessionID sessionID)
        {  
        }
        public void OnLogout(QuickFix.SessionID sessionID)
        { 
        }
        public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionID)
        {  
        }
        public void ToApp(QuickFix.Message message, QuickFix.SessionID sessionId)
        {
            Console.WriteLine("OUT: " + message);
        }

     public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s)
    {
        Symbol symbol = n.Symbol;
        Side side = n.Side;
        OrdType ordType = n.OrdType;
        OrderQty orderQty = n.OrderQty;
        Price price = new Price(DEFAULT_MARKET_PRICE);
        ClOrdID clOrdID = n.ClOrdID;

        switch (ordType.getValue())
        {
            case OrdType.LIMIT:
                price = n.Price;
                if (price.Obj == 0)
                    throw new IncorrectTagValue(price.Tag);
                break;
            case OrdType.MARKET: break;
            default: throw new IncorrectTagValue(ordType.Tag);
        }

        QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport(
            new OrderID(GenOrderID()),
            new ExecID(GenExecID()),
            new ExecType(ExecType.FILL),
            new OrdStatus(OrdStatus.FILLED),
            symbol, //shouldn't be here?
            side,
            new LeavesQty(0),
            new CumQty(orderQty.getValue()),
            new AvgPx(price.getValue()));

        exReport.Set(clOrdID);
        exReport.Set(symbol);
        exReport.Set(orderQty);
        exReport.Set(new LastQty(orderQty.getValue()));
        exReport.Set(new LastPx(price.getValue()));

        if (n.IsSetAccount())
            exReport.SetField(n.Account);

        try
        {
            Session.SendToTarget(exReport, s);
        }
        catch (SessionNotFound ex)
        {
            Console.WriteLine("==session not found exception!==");
            Console.WriteLine(ex.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

创建newordersingle消息的客户端函数:-

代码语言:javascript
复制
 public void Run()

 {
    objEMSOrder = ((FIXFormatter.EMSOrder)messageQueue.Receive().Body);

        if (this._session.SessionID.BeginString == "FIX.4.4")

         {

    QuickFix.FIX44.NewOrderSingle m = objMessageCreator.NewOrderSingle44MessageCreator(objEMSOrder); 
         **//DLL FUNCTION THAT CREATES MESSAGE**      


         if (m != null)
             {
                m.Header.GetField(Tags.BeginString);
                SendMessage(m);
             }

          }

   }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-05 23:01:07

消息存储用于FIX会话协议的内部使用。它只存储传出消息,以便如果存在序列间隔,则可以重新发送先前发送的消息。您需要查看FileLogFactoryFileLog类。这些记录将同时记录传入和传出消息。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21474476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档