public void ExpectedUpdateOrder_ToString_test() { TradeInfo tradeInfo = new TradeInfo("ST12345-RF-01", "RTS-9.14_FT", "23409", 130000, -1, DateTime.Now, "82398"); PendingTradeInfo expectedUpdateOrder = new PendingTradeInfo(tradeInfo); string expected = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", expectedUpdateOrder.Portfolio, expectedUpdateOrder.Symbol, expectedUpdateOrder.OrderNo, expectedUpdateOrder.Price, expectedUpdateOrder.Amount, expectedUpdateOrder.DateTime, expectedUpdateOrder.TradeNo); Assert.AreEqual(expected, expectedUpdateOrder.ToString()); }
public void make_ExpectedUpdateOrder_test() { this.rawData.GetData <TradeInfo>().Add(this.tradeInfo); Assert.AreEqual(1, this.rawData.GetData <TradeInfo>().Count); Assert.AreEqual(1, this.rawData.GetData <PendingTradeInfo>().Count); PendingTradeInfo item = this.rawData.GetData <PendingTradeInfo>().Last(); Assert.AreEqual(this.tradeInfo.Portfolio, item.Portfolio); Assert.AreEqual(this.tradeInfo.Symbol, item.Symbol); Assert.AreEqual(this.tradeInfo.OrderNo, item.OrderNo); Assert.AreEqual(this.tradeInfo.Price, item.Price); Assert.AreEqual(this.tradeInfo.Amount, item.Amount); Assert.AreEqual(this.tradeInfo.DateTime, item.DateTime); Assert.AreEqual(this.tradeInfo.TradeNo, item.TradeNo); }
public override void Update(TradeInfo item) { if (HasDuplicate(item)) { return; } PendingTradeInfo expectedUpdateOrder = new PendingTradeInfo(item); this.logger.Log(String.Format("{0:dd/MM/yyyy H:mm:ss.fff}, {1}, {2}", BrokerDateTime.Make(DateTime.Now), this.GetType().Name, expectedUpdateOrder.ToString())); this.dataContext.GetData <PendingTradeInfo>().Add(expectedUpdateOrder); }
public void make_Trade_when_multiple_PendingTradeInfo_exists_test() { this.tradeInfo = new TradeInfo("ST12345-RF-01", "RTS-9.14_FT", "12345", this.order.Price, -5, BrokerDateTime.Make(DateTime.Now), "54321"); this.pendingTradeInfo = new PendingTradeInfo(this.tradeInfo); this.rawData.GetData <PendingTradeInfo>().Add(this.pendingTradeInfo); this.tradeInfo = new TradeInfo("ST12345-RF-01", "RTS-9.14_FT", "12345", this.order.Price, -5, BrokerDateTime.Make(DateTime.Now), "54325"); this.pendingTradeInfo = new PendingTradeInfo(this.tradeInfo); this.rawData.GetData <PendingTradeInfo>().Add(this.pendingTradeInfo); this.cookieToOrderNoAssociation = new CookieToOrderNoAssociation(this.order.Id, this.tradeInfo.OrderNo); this.rawData.GetData <CookieToOrderNoAssociation>().Add(this.cookieToOrderNoAssociation); Assert.AreEqual(1, this.rawData.GetData <CookieToOrderNoAssociation>().Count); Assert.AreEqual(0, this.rawData.GetData <PendingTradeInfo>().Count); Assert.AreEqual(2, this.tradingData.Get <IEnumerable <Trade> >().Count()); Trade trade = this.tradingData.Get <IEnumerable <Trade> >().Last(); Assert.AreEqual(this.tradeInfo.Amount, trade.Amount); Assert.AreEqual(this.tradeInfo.DateTime, trade.DateTime); Assert.AreEqual(this.tradeInfo.Portfolio, trade.Portfolio); Assert.AreEqual(this.tradeInfo.Price, trade.Price); Assert.AreEqual(this.order.Id, trade.OrderId); Assert.AreEqual(this.order, trade.Order); }
public void Setup() { this.rawData = new RawTradingDataContext(); this.tradingData = new TradingDataContext(); this.strategyHeader = new StrategyHeader(1, "Strategy description", "ST12345-RF-01", "RTS-9.14_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(this.strategyHeader); this.signal = new Signal(this.strategyHeader, BrokerDateTime.Make(DateTime.Now), TradeAction.Sell, OrderType.Market, 125000, 0, 0); this.order = this.tradingData.AddSignalAndItsOrder(this.signal); this.tradeInfo = new TradeInfo("ST12345-RF-01", "RTS-9.14_FT", "12345", this.order.Price, -1, BrokerDateTime.Make(DateTime.Now), "54321"); this.cookieToOrderNoAssociation = new CookieToOrderNoAssociation(this.order.Id, this.tradeInfo.OrderNo); this.pendingTradeInfo = new PendingTradeInfo(this.tradeInfo); this.handler = new MakeTradeOnCookieToOrderNoAssociation(this.rawData, this.tradingData, new NullLogger()); Assert.AreEqual(0, this.rawData.GetData <CookieToOrderNoAssociation>().Count); Assert.AreEqual(0, this.rawData.GetData <PendingTradeInfo>().Count); Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Trade> >().Count()); }
public void ExpectedUpdateOrder_constructor_test() { TradeInfo tradeInfo = new TradeInfo("ST12345-RF-01", "RTS-9.14_FT", "23409", 130000, -1, DateTime.Now, "82398"); PendingTradeInfo expectedUpdateOrder = new PendingTradeInfo(tradeInfo); Assert.IsInstanceOfType(expectedUpdateOrder, typeof(TradeInfo)); Assert.AreEqual(tradeInfo.Portfolio, expectedUpdateOrder.Portfolio); Assert.AreEqual(tradeInfo.Symbol, expectedUpdateOrder.Symbol); Assert.AreEqual(tradeInfo.Price, expectedUpdateOrder.Price); Assert.AreEqual(tradeInfo.Amount, expectedUpdateOrder.Amount); Assert.AreEqual(tradeInfo.DateTime, expectedUpdateOrder.DateTime); Assert.AreEqual(tradeInfo.OrderNo, expectedUpdateOrder.OrderNo); Assert.AreEqual(tradeInfo.TradeNo, expectedUpdateOrder.TradeNo); }