Exemple #1
0
        public void SingleLines()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            NewsSenderViewModel vm = new NewsSenderViewModel(context.App);

            vm.Headline       = "AAAAA";
            vm.IsLine1Enabled = true;
            vm.IsLine2Enabled = true;
            vm.IsLine3Enabled = true;
            vm.Line1Text      = "line1";
            vm.Line2Text      = "line2";
            vm.Line3Text      = "line3";
            vm.SendNewsCommand.Execute(null);

            vm.Headline       = "BBBBB";
            vm.IsLine2Enabled = false;
            vm.SendNewsCommand.Execute(null);

            Assert.AreEqual(2, context.Session.MsgLookup[QuickFix.FIX44.News.MsgType].Count);

            string msg1 = context.Session.MsgLookup[QuickFix.FIX44.News.MsgType][0].ToString();
            string msg2 = context.Session.MsgLookup[QuickFix.FIX44.News.MsgType][1].ToString();

            StringAssert.Contains(nul + "148=AAAAA" + nul, msg1);
            StringAssert.Contains(String.Format("{0}33=3{0}58=line1{0}58=line2{0}58=line3{0}", nul), msg1);
            StringAssert.Contains(nul + "148=BBBBB" + nul, msg2);
            StringAssert.Contains(String.Format("{0}33=2{0}58=line1{0}58=line3{0}", nul), msg2);
        }
Exemple #2
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);
        }
Exemple #3
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.FIX44.NewOrderSingle.MsgType].Count);
            QuickFix.FIX44.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX44.NewOrderSingle.MsgType][0] as QuickFix.FIX44.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);
        }
Exemple #4
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.FIX44.NewOrderSingle.MsgType].Count);
            QuickFix.FIX44.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX44.NewOrderSingle.MsgType][0] as QuickFix.FIX44.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);
        }
Exemple #5
0
        public void OneIncomingExecution()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            ExecutionViewModel vm = new ExecutionViewModel(context.App);

            QuickFix.FIX44.ExecutionReport ex = CreateExReport("order1", "exec1", QuickFix.Fields.ExecTransType.NEW,
                                                               QuickFix.Fields.ExecType.NEW, QuickFix.Fields.OrdStatus.NEW, "IBM", QuickFix.Fields.Side.BUY, 1.23m, 4.56m, 7.89m);

            context.App.FromApp(ex, context.Session.SessionID);

            Assert.AreEqual(1, vm.Executions.Count);
        }
        public void ConnectAndDisconnect()
        {
            UnitTestContext     context = new UnitTestContext();
            ConnectionViewModel vm      = new ConnectionViewModel(context.App);

            Assert.False(vm.IsConnected);

            vm.ConnectCommand.Execute(null);
            context.Login();
            Assert.True(vm.IsConnected);

            vm.DisconnectCommand.Execute(null);
            context.Logout();
            Assert.False(vm.IsConnected);
        }
Exemple #7
0
        public void HeadlineOnly()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            NewsSenderViewModel vm = new NewsSenderViewModel(context.App);

            vm.Headline = "AAAAA";
            vm.SendNewsCommand.Execute(null);

            Assert.AreEqual(1, context.Session.MsgLookup[QuickFix.FIX44.News.MsgType].Count);

            string msg = context.Session.MsgLookup[QuickFix.FIX44.News.MsgType].First().ToString();

            StringAssert.Contains(nul + "148=AAAAA" + nul, msg);
            StringAssert.Contains(nul + "33=0" + nul, msg);
        }
Exemple #8
0
        public void OrderUpdate()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

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

            // send an order with default arguments
            vm.SendBuyCommand.Execute(null);
            Assert.AreEqual(1, context.Session.MsgLookup[QuickFix.FIX44.NewOrderSingle.MsgType].Count);
            QuickFix.FIX44.NewOrderSingle msg = context.Session.MsgLookup[QuickFix.FIX44.NewOrderSingle.MsgType][0] as QuickFix.FIX44.NewOrderSingle;

            // verify grid content (redundant with earlier tests, but whatever)
            Assert.AreEqual(1, vm.Orders.Count);
            OrderRecord or = vm.Orders.First();

            Assert.AreEqual("IBM", or.Symbol);
            Assert.AreEqual(-1, or.Price);
            Assert.AreEqual("Market", or.OrdType);
            Assert.AreEqual("Buy", or.Side);
            Assert.AreEqual("New", or.Status);

            // send an execution report that will update the grid
            QuickFix.FIX44.ExecutionReport r = CreateExReport(
                or.ClOrdID, "foo", QuickFix.Fields.ExecTransType.NEW, QuickFix.Fields.ExecType.FILL,
                QuickFix.Fields.OrdStatus.FILLED, "IBM", QuickFix.Fields.Side.BUY, 0, 0, 0);
            r.LastPx  = new QuickFix.Fields.LastPx(999m);
            r.ClOrdID = new QuickFix.Fields.ClOrdID(msg.ClOrdID.Obj);

            context.App.FromApp(r, context.Session.SessionID);

            // check that it got changed
            Assert.AreEqual(1, vm.Orders.Count);
            Assert.AreEqual(999, or.Price);
            Assert.AreEqual("Filled", or.Status);
        }
Exemple #9
0
        public void ManyExecutions()
        {
            UnitTestContext context = new UnitTestContext();

            context.Login();

            ExecutionViewModel vm = new ExecutionViewModel(context.App);

            QuickFix.FIX44.ExecutionReport ex1 = CreateExReport("order1", "exec1", QuickFix.Fields.ExecTransType.NEW,
                                                                QuickFix.Fields.ExecType.NEW, QuickFix.Fields.OrdStatus.NEW, "IBM", QuickFix.Fields.Side.BUY, 1.23m, 4.56m, 7.89m);
            QuickFix.FIX44.ExecutionReport ex2 = CreateExReport("order1", "exec1", QuickFix.Fields.ExecTransType.CORRECT,
                                                                QuickFix.Fields.ExecType.NEW, QuickFix.Fields.OrdStatus.NEW, "ABC", QuickFix.Fields.Side.SELL, 1.23m, 4.56m, 7.89m);
            QuickFix.FIX44.ExecutionReport ex3 = CreateExReport("order1", "exec1", QuickFix.Fields.ExecTransType.CANCEL,
                                                                QuickFix.Fields.ExecType.NEW, QuickFix.Fields.OrdStatus.NEW, "XYZ", QuickFix.Fields.Side.BUY, 1.23m, 4.56m, 7.89m);

            context.App.FromApp(ex1, context.Session.SessionID);
            context.App.FromApp(ex2, context.Session.SessionID);
            context.App.FromApp(ex3, context.Session.SessionID);

            Assert.AreEqual(3, vm.Executions.Count);

            Assert.AreEqual("order1", vm.Executions[0].OrderID);
            Assert.AreEqual("New", vm.Executions[0].ExecTransType);
            Assert.AreEqual("IBM", vm.Executions[0].Symbol);
            Assert.AreEqual("Buy", vm.Executions[0].Side);

            Assert.AreEqual("order1", vm.Executions[1].OrderID);
            Assert.AreEqual("Correct", vm.Executions[1].ExecTransType);
            Assert.AreEqual("ABC", vm.Executions[1].Symbol);
            Assert.AreEqual("Sell", vm.Executions[1].Side);

            Assert.AreEqual("order1", vm.Executions[2].OrderID);
            Assert.AreEqual("Cancel", vm.Executions[2].ExecTransType);
            Assert.AreEqual("XYZ", vm.Executions[2].Symbol);
            Assert.AreEqual("Buy", vm.Executions[2].Side);
        }