private QuickFix.FIX42.NewOrderSingle createHeldOptionOrder(Model.OrderModel orderModel)
        {
            var order = new QuickFix.FIX42.NewOrderSingle(
                new ClOrdID(orderModel.messageId),
                new HandlInst('1'),
                new Symbol(orderModel.underlyingExchangeSymbol),
                StageOrdersToTTWPFLibrary.FixEnumTranslator.ToField(orderModel.side),
                new TransactTime(DateTime.Now),
                new OrdType(OrdType.LIMIT));

            order.SecurityType = StageOrdersToTTWPFLibrary.FixEnumTranslator.ToField(orderModel.securityType);

            order.SecurityExchange = new SecurityExchange(orderModel.underlyingExchange);

            order.SetField(new StringField(18203, orderModel.underlyingGateway));

            order.PutOrCall = StageOrdersToTTWPFLibrary.FixEnumTranslator.ToField(orderModel.optionType);

            order.StrikePrice = new StrikePrice(orderModel.optionStrikePrice);  //new StrikePrice(new decimal(207000));

            order.MaturityMonthYear = new MaturityMonthYear(orderModel.maturityMonthYear);

            order.OrderQty = new OrderQty(orderModel.orderQty);


            order.SetField(new CharField(11028, 'Y'));

            //order.SetField(new StringField(50, "TML1"));

            //order.SetField(new StringField(16142, "TML NORTH VANCOUVER"));

            order.SetField(new StringField(18220, orderModel.broker_18220));

            //order.SetField(new StringField(16106, orderModel.stagedOrderMessage));

            order.SetField(new CharField(16111, 'I'));

            order.Account = new Account(orderModel.acct);

            order.Price = new Price(orderModel.orderPrice);

            order.ExecInst = new ExecInst("5");


            fillOrderInfoForICE(order, orderModel);


            //OrderRecord r = new OrderRecord(order);
            //lock (_orderViewModel.ordersLock)
            //{
            //    _orderViewModel.Orders.Add(r);
            //}

            //if (_fixConnectionSystem.InitiatorRunning && _connectionViewModel.IsOrderConnected)
            //{
            //    QuickFix.Session.SendToTarget(order, _fixConnectionSystem.orderSession.SessionID);
            //}

            return(order);
        }
Пример #2
0
        public void DefaultBuyOrder()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            OrderViewModel vm = new OrderViewModel(context.App, new FIXApplication.NullFixStrategy());

            vm.SendBuyCommand.Execute(null);

            // messaging of sent order
            Assert.AreEqual(1, context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType].Count);
            QuickFix.FIX42.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType][0] as QuickFix.FIX42.NewOrderSingle;
            Assert.AreEqual("IBM", msg.Symbol.Obj);
            Assert.AreEqual(5, msg.OrderQty.Obj);
            Assert.AreEqual(QuickFix.Fields.OrdType.MARKET, msg.OrdType.Obj);
            Assert.AreEqual(QuickFix.Fields.Side.BUY, msg.Side.Obj);

            // what's in the grid
            Assert.AreEqual(1, vm.Orders.Count);
            OrderRecord o = vm.Orders.First();

            Assert.AreEqual("IBM", o.Symbol);
            Assert.AreEqual(-1, o.Price);
            Assert.AreEqual("Market", o.OrdType);
            Assert.AreEqual("Buy", o.Side);
        }
Пример #3
0
        /// <summary>
        /// Create a NewOrderSingle message.
        /// </summary>
        /// <param name="customFields"></param>
        /// <param name="orderType"></param>
        /// <param name="side"></param>
        /// <param name="symbol"></param>
        /// <param name="orderQty"></param>
        /// <param name="tif"></param>
        /// <param name="price">ignored if orderType=Market</param>
        /// <returns></returns>
        static public QuickFix.FIX42.NewOrderSingle NewOrderSingle(
            Dictionary <int, string> customFields,
            OrderType orderType, Side side, string symbol,
            int orderQty, TimeInForce tif, decimal price)
        {
            // hard-coded fields
            QuickFix.Fields.HandlInst fHandlInst = new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE);

            // from params
            QuickFix.Fields.OrdType      fOrdType      = FixEnumTranslator.ToField(orderType);
            QuickFix.Fields.Side         fSide         = FixEnumTranslator.ToField(side);
            QuickFix.Fields.Symbol       fSymbol       = new QuickFix.Fields.Symbol(symbol);
            QuickFix.Fields.TransactTime fTransactTime = new QuickFix.Fields.TransactTime(DateTime.Now);
            QuickFix.Fields.ClOrdID      fClOrdID      = GenerateClOrdID();

            QuickFix.FIX42.NewOrderSingle nos = new QuickFix.FIX42.NewOrderSingle(
                fClOrdID, fHandlInst, fSymbol, fSide, fTransactTime, fOrdType);
            nos.OrderQty    = new QuickFix.Fields.OrderQty(orderQty);
            nos.TimeInForce = FixEnumTranslator.ToField(tif);

            if (orderType == OrderType.Limit)
            {
                nos.Price = new QuickFix.Fields.Price(price);
            }

            // add custom fields
            foreach (KeyValuePair <int, string> p in customFields)
            {
                nos.SetField(new QuickFix.Fields.StringField(p.Key, p.Value));
            }

            return(nos);
        }
Пример #4
0
        private QuickFix.FIX42.NewOrderSingle QueryNewOrderSingle42()
        {
            QuickFix.Fields.OrdType ordType = null;

            QuickFix.FIX42.NewOrderSingle newOrderSingle = new QuickFix.FIX42.NewOrderSingle(
                QueryClOrdID(),
                new HandlInst('1'),
                QuerySymbol(),
                QuerySide(),
                new TransactTime(DateTime.Now),
                ordType = QueryOrdType());

            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);
        }
