Esempio n. 1
0
        private QuickFix.FIX50.NewOrderSingle QueryNewOrderSingle44()
        {
            QuickFix.Fields.OrdType ordType = null;

            QuickFix.FIX50.NewOrderSingle newOrderSingle = new QuickFix.FIX50.NewOrderSingle(
                QueryClOrdID(),
                //  QuerySymbol(),
                QuerySide(),
                new TransactTime(DateTime.Now),
                ordType = QueryOrdType());

            newOrderSingle.Set(new HandlInst('1'));
            newOrderSingle.Set(QueryOrderQty());
            newOrderSingle.Set(QueryTimeInForce());
            if (ordType.getValue() == OrdType.LIMIT || ordType.getValue() == OrdType.STOP_LIMIT)
            {
                newOrderSingle.Set(QueryPrice());
            }
            if (ordType.getValue() == OrdType.STOP || ordType.getValue() == OrdType.STOP_LIMIT)
            {
                newOrderSingle.Set(QueryStopPx());
            }

            return(newOrderSingle);
        }
Esempio n. 2
0
        public void OnMessage(QuickFix.FIX50.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.FIX50.ExecutionReport exReport = new QuickFix.FIX50.ExecutionReport(
                new OrderID(GenOrderID()),
                new ExecID(GenExecID()),
                new ExecType(ExecType.FILL),
                new OrdStatus(OrdStatus.FILLED),
                side,
                new LeavesQty(0),
                new CumQty(orderQty.getValue()));

            exReport.Set(clOrdID);
            exReport.Set(symbol);
            exReport.Set(orderQty);
            exReport.Set(new LastQty(orderQty.getValue()));
            exReport.Set(new LastPx(price.getValue()));
            exReport.Set(new AvgPx(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());
            }
        }
Esempio n. 3
0
        private void QueryEnterOrder()
        {
            Console.WriteLine("\nNewOrderSingle");

            QuickFix.FIX50.NewOrderSingle m = QueryNewOrderSingle44();

            if (m != null && QueryConfirm("Send order"))
            {
                m.Header.GetString(Tags.BeginString);

                SendMessage(m);
            }
        }
Esempio n. 4
0
        public bool EnviarNuevaOrden(Transaccion transaccion)
        {
            var newOrderSingle = new QuickFix.FIX50.NewOrderSingle
            {
                OrderQty      = new OrderQty(transaccion.Cantidad),
                Symbol        = new Symbol(transaccion.Simbolo),
                ClOrdID       = new ClOrdID(transaccion.ID.ToString()),
                TransactTime  = new TransactTime(transaccion.FechaOrden),
                OrdType       = new OrdType(OrdType.LIMIT),
                Price         = new Price(Precio),
                TimeInForce   = new TimeInForce(TimeInForce.DAY),
                OrderCapacity = new OrderCapacity(OrderCapacity.AGENCY),
                Account       = new Account(NumeroCuenta)
            };

            bool ok = _fixEngineConnection.EnviarMensaje(newOrderSingle);

            return(ok);
        }
Esempio n. 5
0
        private void AddOrder(string exchange, string orderId, string symbol, bool isBuy, decimal amount, decimal price, ESymbolSource symbolSource)
        {
            var newOrder = new QuickFix.FIX50.NewOrderSingle();

            newOrder.ClOrdID = new QuickFix.Fields.ClOrdID(orderId);
            //newOrder.ExecInst
            newOrder.ExDestination    = new QuickFix.Fields.ExDestination(exchange);
            newOrder.Symbol           = new QuickFix.Fields.Symbol(symbol);
            newOrder.SecurityID       = new QuickFix.Fields.SecurityID(symbol);
            newOrder.SecurityIDSource = new QuickFix.Fields.SecurityIDSource(symbolSource.ToString("D"));
            newOrder.SecurityExchange = new QuickFix.Fields.SecurityExchange(exchange);
            newOrder.Side             = new QuickFix.Fields.Side(isBuy ? '1' : '2'); //BUY : SELL
            newOrder.TransactTime     = new QuickFix.Fields.TransactTime(DateTime.Now.ToUniversalTime());
            newOrder.OrderQty         = new QuickFix.Fields.OrderQty(amount);
            newOrder.OrdType          = new QuickFix.Fields.OrdType('2');     //LIMIT
            newOrder.Price            = new QuickFix.Fields.Price(price);
            newOrder.TimeInForce      = new QuickFix.Fields.TimeInForce('1'); //GTC
            newOrder.ClOrdLinkID      = new QuickFix.Fields.ClOrdLinkID(orderId);
            //newOrder.ExpireTime //GTD
            SendMessage(newOrder);
        }
Esempio n. 6
0
 public void OnMessage(QuickFix.FIX50.NewOrderSingle nos, SessionID sessionID)
 {
     ProcessNOS(nos, sessionID);
 }
Esempio n. 7
0
        private QuickFix.FIX50.NewOrderSingle QueryNewOrderSingle50()
        {
            QuickFix.Fields.OrdType ordType = null;

            QuickFix.FIX50.NewOrderSingle newOrderSingle = new QuickFix.FIX50.NewOrderSingle(
                QueryClOrdID(),
                QuerySide(),
                new TransactTime(DateTime.Now),
                ordType = QueryOrdType());

            newOrderSingle.Set(new HandlInst('1'));
            newOrderSingle.Set(QuerySymbol());
            newOrderSingle.Set(QueryOrderQty());
            newOrderSingle.Set(QueryTimeInForce());
            if (ordType.getValue() == OrdType.LIMIT || ordType.getValue() == OrdType.STOP_LIMIT)
                newOrderSingle.Set(QueryPrice());
            if (ordType.getValue() == OrdType.STOP || ordType.getValue() == OrdType.STOP_LIMIT)
                newOrderSingle.Set(QueryStopPx());

            QueryHeader(newOrderSingle.Header);
            return newOrderSingle;
        }