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); }
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); }
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); }