Пример #5
0
        public void TestApplicationExtension()
        {
            var mockApp = new MockApplicationExt();

            session = new QuickFix.Session(mockApp, new QuickFix.MemoryStoreFactory(), sessionID,
                                           new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(config), 0, new QuickFix.ScreenLogFactory(settings), new QuickFix.DefaultMessageFactory(), "blah");
            session.SetResponder(responder);
            session.CheckLatency = false;

            Logon();
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2));

            session.Next(order.ToString());

            Assert.That(mockApp.InterceptedMessageTypes.Count, Is.EqualTo(2));
            Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.LOGON));
            Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.NEWORDERSINGLE));
        }
Пример #6
0
        /// <summary>
        /// Create a NewOrderSingle message.
        /// </summary>
        /// <param name="customFields"></param>
        /// <param name="orderType"></param>
        /// <param name="side"></param>
        /// <param name="symbol"></param>
        /// <param name="orderQty"></param>
        /// <param name="tif"></param>
        /// <param name="price">ignored if orderType=Market</param>
        /// <returns></returns>
        static public QuickFix.FIX42.NewOrderSingle NewOrderSingle(
            Dictionary<int,string> customFields,
            OrderType orderType, Side side, string symbol,
            int orderQty, TimeInForce tif, decimal price)
        {
            // hard-coded fields
            QuickFix.Fields.HandlInst fHandlInst = new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE);
            
            // from params
            QuickFix.Fields.OrdType fOrdType = FixEnumTranslator.ToField(orderType);
            QuickFix.Fields.Side fSide = FixEnumTranslator.ToField(side);
            QuickFix.Fields.Symbol fSymbol = new QuickFix.Fields.Symbol(symbol);
            QuickFix.Fields.TransactTime fTransactTime = new QuickFix.Fields.TransactTime(DateTime.Now);
            QuickFix.Fields.ClOrdID fClOrdID = GenerateClOrdID();

            QuickFix.FIX42.NewOrderSingle nos = new QuickFix.FIX42.NewOrderSingle(
                fClOrdID, fHandlInst, fSymbol, fSide, fTransactTime, fOrdType);
            nos.OrderQty = new QuickFix.Fields.OrderQty(orderQty);
            nos.TimeInForce = FixEnumTranslator.ToField(tif);

            if (orderType == OrderType.Limit)
                nos.Price = new QuickFix.Fields.Price(price);

            // add custom fields
            foreach (KeyValuePair<int,string> p in customFields)
                nos.SetField(new QuickFix.Fields.StringField(p.Key, p.Value));

            return nos;
        }
        private void fillOrderInfoForICE(QuickFix.FIX42.NewOrderSingle order, OrderModel orderModel)
        {
            if (orderModel.TAG47_Rule80A.useTag)
            {
                order.Rule80A = new Rule80A(orderModel.TAG47_Rule80A.tagCharValue);
            }

            if (orderModel.TAG204_CustomerOrFirm.useTag)
            {
                order.CustomerOrFirm = new CustomerOrFirm(orderModel.TAG204_CustomerOrFirm.tagIntValue);
            }

            if (orderModel.TAG18205_TTAccountType.useTag)
            {
                order.SetField(new StringField(18205, orderModel.TAG18205_TTAccountType.tagStringValue));
            }

            if (orderModel.TAG440_ClearingAccount.useTag)
            {
                order.ClearingAccount = new ClearingAccount(orderModel.TAG440_ClearingAccount.tagStringValue);
            }

            if (orderModel.TAG16102_FFT2.useTag)
            {
                order.SetField(new StringField(16102, orderModel.TAG16102_FFT2.tagStringValue));
            }
        }
        private void displayOrderThreadSafe(QuickFix.FIX42.NewOrderSingle orderSingle)
        {
            try
            {
                //Trace.WriteLine(String.Format("Send New Order: Type={0} Side={1} Symbol=[{2}] Qty=[{3}] LimitPrice=[{4}] TIF={5}",
                //    this.OrderType.ToString(), side.ToString(), this.Symbol,
                //    this.OrderQtyString, this.LimitPriceString, this.TimeInForce.ToString()));

                //Dictionary<int, string> customFieldsDict = new Dictionary<int, string>();
                //foreach (CustomFieldRecord cfr in this.CustomFields)
                //    customFieldsDict[cfr.Tag] = cfr.Value;

                //int orderQty = int.Parse(this.OrderQtyString);
                //decimal limitPrice = decimal.Parse(this.LimitPriceString);

                //QuickFix.FIX42.NewOrderSingle nos = MessageCreator42.NewOrderSingle(
                //    customFieldsDict,
                //    this.OrderType, side, this.Symbol, orderQty, this.TimeInForce, limitPrice);

                OrderRecord r = new OrderRecord(orderSingle);
                lock (_ordersLock)
                {
                    //Orders.Add(r);
                    Orders.Insert(0, r);
                }

                //_qfapp.Send(nos);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to send order\n" + e.ToString());
            }
        }
Пример #9
0
        public void TestIgnorePossDupInResendRequest()
        {
            // Default is false
            Assert.That(session.IgnorePossDupResendRequests, Is.EqualTo(false));

            session.IgnorePossDupResendRequests = true;
            // Logon
            Logon();

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));
            // This will generate resend requests
            session.Send(order);

            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1);

            QuickFix.Message msg = new QuickFix.FIX42.ResendRequest(
                new QuickFix.Fields.BeginSeqNo(1),
                new QuickFix.Fields.EndSeqNo(0));
            msg.Header.SetField(new QuickFix.Fields.PossDupFlag(true));
            SendTheMessage(msg);

            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1);
        }
