Example #1
0
        public OrderRecord(QuickFix.FIX42.NewOrderSingle nos)
        {
            OriginalNOS = nos;

            decimal price = -1;

            if (nos.OrdType.Obj == QuickFix.Fields.OrdType.LIMIT && nos.IsSetPrice())
            {
                price = nos.Price.Obj;
            }

            ClOrdID = nos.ClOrdID.Obj;
            Symbol  = nos.Symbol.Obj;
            Side    = FixEnumTranslator.Translate(nos.Side);
            OrdType = FixEnumTranslator.Translate(nos.OrdType);
            Price   = price;
            Status  = "New";

            if (nos.IsSetField(167))
            {
                SecurityType = FixEnumTranslator.Translate(nos.SecurityType);
            }

            if (nos.IsSetField(201))
            {
                CallOrPut = FixEnumTranslator.Translate(nos.PutOrCall);
            }

            if (nos.IsSetField(202))
            {
                Strike = nos.StrikePrice.Obj;
            }
        }
Example #2
0
        public OrderRecord(QuickFix.FIX42.NewOrderSingle nos)
        {
            OriginalNOS = nos;

            decimal price = -1;

            if (nos.OrdType.Obj == QuickFix.Fields.OrdType.LIMIT && nos.IsSetPrice())
            {
                price = nos.Price.Obj;
            }

            ClOrdID = nos.ClOrdID.Obj;
            Symbol  = nos.Symbol.Obj;
            Side    = FIXApplication.FixEnumTranslator.Translate(nos.Side);
            OrdType = FIXApplication.FixEnumTranslator.Translate(nos.OrdType);
            Price   = price;
            Status  = "New";
        }
        public void OnMessage(QuickFix.FIX42.NewOrderSingle msg, QuickFix.SessionID session)
        {
            try
            {
                OrderFixBridge r;
                lock (locker_)
                    r = m_orders.AddOrGet(null, msg.ClOrdID.getValue(), session);

                if (r.Order != null)
                {
                    RejectNew(session, msg.Symbol.getValue(), msg.ClOrdID.getValue(), Convert.ToInt32(msg.OrderQty.getValue()), Converter.c(msg.Side), "ClOrdID '" + msg.ClOrdID + "'already exists !");
                    return;
                }

                QuickFixStaticAcceptor.FromFIX_SendOrder(
                    r,
                    msg.Symbol.getValue(),
                    Converter.c(msg.Side),
                    Converter.c(msg.OrdType),
                    msg.IsSetOrderQty() ? Convert.ToInt32(msg.OrderQty.getValue()) : 0,
                    msg.IsSetPrice() ? Convert.ToDouble(msg.Price.getValue()) : 0,
                    msg.IsSetStopPx() ? Convert.ToDouble(msg.StopPx.getValue()) : 0,
                    msg.IsSetText() ? msg.Text.getValue() : string.Empty
                    );

                if (r.Order == null)
                {
                    RejectNew(session, msg.Symbol.getValue(), msg.ClOrdID.getValue(), Convert.ToInt32(msg.OrderQty.getValue()), Converter.c(msg.Side), "NinjaTrader7 returned null on creating order (internal error)");
                    return;
                }
            }
            catch (Exception e)
            {
                RejectNew(session, msg.Symbol.getValue(), msg.ClOrdID.getValue(), Convert.ToInt32(msg.OrderQty.getValue()), Converter.c(msg.Side), e.Message);
            }
        }