コード例 #1
0
        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());
            }
        }
コード例 #2
0
        public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s)
        {
            Console.WriteLine("* Got a NewOrderSingle.  Responding with an ExecutionReport.");

            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());
            }
        }
コード例 #3
0
ファイル: Executor.cs プロジェクト: Jason6583/TradingUIDemo
        private void SendExecution(SessionID s, char ordStatus, char execType, QuickFix.FIX44.NewOrderSingle n, decimal leavesQty, decimal cumQty, decimal avgPx, decimal lastQty, decimal lastPrice)
        {
            QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport(
                new OrderID(GenOrderID()),
                new ExecID(GenExecID()),
                new ExecType(execType),
                new OrdStatus(ordStatus),
                n.Symbol, //shouldn't be here?
                n.Side,
                new LeavesQty(leavesQty),
                new CumQty(cumQty),
                new AvgPx(avgPx));

            exReport.ClOrdID = new ClOrdID(n.ClOrdID.getValue());
            exReport.Set(new LastQty(lastQty));
            exReport.Set(new LastPx(lastPrice));

            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());
            }
        }
コード例 #4
0
        public static List <QuickFix.FIX44.ExecutionReport> Fix44Rejection2ExecutionReportNOC(QuickFix.Message msgReject, QuickFix.FIX44.NewOrderCross noc)
        {
            try
            {
                QuickFix.FIX44.ExecutionReport er1 = new QuickFix.FIX44.ExecutionReport();
                QuickFix.FIX44.ExecutionReport er2 = new QuickFix.FIX44.ExecutionReport();
                er1.Set(new OrderID("NONE"));
                er2.Set(new OrderID("NONE"));
                if (noc.IsSetNoSides() && noc.NoSides.getValue() == 2)
                {
                    QuickFix.Group grpNoSides = noc.GetGroup(1, Tags.NoSides);
                    if (grpNoSides.IsSetField(Tags.ClOrdID))
                    {
                        er1.Set(new ClOrdID(grpNoSides.GetField(Tags.ClOrdID)));
                    }
                    er1.Set(new ExecID(DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                    er1.Set(new ExecType(ExecType.REJECTED));
                    er1.Set(new OrdStatus(OrdStatus.REJECTED));
                    if (grpNoSides.IsSetField(Tags.Account))
                    {
                        er1.Set(new Account(grpNoSides.GetField(Tags.Account)));
                    }
                    er1.Set(new Symbol(noc.GetField(Tags.Symbol)));
                    if (noc.IsSetField(Tags.SecurityID))
                    {
                        er1.Set(new SecurityID(noc.GetField(Tags.SecurityID)));
                    }
                    if (noc.IsSetField(Tags.SecurityIDSource))
                    {
                        er1.Set(new SecurityIDSource(noc.GetField(Tags.SecurityIDSource)));
                    }
                    er1.Set(new Side(grpNoSides.GetChar(Tags.Side)));
                    er1.Set(new OrderQty(grpNoSides.GetDecimal(Tags.OrderQty)));
                    if (noc.IsSetField(Tags.OrdType))
                    {
                        er1.Set(new OrdType(noc.GetChar(Tags.OrdType)));
                    }
                    if (noc.IsSetField(Tags.Price))
                    {
                        er1.Set(new Price(noc.GetDecimal(Tags.Price)));
                    }
                    er1.Set(new LeavesQty(0));
                    er1.Set(new CumQty(0));
                    er1.Set(new AvgPx(Decimal.Zero));
                    DateTime transact1 = DateTime.UtcNow;
                    er1.Set(new TransactTime(transact1));
                    if (msgReject.IsSetField(Tags.Text))
                    {
                        er1.Set(new Text(msgReject.GetField(Tags.Text)));
                    }

                    grpNoSides = noc.GetGroup(2, Tags.NoSides);
                    if (grpNoSides.IsSetField(Tags.ClOrdID))
                    {
                        er2.Set(new ClOrdID(grpNoSides.GetField(Tags.ClOrdID)));
                    }
                    er2.Set(new ExecID(DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                    er2.Set(new ExecType(ExecType.REJECTED));
                    er2.Set(new OrdStatus(OrdStatus.REJECTED));
                    if (grpNoSides.IsSetField(Tags.Account))
                    {
                        er2.Set(new Account(grpNoSides.GetField(Tags.Account)));
                    }
                    er2.Set(new Symbol(noc.GetField(Tags.Symbol)));
                    if (noc.IsSetField(Tags.SecurityID))
                    {
                        er2.Set(new SecurityID(noc.GetField(Tags.SecurityID)));
                    }
                    if (noc.IsSetField(Tags.SecurityIDSource))
                    {
                        er2.Set(new SecurityIDSource(noc.GetField(Tags.SecurityIDSource)));
                    }
                    er2.Set(new Side(grpNoSides.GetChar(Tags.Side)));
                    er2.Set(new OrderQty(grpNoSides.GetDecimal(Tags.OrderQty)));
                    if (noc.IsSetField(Tags.OrdType))
                    {
                        er2.Set(new OrdType(noc.GetChar(Tags.OrdType)));
                    }
                    if (noc.IsSetField(Tags.Price))
                    {
                        er2.Set(new Price(noc.GetDecimal(Tags.Price)));
                    }
                    er2.Set(new LeavesQty(0));
                    er2.Set(new CumQty(0));
                    er2.Set(new AvgPx(Decimal.Zero));
                    DateTime transact2 = DateTime.UtcNow;
                    er2.Set(new TransactTime(transact2));
                    if (msgReject.IsSetField(Tags.Text))
                    {
                        er2.Set(new Text(msgReject.GetField(Tags.Text)));
                    }
                }

                List <QuickFix.FIX44.ExecutionReport> ret = new List <QuickFix.FIX44.ExecutionReport>();
                ret.Add(er1);
                ret.Add(er2);
                return(ret);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44Rejection2ExecutionReportNOC(): " + ex.Message, ex);
                return(null);
            }
        }
コード例 #5
0
        public static QuickFix.FIX44.ExecutionReport Fix44Rejection2ExecutionReport(QuickFix.Message msgReject, QuickFix.Message msgOri)
        {
            try
            {
                QuickFix.FIX44.ExecutionReport er = new QuickFix.FIX44.ExecutionReport();
                if (msgOri.IsSetField(Tags.OrderID))
                {
                    er.Set(new OrderID(msgOri.GetString(Tags.OrderID)));
                }
                else
                {
                    er.Set(new OrderID("NONE"));
                }

                if (msgOri.IsSetField(Tags.ClOrdID))
                {
                    er.Set(new ClOrdID(msgOri.GetField(Tags.ClOrdID)));
                }
                if (msgOri.IsSetField(Tags.OrigClOrdID))
                {
                    er.Set(new OrigClOrdID(msgOri.GetField(Tags.OrigClOrdID)));
                }
                // Fazer atribuicao dos PartyIDs da mensagem original
                int len = msgOri.GetInt(Tags.NoPartyIDs);
                for (int i = 0; i < len; i++)
                {
                    Group grp = msgOri.GetGroup(i + 1, Tags.NoPartyIDs);
                    er.AddGroup(grp);
                }
                er.Set(new ExecID(DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                er.Set(new ExecType(ExecType.REJECTED));
                er.Set(new OrdStatus(OrdStatus.REJECTED));
                if (msgOri.IsSetField(Tags.Account))
                {
                    er.Set(new Account(msgOri.GetField(Tags.Account)));
                }
                er.Set(new Symbol(msgOri.GetField(Tags.Symbol)));
                if (msgOri.IsSetField(Tags.SecurityID))
                {
                    er.Set(new SecurityID(msgOri.GetField(Tags.SecurityID)));
                }
                if (msgOri.IsSetField(Tags.SecurityIDSource))
                {
                    er.Set(new SecurityIDSource(msgOri.GetField(Tags.SecurityIDSource)));
                }
                er.Set(new Side(msgOri.GetChar(Tags.Side)));
                er.Set(new OrderQty(msgOri.GetDecimal(Tags.OrderQty)));
                if (msgOri.IsSetField(Tags.OrdType))
                {
                    er.Set(new OrdType(msgOri.GetChar(Tags.OrdType)));
                }
                if (msgOri.IsSetField(Tags.Price))
                {
                    er.Set(new Price(msgOri.GetDecimal(Tags.Price)));
                }
                if (msgOri.IsSetField(Tags.StopPx))
                {
                    er.Set(new StopPx(msgOri.GetDecimal(Tags.StopPx)));
                }
                if (msgOri.IsSetField(Tags.TimeInForce))
                {
                    er.Set(new TimeInForce(msgOri.GetChar(Tags.TimeInForce)));
                }
                if (msgOri.IsSetField(Tags.ExpireDate))
                {
                    er.Set(new ExpireDate(msgOri.GetField(Tags.ExpireDate)));
                }
                er.Set(new LeavesQty(0));
                er.Set(new CumQty(0));
                er.Set(new AvgPx(Decimal.Zero));
                DateTime transact = DateTime.UtcNow;
                er.Set(new TransactTime(transact));
                if (msgOri.IsSetField(Tags.MaxFloor))
                {
                    er.Set(new MaxFloor(msgOri.GetDecimal(Tags.MaxFloor)));
                }
                if (msgOri.IsSetField(Tags.Memo))
                {
                    er.SetField(new Memo(msgOri.GetString(Tags.Memo)));
                }

                if (msgReject.IsSetField(Tags.Text))
                {
                    er.Set(new Text(msgReject.GetField(Tags.Text)));
                }
                if (msgReject.IsSetField(Tags.OrderID))
                {
                    er.Set(new OrderID(msgReject.GetField(Tags.OrderID)));
                }

                return(er);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44Rejection2ExecutionReport(): " + ex.Message, ex);
                return(null);
            }
        }
コード例 #6
0
ファイル: Executor.cs プロジェクト: ChuangYang/quickfixn
        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 = n.Price;
            ClOrdID clOrdID = n.ClOrdID;

            if (ordType.getValue() != OrdType.LIMIT)
                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.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("==unknown exception==");
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.StackTrace);
            }
        }