Пример #10
0
        public void MarketSell()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            OrderViewModel vm = new OrderViewModel(context.App, new FIXApplication.NullFixStrategy());

            vm.Symbol         = "pants";
            vm.OrderQtyString = "999";
            vm.SendSellCommand.Execute(null);

            // messaging of sent order
            Assert.AreEqual(1, context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType].Count);
            QuickFix.FIX42.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType][0] as QuickFix.FIX42.NewOrderSingle;
            Assert.AreEqual("pants", msg.Symbol.Obj);
            Assert.AreEqual(999, msg.OrderQty.Obj);
            Assert.AreEqual(QuickFix.Fields.Side.SELL, msg.Side.Obj);

            // what's in the grid
            Assert.AreEqual(1, vm.Orders.Count);
            OrderRecord o = vm.Orders.First();

            Assert.AreEqual("pants", o.Symbol);
            Assert.AreEqual(-1, o.Price);
            Assert.AreEqual("Market", o.OrdType);
            Assert.AreEqual("Sell", o.Side);
        }
Пример #11
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());
            }
        }
Пример #12
0
        public static QuickFix.FIX42.OrderCancelReplaceRequest OrderCancelReplaceRequest(
            Dictionary <int, string> customFields,
            QuickFix.FIX42.NewOrderSingle nos, int newQty, decimal newPrice)
        {
            QuickFix.FIX42.OrderCancelReplaceRequest ocrq = new QuickFix.FIX42.OrderCancelReplaceRequest(
                new QuickFix.Fields.OrigClOrdID(nos.ClOrdID.Obj),
                GenerateClOrdID(),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE),
                nos.Symbol,
                nos.Side,
                new QuickFix.Fields.TransactTime(DateTime.Now),
                nos.OrdType);

            ocrq.OrderQty = new QuickFix.Fields.OrderQty(newQty);

            if (nos.OrdType.Obj != QuickFix.Fields.OrdType.MARKET)
            {
                ocrq.Price = new QuickFix.Fields.Price(newPrice);
            }

            // other fields to relay
            ocrq.TimeInForce = nos.TimeInForce;

            // add custom fields
            foreach (KeyValuePair <int, string> p in customFields)
            {
                ocrq.SetField(new QuickFix.Fields.StringField(p.Key, p.Value));
            }

            return(ocrq);
        }
Пример #13
0
        public void ExtractFieldTypes()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX42.xml");

            QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle();

            string s = "8=FIX.4.2\x01" + "9=137\x01" + "35=D\x01" + "34=3\x01" + "49=CLIENT1\x01"
                       + "52=20110901-18:41:56.917\x01" + "56=EXECUTOR\x01" + "11=asdf\x01" + "21=1\x01"
                       + "38=5.5\x01" + "40=1\x01" + "54=1\x01" + "55=ibm\x01" + "59=1\x01" + "60=20110901-13:41:31.804\x01"
                       + "377=Y\x01" + "201=1\x01"
                       + "10=63\x01";

            n.FromString(s, true, dd, dd, _defaultMsgFactory);

            // string values are good?
            Assert.AreEqual("Y", n.SolicitedFlag.ToString());                    //bool, 377
            Assert.AreEqual("1", n.Side.ToString());                             //char, 54
            Assert.AreEqual("20110901-13:41:31.804", n.TransactTime.ToString()); //datetime, 60
            Assert.AreEqual("5.5", n.OrderQty.ToString());                       //decimal, 38
            Assert.AreEqual("1", n.PutOrCall.ToString());                        //int, 201
            Assert.AreEqual("asdf", n.ClOrdID.ToString());                       //string, 11

            // type-converted values are good?
            Assert.AreEqual(true, n.SolicitedFlag.getValue());
            Assert.AreEqual('1', n.Side.getValue());
            Assert.AreEqual(DateTime.Parse("2011-09-01 13:41:31.804"), n.TransactTime.getValue());
            Assert.AreEqual(5.5m, n.OrderQty.getValue());
            Assert.AreEqual(1, n.PutOrCall.getValue());
            Assert.AreEqual("asdf", n.ClOrdID.getValue());
        }
Пример #14
0
        public void LimitBuy()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            OrderViewModel vm = new OrderViewModel(context.App, new FIXApplication.NullFixStrategy());

            vm.OrderType        = FIXApplication.Enums.OrderType.Limit;
            vm.Symbol           = "LIM";
            vm.OrderQtyString   = "9";
            vm.LimitPriceString = "3.45";
            vm.SendBuyCommand.Execute(null);

            // messaging of sent order
            Assert.AreEqual(1, context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType].Count);
            QuickFix.FIX42.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX42.NewOrderSingle.MsgType][0] as QuickFix.FIX42.NewOrderSingle;
            Assert.AreEqual("LIM", msg.Symbol.Obj);
            Assert.AreEqual(9, msg.OrderQty.Obj);
            Assert.AreEqual(3.45m, msg.Price.Obj);
            Assert.AreEqual(QuickFix.Fields.OrdType.LIMIT, msg.OrdType.Obj);
            Assert.AreEqual(QuickFix.Fields.Side.BUY, msg.Side.Obj);

            // what's in the grid
            Assert.AreEqual(1, vm.Orders.Count);
            OrderRecord o = vm.Orders.First();

            Assert.AreEqual("LIM", o.Symbol);
            Assert.AreEqual(3.45m, o.Price);
            Assert.AreEqual("Limit", o.OrdType);
            Assert.AreEqual("Buy", o.Side);
        }
