简体   繁体   English

Quickfixn:如何编写执行报告以存储文件

[英]Quickfixn : How to write execution report to store file‏

I have created a application to send messages between client-server and I am having a problem on server side. 我创建了一个在客户端-服务器之间发送消息的应用程序,服务器端出现问题。

I want to write the incoming NewOrderSingle message( .body extension file) files in store folder on server side. 我想将传入的NewOrderSingle message( .body extension file)文件写入服务器端的存储文件夹中。

The newordersingle message along with executionreport message get written into store file on client side. newordersingle消息与executionreport消息一起写入客户端的存储文件中。 but on server side I don't get application messages(file with .body extension) in store file. 但是在服务器端,我没有在存储文件中收到application messages(file with .body extension)文件)。

How to write the incoming application messages to the file and not the admin messages. 如何将传入的应用程序消息而不是管理员消息写入文件。

My sample code is as follows: 我的示例代码如下:

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

My client side function that creates the newordersingle message :- 我的客户端函数创建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);
             }

          }

   }

The message store is for internal use by the FIX session protocol. 消息存储库供FIX会话协议内部使用。 It only stores outgoing messages so that if there is a sequence gap is can resend previously sent messages. 它仅存储传出的消息,因此,如果存在序列间隔,可以重新发送先前发送的消息。 You want to look at the FileLogFactory and FileLog classes. 您要查看FileLogFactoryFileLog类。 Those will log both incoming and outgoing messages. 这些将记录传入和传出消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM