Quickfixn:如何将执行报告写入存储文件

时间:2014-01-31 07:17:25

标签: c# quickfix

我创建了一个应用程序来在客户端 - 服务器之间发送消息,而我正在使用 服务器端的问题。

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

newordersingle消息以及executionreport消息将写入客户端的商店文件中。但在服务器端,我没有在商店文件中获得application messages(file with .body extension)

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

我的示例代码如下:

    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消息: -

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

          }

   }

1 个答案:

答案 0 :(得分:1)

消息存储库供FIX会话协议内部使用。它只存储传出消息,这样如果存在序列间隙,则可以重新发送先前发送的消息。您想查看FileLogFactoryFileLog类。这些将记录传入和传出的消息。