Пример #15
0
        private void QueryEnterOrder()
        {
            int numOfOrders = QueryNumOfOrders();

            Console.WriteLine("\nIssuing " + numOfOrders + " orders.");
            Queue <QuickFix.FIX42.NewOrderSingle> orders = CreateOrders(numOfOrders);

            m_OpenOrderIds.Clear();
            m_NumOfExeReportsReceived = 0;
            m_Stopwatch = Stopwatch.StartNew();
            int numOrdersSent = 0;

            while (orders.Count > 0)
            {
                QuickFix.FIX42.NewOrderSingle order = orders.Dequeue();
                ++numOrdersSent;
                lock (m_OpenOrderIds)
                    m_OpenOrderIds.Add(order.ClOrdID.getValue());
                SendMessage(order);

                if (numOrdersSent % 1000 == 0)
                {
                    Console.WriteLine("Order sent: " + numOrdersSent);
                }
            }
        }
Пример #16
0
        public void TestLastMsgSeqNumProcessed()
        {
            // Disabled by default
            Assert.That(!session.EnableLastMsgSeqNumProcessed);

            session.EnableLastMsgSeqNumProcessed = true;

            // Logon
            Logon();
            QuickFix.Message msg    = responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Last();
            int lastSeqNumProcessed = msg.Header.GetInt(QuickFix.Fields.Tags.LastMsgSeqNumProcessed);

            Assert.That(lastSeqNumProcessed == 1);

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));
            session.Send(order);

            msg = responder.msgLookup[QuickFix.Fields.MsgType.NEW_ORDER_D].Last();
            lastSeqNumProcessed = msg.Header.GetInt(QuickFix.Fields.Tags.LastMsgSeqNumProcessed);
            Assert.That(lastSeqNumProcessed == 1);
        }
 public void OnMessage(QuickFix.FIX42.NewOrderSingle n, SessionID s)
 {
     if (_executionEngine != null)
     {
         _executionEngine.HandleNewOrder(n);
     }
 }
Пример #18
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;
            }
        }
Пример #19
0
        private void SendOrder(Side side)
        {
            try
            {
                Trace.WriteLine(String.Format("Send New Order: Type={0} Side={1} Symbol=[{2}] Qty=[{3}] LimitPrice=[{4}] TIF={5}",
                                              this.OrderType.ToString(), side.ToString(), this.Symbol,
                                              this.OrderQtyString, this.LimitPriceString, this.TimeInForce.ToString()));

                Dictionary <int, string> customFieldsDict = new Dictionary <int, string>();
                foreach (CustomFieldRecord cfr in this.CustomFields)
                {
                    customFieldsDict[cfr.Tag] = cfr.Value;
                }

                int     orderQty   = int.Parse(this.OrderQtyString);
                decimal limitPrice = decimal.Parse(this.LimitPriceString);

                QuickFix.FIX42.NewOrderSingle nos = MessageCreator42.NewOrderSingle(
                    customFieldsDict,
                    this.OrderType, side, this.Symbol, orderQty, this.TimeInForce, limitPrice);

                OrderRecord r = new OrderRecord(nos);
                lock (_ordersLock)
                {
                    Orders.Add(r);
                }

                _qfapp.Send(nos);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to send order\n" + e.ToString());
            }
        }
Пример #20
0
        public void TestGapFillOnResend()
        {
            // Engineer a gap fill at the beginning of a re-send range, in the middle, and at the end
            Logon(); //seq 1
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.SenderCompID));

            int[] gapStarts  = new[] { 1, 5, 11 }; // 1st gap  from seq num 1 to 2 is just the Logon message
            int[] gapEnds    = new[] { 2, 8, 15 };
            int   orderCount = 0;

            for (int msgSeqNum = gapEnds[0]; msgSeqNum < gapStarts[1]; ++msgSeqNum)
            {
                order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum));
                session.Send(order);
                ++orderCount;
            } //seq 4, next is 5

            for (int msgSeqNum = gapStarts[1]; msgSeqNum < gapEnds[1]; ++msgSeqNum)
            {
                session.GenerateHeartbeat();
            } //seq 7, next is 8

            for (int msgSeqNum = gapEnds[1]; msgSeqNum < gapStarts[2]; ++msgSeqNum)
            {
                order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum));
                session.Send(order);
                ++orderCount;
            } //seq 10, next is 11

            for (int msgSeqNum = gapStarts[2]; msgSeqNum < gapEnds[2]; ++msgSeqNum)
            {
                session.GenerateHeartbeat();
            } // seq 11 - 14

            responder.msgLookup.Clear();
            SendResendRequest(1, 100);

            Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.NEWORDERSINGLE), orderCount);
            Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.SEQUENCE_RESET), gapStarts.Length);

            int count = -1;

            foreach (QuickFix.Message sequenceResestMsg in responder.msgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET])
            {
                Assert.AreEqual(sequenceResestMsg.GetString(QuickFix.Fields.Tags.GapFillFlag), "Y");
                Assert.AreEqual(sequenceResestMsg.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), gapStarts[++count]);
                Assert.AreEqual(sequenceResestMsg.GetInt(QuickFix.Fields.Tags.NewSeqNo), gapEnds[count]);
            }
        }
        private QuickFix.FIX42.NewOrderSingle createStagedFutureOrder(Model.OrderModel orderModel)
        {
            var order = new QuickFix.FIX42.NewOrderSingle(
                new ClOrdID(orderModel.messageId),
                new HandlInst('3'),
                new Symbol(orderModel.underlyingExchangeSymbol),
                StageOrdersToTTWPFLibrary.FixEnumTranslator.ToField(orderModel.side),
                new TransactTime(DateTime.Now),
                new OrdType(OrdType.LIMIT));

            //if(order.Side.Obj == Side.BUY)

            //switch (order.Side.Obj)
            //{
            //    case QuickFix.Fields.Side.BUY:
            //        Console.Write("t");
            //        break;
            //    case QuickFix.Fields.Side.SELL:
            //        Console.Write("t");
            //        break;
            //}



            order.SecurityType = StageOrdersToTTWPFLibrary.FixEnumTranslator.ToField(orderModel.securityType);

            order.SecurityExchange = new SecurityExchange(orderModel.underlyingExchange);

            order.SetField(new StringField(18203, orderModel.underlyingGateway));

            order.MaturityMonthYear = new MaturityMonthYear(orderModel.maturityMonthYear);

            order.OrderQty = new OrderQty(orderModel.orderQty);

            //order.Price = new Price(new decimal(207175));

            order.SetField(new CharField(11028, 'Y'));

            //order.SetField(new StringField(50, "TML1"));

            //order.SetField(new StringField(16142, "TML NORTH VANCOUVER"));

            order.SetField(new StringField(18220, orderModel.broker_18220));

            order.SetField(new StringField(16106, orderModel.stagedOrderMessage));

            order.SetField(new CharField(16111, 'I'));

            order.Account = new Account(orderModel.acct);

            order.Price = new Price(0);


            fillOrderInfoForICE(order, orderModel);


            return(order);
        }
