Example #1
0
        //public void OnMessage(QuickFix.FIX42.SpreadMultiLegOrderSingle message, SessionID s)
        //{
        //    var noMdEntries = message.NoLegs.getValue();
        //    var group = new QuickFix.FIX42.SpreadMultiLegOrderSingle.NoLegsGroup();
        //    SendNewExecutionReport(message, s, noMdEntries, group);
        //    Thread.Sleep(100);
        //    SendFilledExecutionReport(message, s, noMdEntries, group);
        //}

        //private void SendNewExecutionReport(QuickFix.FIX42.SpreadMultiLegOrderSingle message, SessionID s, int noMdEntries, QuickFix.FIX42.SpreadMultiLegOrderSingle.NoLegsGroup group)
        //{
        //    Symbol symbol = new Symbol("L");
        //    Side side = new Side('L');
        //    OrdType ordType = message.OrdType;

        //    QuickFix.FIX42.ExecutionReport exReport = new QuickFix.FIX42.ExecutionReport(
        //            new OrderID(GenOrderID()),
        //            new ExecID(""),
        //            new ExecTransType(ExecTransType.NEW),
        //            new ExecType(ExecType.NEW),
        //            new OrdStatus(OrdStatus.NEW),
        //            symbol,
        //            side,
        //            new LeavesQty(0),
        //            new CumQty(0),
        //            new AvgPx(0));


        //    exReport.Set(message.ClOrdID);
        //    exReport.Set(message.TimeInForce);

        //    if (message.IsSetAccount())
        //        exReport.SetField(message.Account);

        //    for (int i = 1; i <= noMdEntries; i++)
        //    {
        //        var n = (QuickFix.FIX42.SpreadMultiLegOrderSingle.NoLegsGroup)message.GetGroup(i, group);

        //        var Exgroup = new QuickFix.FIX42.ExecutionReport.NoLegsGroup();

        //        Exgroup.LegOrderQty = new LegOrderQty(n.LegOrderQty.getValue());
        //        Exgroup.LegPrice = new LegPrice(n.LegPrice.getValue());
        //        Exgroup.LegSecurityID = new LegSecurityID(n.LegSecurityID.getValue());
        //        Exgroup.LegProduct = new LegProduct(n.LegProduct.getValue());
        //        message.AddGroup(Exgroup);
        //    }
        //    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());
        //    }

        //}

        //private void SendFilledExecutionReport(QuickFix.FIX42.SpreadMultiLegOrderSingle message, SessionID s, int noMdEntries, QuickFix.FIX42.SpreadMultiLegOrderSingle.NoLegsGroup group)
        //{
        //    for (int i = 1; i <= noMdEntries; i++)
        //    {
        //        var n = (QuickFix.FIX42.SpreadMultiLegOrderSingle.NoLegsGroup)message.GetGroup(i, group);
        //        SecurityID security = new SecurityID(n.LegSecurityID.getValue());
        //        Symbol symbol = new Symbol(n.LegSymbol.getValue());

        //        Side side = new Side(n.IsSetLegSide() ? n.LegSide.getValue() : 'B');
        //        OrdType ordType = message.OrdType;
        //        OrderQty orderQty = new OrderQty(n.LegOrderQty.getValue());
        //        ClOrdID clOrdID = message.ClOrdID;
        //        Price price = new Price(DEFAULT_MARKET_PRICE);
        //        TimeInForce tm = message.TimeInForce;
        //        switch (ordType.getValue())
        //        {
        //            case OrdType.LIMIT:
        //                price = new Price(n.LegPrice.getValue());
        //                if (price.Obj == 0)
        //                    throw new IncorrectTagValue(price.Tag);
        //                break;
        //            case OrdType.MARKET:
        //                break;
        //            default:
        //                throw new IncorrectTagValue(ordType.Tag);
        //        }

        //        QuickFix.FIX42.ExecutionReport exReport = new QuickFix.FIX42.ExecutionReport(
        //            new OrderID(GenOrderID()),
        //            new ExecID(DateTime.Now.ToString("yyyyMMddHHmmss") + GenExecID()),
        //            new ExecTransType(ExecTransType.NEW),
        //            new ExecType(ExecType.FILL),
        //            new OrdStatus(OrdStatus.FILLED),
        //            symbol,
        //            side,
        //            new LeavesQty(0),
        //            new CumQty(orderQty.getValue()),
        //            new AvgPx(price.getValue()));

        //        exReport.Set(security);
        //        exReport.Set(clOrdID);
        //        exReport.Set(orderQty);
        //        exReport.Set(new LastShares(orderQty.getValue()));
        //        exReport.Set(new LastPx(price.getValue()));
        //        exReport.Set(message.TimeInForce);
        //        if (message.IsSetAccount())
        //            exReport.SetField(message.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());
        //        }
        //    }
        //}

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

            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.FIX42.ExecutionReport exReport = new QuickFix.FIX42.ExecutionReport(
                new OrderID(GenOrderID()),
                new ExecID(GenExecID()),
                new ExecTransType(ExecTransType.NEW),
                new ExecType(ExecType.FILL),
                new OrdStatus(OrdStatus.FILLED),
                symbol,
                side,
                new LeavesQty(0),
                new CumQty(orderQty.getValue()),
                new AvgPx(price.getValue()));

            exReport.Set(clOrdID);
            exReport.Set(orderQty);
            exReport.Set(new LastShares(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());
            }
        }
Example #2
0
        /// <summary>
        ///  Translate FIX42 NewOrderSingle message to OrderData
        /// </summary>
        /// <param name="n">The message</param>
        /// <returns>The order data</returns>
        /// <exception cref="QuickFix.IncorrectTagValue"></exception>
        public static OrderData Translate(QuickFix.FIX42.NewOrderSingle n)
        {
            ValidateIsSupportedOrderType(n.OrdType);

            return(TranslateOrderImpl(n.Symbol,
                                      n.Side,
                                      n.OrdType,
                                      n.OrderQty,
                                      n.Price,
                                      n.ClOrdID,
                                      n.IsSetAccount() ? n.Account : null));
        }