示例#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 = FIXApplication.FixEnumTranslator.Translate(nos.Side);
            OrdType = FIXApplication.FixEnumTranslator.Translate(nos.OrdType);
            Price = price;
            Status = "New";
        }
示例#2
0
        public OrderRecord(QuickFix.FIX44.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 = Services.TranslateFixFields.Translate(nos.Side);
            OrdType = Services.TranslateFixFields.Translate(nos.OrdType);
            Price = price;
            Quantity = nos.OrderQty.Obj;
            Status = OrderStatus.New;
        }
        public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, QuickFix.SessionID session)
        {
            try
            {
                // qty set ?
                int qty = -1;
                if (msg.IsSetOrderQty()) qty = Convert.ToInt32(msg.OrderQty.getValue());
                else if (msg.IsSetCashOrderQty()) qty = Convert.ToInt32(msg.CashOrderQty.getValue());
                if (qty < 0)
                {
                    RejectCancelRequest(session, msg.ClOrdID, msg.OrigClOrdID, null, "Qty nor CashOrderQty field is not set", QuickFix.Fields.CxlRejReason.BROKER_OPTION, true);
                    return;
                }

                double price = (msg.IsSetPrice() ? Convert.ToDouble(msg.Price.getValue()) : 0);
                double stopPx = (msg.IsSetStopPx() ? Convert.ToDouble(msg.StopPx.getValue()) : 0);

                ProcessOrderCancelRequest(session, msg.ClOrdID, msg.OrigClOrdID, true, qty, price, stopPx);

            }
            catch (Exception e)
            {
                RejectCancelRequest(session, msg.ClOrdID, msg.OrigClOrdID, null, "OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, QuickFix.SessionID session) : internal error : " + e.ToString()
                , QuickFix.Fields.CxlRejReason.OTHER, true);

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