Пример #22
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));
        }
Пример #23
0
 public void TestRequireLogon()
 {
     QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
         new QuickFix.Fields.ClOrdID("1"),
         new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
         new QuickFix.Fields.Symbol("IBM"),
         new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
         new QuickFix.Fields.TransactTime(),
         new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));
     // This should cause disconnect, because first message is something other than a logon.
     SendTheMessage(order);
     Assert.That(DISCONNECTED());
 }
Пример #24
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";
        }
Пример #25
0
        public void TestToAppDoNotSend()
        {
            Logon();
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            application.doNotSendException = new QuickFix.DoNotSend();
            session.Send(order);
            Assert.False(SENT_NOS());
        }
Пример #26
0
        public void AddGroupGetGroupTest()
        {
            var nos = new QuickFix.FIX42.NewOrderSingle();
            var noTradingSessions = new QuickFix.FIX42.NewOrderSingle.NoTradingSessionsGroup();
            noTradingSessions.SetField(new StringField(336, "OHHAI"));
            nos.AddGroup(noTradingSessions);
            var noTradingSessionsRE = nos.GetGroup(1, Tags.NoTradingSessions);
            Assert.That(noTradingSessionsRE.GetString(336), Is.EqualTo("OHHAI"));

            var nos2 = new QuickFix.FIX42.NewOrderSingle();
            var grp = new Group(200, 300);
            grp.SetField(new StringField(300, "Dude"));
            nos2.AddGroup(grp);
            Assert.That(nos2.GetGroup(1, 200).GetString(300), Is.EqualTo("Dude"));
        }
Пример #27
0
        public void SendNOSMessage()
        {
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));

            session.Next(order.ToString());
        }
Пример #28
0
        public void FromString_DoNotCorrectCounter()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml");

            QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle();

            string nul = "\x01";
            string s   = "8=FIX.4.2" + nul + "9=148" + nul + "35=D" + nul + "34=2" + nul + "49=TW" + nul + "52=20111011-15:06:23.103" + nul + "56=ISLD" + nul
                         + "11=ID" + nul + "21=1" + nul + "40=1" + nul + "54=1" + nul + "38=200.00" + nul + "55=INTC" + nul
                         + "386=3" + nul + "336=PRE-OPEN" + nul + "336=AFTER-HOURS" + nul
                         + "60=20111011-15:06:23.103" + nul
                         + "10=35" + nul;

            n.FromString(s, true, dd, dd, _defaultMsgFactory);
            Assert.AreEqual("386=3", n.NoTradingSessions.toStringField());
            StringAssert.Contains("386=3", n.ToString()); //don't correct it to 2, you bastard
        }
        private void SendAck(NewOrderSingle newOrderSingle)
        {
            var      exReport = new QuickFix.FIX42.ExecutionReport();
            OrderQty orderQty = newOrderSingle.OrderQty;

            exReport.CopyFromOrder(newOrderSingle);
            exReport.Set(new OrderID(GenOrderID()));
            exReport.Set(new ExecID(GenExecID()));
            exReport.Set(new ExecTransType(ExecTransType.NEW));
            exReport.Set(new ExecType(ExecType.NEW));
            exReport.Set(new OrdStatus(OrdStatus.NEW));
            exReport.Set(new LeavesQty(orderQty.getValue()));
            exReport.Set(new CumQty(0));
            exReport.Set(new AvgPx(0));

            SendExecReport(exReport);
        }
Пример #30
0
        public void AddGroupGetGroupTest()
        {
            var nos = new QuickFix.FIX42.NewOrderSingle();
            var noTradingSessions = new QuickFix.FIX42.NewOrderSingle.NoTradingSessionsGroup();

            noTradingSessions.SetField(new StringField(336, "OHHAI"));
            nos.AddGroup(noTradingSessions);
            var noTradingSessionsRE = nos.GetGroup(1, Tags.NoTradingSessions);

            Assert.That(noTradingSessionsRE.GetString(336), Is.EqualTo("OHHAI"));

            var nos2 = new QuickFix.FIX42.NewOrderSingle();
            var grp  = new Group(200, 300);

            grp.SetField(new StringField(300, "Dude"));
            nos2.AddGroup(grp);
            Assert.That(nos2.GetGroup(1, 200).GetString(300), Is.EqualTo("Dude"));
        }
        //TODO:  Move to background thread and pulse execreports
        public override void HandleNewOrder(Message newOrder)
        {
            Contract.Requires(_session != null);
            Contract.Requires(newOrder != null);
            Contract.Requires(newOrder is NewOrderSingle);
            NewOrderSingle newOrderSingle = (NewOrderSingle)newOrder;

            if (_executionEngineSettings.SendAck)
            {
                SendAck(newOrderSingle);
            }

            //TODO:  Add canceling mechanism
            if (_executionEngineSettings.SendExecs)
            {
                Task.Factory.StartNew(() => SendExecReport(newOrderSingle, _executionEngineSettings));
            }
        }
