Example #1
0
        public void GetPositionByKey_Multitrades_ValidQuantity()
        {
            var service = new PositionCacheService();

            service.SubmitOrder(new Order()
            {
                OrderType        = Common.OrderType.Buy,
                SecurityMasterId = 1,
                Portfolio        = "TraderX",
                Price            = 100.45M,
                Quantity         = 100
            });

            service.SubmitOrder(new Order()
            {
                OrderType        = Common.OrderType.Buy,
                SecurityMasterId = 1,
                Portfolio        = "TraderX",
                Price            = 200.00M,
                Quantity         = 100
            });

            var pos = service.GetPositionByKey(PositionKey.Create("TraderX", 1));

            Assert.AreEqual(200, pos.Quantity);
        }
Example #2
0
        public void GetPositionByKey_Multitrades_ChangeSide()
        {
            var service = new PositionCacheService();

            service.SubmitOrder(new Order()
            {
                OrderType        = Common.OrderType.Buy,
                SecurityMasterId = 1,
                Portfolio        = "TraderX",
                Price            = 100M,
                Quantity         = 100
            });

            service.SubmitOrder(new Order()
            {
                OrderType        = Common.OrderType.Sell,
                SecurityMasterId = 1,
                Portfolio        = "TraderX",
                Price            = 200.00M,
                Quantity         = 200
            });

            var pos = service.GetPositionByKey(PositionKey.Create("TraderX", 1));

            Assert.IsTrue(pos.IsShort);
        }
Example #3
0
        public void GetPositionByKey_InValidPortFolio()
        {
            var service = new PositionCacheService();

            service.SubmitOrder(new Order()
            {
                OrderType        = Common.OrderType.Buy,
                SecurityMasterId = 1,
                Portfolio        = "TraderX",
                Price            = 100.45M,
                Quantity         = 100
            });

            var pos = service.GetPositionByKey(PositionKey.Create("Trader", 1));

            Assert.IsNull(pos);
        }