Пример #32
0
        public int addOrder(OrderStruct os)
        {
            OrderDAO odao = new OrderDAO();

            Console.WriteLine("Going to call DB");
            int ordNo = odao.insertOrder(os);

            ClOrdID OrdId  = new ClOrdID(Convert.ToString(os.ID));
            string  symbol = sanitiseField(os.symbol);
            var     order  = new QuickFix.FIX42.NewOrderSingle(OrdId, new HandlInst('1'), new Symbol(symbol), new Side(Side.BUY),
                                                               new TransactTime(DateTime.Now.ToUniversalTime()), new OrdType(OrdType.LIMIT));

            order.Price = new Price((decimal)os.price);
            order.SetField(new OrderQty(1));

            Session.SendToTarget(order, FixClient.MySess);
            return(ordNo);
        }
Пример #33
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";
        }
Пример #34
0
        public void CheckGroupCountTest()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml");

            QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle();

            string nul = Message.SOH;
            string s = "8=FIX.4.2" + nul + "9=148" + nul + "35=D" + nul + "34=2" + nul + "49=TW" + nul + "52=20111011-15:06:23.103" + nul + "56=ISLD" + nul
                + "11=ID" + nul + "21=1" + nul + "40=1" + nul + "54=1" + nul + "38=200.00" + nul + "55=INTC" + nul
                + "386=3" + nul + "336=PRE-OPEN" + nul + "336=AFTER-HOURS" + nul
                + "60=20111011-15:06:23.103" + nul
                + "10=35" + nul;

            n.FromString(s, true, dd, dd);

            //verify that FromString didn't correct the counter (if these fail, check if MessageTests::FromString_DoNotCorrectCounter() passes)
            Assert.AreEqual("386=3", n.NoTradingSessions.toStringField());
            StringAssert.Contains("386=3", n.ToString());

            Assert.Throws<QuickFix.RepeatingGroupCountMismatch>(delegate { dd.CheckGroupCount(n.NoTradingSessions, n, "D"); });
        }
Пример #35
0
        public void TestMaxMessagesInResendRequest()
        {
            // Default
            Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(0));

            session.MaxMessagesInResendRequest = 2500;
            // Logon
            Logon();

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5005));
            // This will generate resend requests
            session.Verify(order, true, false);

            // 3 resend requests
            //  2->2501
            //  2502->5001
            //  5002->5005
            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 3);
            QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(2501));

            msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2502));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5001));

            msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(5002));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5004));
        }
Пример #36
0
        public void TestMaxMessagesInResendRequest()
        {
            // Default
            Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(0));

            session.MaxMessagesInResendRequest = 2500;
            // Logon
            Logon();

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5005));
            // This will generate resend requests
            session.Verify(order, true, false);

            // 3 resend requests
            //  2->2501
            //  2502->5001
            //  5002->5005

            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1);
            QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(2501));

            // Jump forward to the end of the resend chunk with a fillgap reset message
            QuickFix.FIX42.SequenceReset reset = new QuickFix.FIX42.SequenceReset();
            reset.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            reset.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            reset.SetField(new QuickFix.Fields.GapFillFlag(true));

            reset.Header.SetField(new QuickFix.Fields.MsgSeqNum(2));
            reset.SetField(new QuickFix.Fields.NewSeqNo(2501));
            session.Next(reset);

            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2501));
            session.Next(order);

            // Should have triggered next resend (2502->5001), check this
            Console.WriteLine(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count);
            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1);
            msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2502));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5001));

            // Jump forward to the end of the resend chunk with a fillgap reset message
            reset.Header.SetField(new QuickFix.Fields.MsgSeqNum(2502));
            reset.SetField(new QuickFix.Fields.NewSeqNo(5001));
            session.Next(reset);

            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5001));
            session.Next(order);   // Triggers next resend (5002->5005)

            Console.WriteLine(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count);
            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1);
            msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue();
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(5002));
            Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5004));
        }
Пример #37
0
        public void TestLastMsgSeqNumProcessed()
        {
            // Disabled by default
            Assert.That(!session.EnableLastMsgSeqNumProcessed);

            session.EnableLastMsgSeqNumProcessed = true;

            // Logon
            Logon();
            QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Last();
            int lastSeqNumProcessed = msg.Header.GetInt(QuickFix.Fields.Tags.LastMsgSeqNumProcessed);
            Assert.That(lastSeqNumProcessed == 1);

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));
            session.Send(order);

            msg = responder.msgLookup[QuickFix.Fields.MsgType.NEW_ORDER_D].Last();
            lastSeqNumProcessed = msg.Header.GetInt(QuickFix.Fields.Tags.LastMsgSeqNumProcessed);
            Assert.That(lastSeqNumProcessed == 1);
        }
Пример #38
0
        public void TestIgnorePossDupInResendRequest()
        {
            // Default is false
            Assert.That(session.IgnorePossDupResendRequests, Is.EqualTo(false));

            session.IgnorePossDupResendRequests = true;
            // Logon
            Logon();

            // NOS
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));
            // This will generate resend requests
            session.Send(order);

            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1);

            QuickFix.Message msg = new QuickFix.FIX42.ResendRequest(
                new QuickFix.Fields.BeginSeqNo(1),
                new QuickFix.Fields.EndSeqNo(0));
            msg.Header.SetField(new QuickFix.Fields.PossDupFlag(true));
            SendTheMessage(msg);

            Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1);
        }
Пример #39
0
        public void ExtractFieldTypes()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX42.xml");

            QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle();

            string s = "8=FIX.4.2\x01" + "9=137\x01" + "35=D\x01" + "34=3\x01" + "49=CLIENT1\x01"
                + "52=20110901-18:41:56.917\x01" + "56=EXECUTOR\x01" + "11=asdf\x01" + "21=1\x01"
                + "38=5.5\x01" + "40=1\x01" + "54=1\x01" + "55=ibm\x01" + "59=1\x01" + "60=20110901-13:41:31.804\x01"
                + "377=Y\x01" + "201=1\x01"
                + "10=63\x01";
            n.FromString(s, true, dd, dd, _defaultMsgFactory);

            // string values are good?
            Assert.AreEqual("Y", n.SolicitedFlag.ToString()); //bool, 377
            Assert.AreEqual("1", n.Side.ToString()); //char, 54
            Assert.AreEqual("20110901-13:41:31.804", n.TransactTime.ToString()); //datetime, 60
            Assert.AreEqual("5.5", n.OrderQty.ToString()); //decimal, 38
            Assert.AreEqual("1", n.PutOrCall.ToString()); //int, 201
            Assert.AreEqual("asdf", n.ClOrdID.ToString()); //string, 11

            // type-converted values are good?
            Assert.AreEqual(true, n.SolicitedFlag.getValue());
            Assert.AreEqual('1', n.Side.getValue());
            Assert.AreEqual(DateTime.Parse("2011-09-01 13:41:31.804"), n.TransactTime.getValue());
            Assert.AreEqual(5.5m, n.OrderQty.getValue());
            Assert.AreEqual(1, n.PutOrCall.getValue());
            Assert.AreEqual("asdf", n.ClOrdID.getValue());
        }
Пример #40
0
 private Queue<QuickFix.FIX42.NewOrderSingle> CreateOrders(int n)
 {
     Queue<QuickFix.FIX42.NewOrderSingle> orders = new Queue<QuickFix.FIX42.NewOrderSingle>(n);
     for (int i = 0; i < n; i++) {
         ClOrdID cloudOrderId = new ClOrdID(Guid.NewGuid().ToString());
         HandlInst handlInst = new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION);
         Symbol symbol = new Symbol("MSFT");
         Side side = new Side(Side.BUY);
         TransactTime time = new TransactTime();
         OrdType orderType = new OrdType(OrdType.LIMIT);
         QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(cloudOrderId, handlInst, symbol, side, time, orderType);
         order.Account = new Account("Account");
         order.OrderQty = new OrderQty(100);
         order.ExDestination = new ExDestination("*");
         order.TimeInForce = new TimeInForce(TimeInForce.DAY);
         order.Price = new Price(50m);
         order.SecurityType = new SecurityType(SecurityType.COMMON_STOCK);
         orders.Enqueue(order);
     }
     return orders;
 }
Пример #41
0
        private QuickFix.FIX42.NewOrderSingle QueryNewOrderSingle42()
        {
            QuickFix.Fields.OrdType ordType = null;

            QuickFix.FIX42.NewOrderSingle newOrderSingle = new QuickFix.FIX42.NewOrderSingle(
                QueryClOrdID(),
                new HandlInst('1'),
                QuerySymbol(),
                QuerySide(),
                new TransactTime(DateTime.Now),
                ordType = QueryOrdType());

            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;
        }
Пример #42
0
        public void TestGapFillOnResend()
        {
            // Engineer a gap fill at the beginning of a re-send range, in the middle, and at the end
            Logon(); //seq 1
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.SenderCompID));

            int[] gapStarts = new[] { 1, 5, 11 }; // 1st gap  from seq num 1 to 2 is just the Logon message
            int[] gapEnds = new[] { 2, 8, 15 };
            int orderCount = 0;

            for (int msgSeqNum = gapEnds[0]; msgSeqNum < gapStarts[1]; ++msgSeqNum)
            {
                order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum));
                session.Send(order);
                ++orderCount;
            } //seq 4, next is 5

            for (int msgSeqNum = gapStarts[1]; msgSeqNum < gapEnds[1]; ++msgSeqNum)
            {
                session.GenerateHeartbeat();
            } //seq 7, next is 8

            for (int msgSeqNum = gapEnds[1]; msgSeqNum < gapStarts[2]; ++msgSeqNum)
            {
                order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum));
                session.Send(order);
                ++orderCount;
            } //seq 10, next is 11

            for (int msgSeqNum = gapStarts[2]; msgSeqNum < gapEnds[2]; ++msgSeqNum)
            {
                session.GenerateHeartbeat();
            } // seq 11 - 14

            responder.msgLookup.Clear();
            SendResendRequest(1, 100);

            Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.NEWORDERSINGLE), orderCount);
            Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.SEQUENCE_RESET), gapStarts.Length);

            int count = -1;
            foreach (QuickFix.Message sequenceResestMsg in responder.msgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET])
            {
                Assert.AreEqual(sequenceResestMsg.GetField(QuickFix.Fields.Tags.GapFillFlag), "Y");
                Assert.AreEqual(sequenceResestMsg.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), gapStarts[++count]);
                Assert.AreEqual(sequenceResestMsg.GetInt(QuickFix.Fields.Tags.NewSeqNo), gapEnds[count]);
            }
        }
Пример #43
0
        public void TestApplicationExtension()
        {
            var mockApp = new MockApplicationExt();
            session = new QuickFix.Session(mockApp, new QuickFix.MemoryStoreFactory(), sessionID,
                new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(config), 0, new QuickFix.ScreenLogFactory(settings), new QuickFix.DefaultMessageFactory(), "blah");
            session.SetResponder(responder);
            session.CheckLatency = false;

            Logon();
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2));

            session.Next(order.ToString());

            Assert.That(mockApp.InterceptedMessageTypes.Count, Is.EqualTo(2));
            Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.LOGON));
            Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.NEWORDERSINGLE));
        }
Пример #44
0
 public void TestRequireLogon()
 {
     QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
         new QuickFix.Fields.ClOrdID("1"),
         new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
         new QuickFix.Fields.Symbol("IBM"),
         new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
         new QuickFix.Fields.TransactTime(),
         new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));
     // This should cause disconnect, because first message is something other than a logon.
     SendTheMessage(order);
     Assert.That(DISCONNECTED());
 }
Пример #45
0
        public void TestToAppDoNotSend()
        {
            Logon();
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                 new QuickFix.Fields.ClOrdID("1"),
                 new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                 new QuickFix.Fields.Symbol("IBM"),
                 new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                 new QuickFix.Fields.TransactTime(),
                 new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            application.doNotSendException = new QuickFix.DoNotSend();
            session.Send(order);
            Assert.False(SENT_NOS());
        }
Пример #46
0
        /// <summary>
        /// Send a market order to flatten position 
        /// </summary>
        /// <param name="_account">account number must be read in from MGT.XML file</param>
        /// <param name="SecEx">Exchange</param>
        /// <param name="symbol">Exchange symbol for contract</param>
        /// <param name="secID">unique identifier supplied by the exchnage for this contract 
        /// For eurex this is the ticker and expiration</param>
        /// <param name="qty">order quantity</param>
        /// <param name="bs">buy or sell</param>
        /// <param name="gateway">TT gateway name</param>
        public void ttNewOrderSingle(string _account, string SecEx, string symbol, string secID, decimal qty, char bs, string gateway)
        {
            try
            {
                //log.WriteLog(string.Format("{0} {1} {2} {3} {4} {5} {6}", _account, SecEx, symbol, secID, qty, bs, gateway));

                QuickFix.FIX42.NewOrderSingle nos = new QuickFix.FIX42.NewOrderSingle();

                string id = uniqueID();
                nos.Set(new QuickFix.Fields.ClOrdID(id));
                inflightOrders.Add(id);

                nos.Set(new QuickFix.Fields.SecurityExchange(SecEx));
                nos.Set(new QuickFix.Fields.Symbol(symbol));
                nos.Set(new QuickFix.Fields.SecurityID(secID));

                nos.Set(new QuickFix.Fields.OrderQty(qty));
                nos.Set(new QuickFix.Fields.Side(bs));
                nos.Set(new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.MARKET));
                nos.Set(new QuickFix.Fields.Account(_account));

                //To add a TT custom tag to a QuickFix Message you must use SetString or similar
                //the Set method of the QuickFix.FIX42 message only allows setting standard FIX 4.2 fields
                //SetString(TTAccountType.FIELD, TT.TTAccountType.M1);
                //TODO is ACCOUNT_IS_HOUSE_TRADER_AND_IS_CROSS_MARGINED = M1??
                nos.CustomerOrFirm.setValue(QuickFix.Fields.AccountType.ACCOUNT_IS_HOUSE_TRADER_AND_IS_CROSS_MARGINED);

                //Alternative code that can only be used if FA is setup to accept tag 47 and 204 instead of custom tag 18205
                //nos.Set(new QuickFix.Fields.Rule80A(QuickFix.Fields.Rule80A.AGENCY_SINGLE_ORDER));
                //nos.Set(new QuickFix.Fields.CustomerOrFirm(QuickFix.Fields.CustomerOrFirm.CUSTOMER));

                //required for environments with multiple gateways with same products
                nos.ExchangeGateway.setValue(gateway);

                QuickFix.Session.SendToTarget(nos, orderSessionID);

            }
            catch (Exception ex)
            { log.WriteLog(ex.ToString()); }
        }
Пример #47
0
        public void SendNOSMessage()
        {
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                new QuickFix.Fields.ClOrdID("1"),
                new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                new QuickFix.Fields.Symbol("IBM"),
                new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                new QuickFix.Fields.TransactTime(),
                new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID));
            order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID));
            order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++));

            session.Next(order);
        }
Пример #48
0
        public void TestToAppResendDoNotSend()
        {
            Logon();
            QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(
                 new QuickFix.Fields.ClOrdID("1"),
                 new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER),
                 new QuickFix.Fields.Symbol("IBM"),
                 new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY),
                 new QuickFix.Fields.TransactTime(),
                 new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT));

            session.Send(order);
            Assert.True(SENT_NOS());

            responder.msgLookup.Remove(QuickFix.Fields.MsgType.NEWORDERSINGLE);
            application.doNotSendException = new QuickFix.DoNotSend();

            SendResendRequest(1, 0);
            Assert.False(SENT_NOS());
        }
Пример #49
0
        public void FromString_DoNotCorrectCounter()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml");

            QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle();

            string nul = "\x01";
            string s = "8=FIX.4.2" + nul + "9=148" + nul + "35=D" + nul + "34=2" + nul + "49=TW" + nul + "52=20111011-15:06:23.103" + nul + "56=ISLD" + nul
                + "11=ID" + nul + "21=1" + nul + "40=1" + nul + "54=1" + nul + "38=200.00" + nul + "55=INTC" + nul
                + "386=3" + nul + "336=PRE-OPEN" + nul + "336=AFTER-HOURS" + nul
                + "60=20111011-15:06:23.103" + nul
                + "10=35" + nul;

            n.FromString(s, true, dd, dd, _defaultMsgFactory);
            Assert.AreEqual("386=3", n.NoTradingSessions.toStringField());
            StringAssert.Contains("386=3", n.ToString()); //don't correct it to 2, you bastard
        }