public void Transaction_ImportTradesTransaction_import_three_orders() { StrategyHeader strategyHeader = new StrategyHeader(1, "First strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(strategyHeader); StrategyHeader strategy1 = new StrategyHeader(2, "Second strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(strategy1); StrategyHeader strategy2 = new StrategyHeader(3, "Third strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(strategy2); Signal s1 = new Signal(strategyHeader, BrokerDateTime.Make(DateTime.Now), TradeAction.Buy, OrderType.Limit, 150000, 0, 150000); s1.Id = 1; this.tradingData.Get <ICollection <Signal> >().Add(s1); Signal s2 = new Signal(strategyHeader, BrokerDateTime.Make(DateTime.Now), TradeAction.Sell, OrderType.Market, 150000, 0, 0); s2.Id = 2; this.tradingData.Get <ICollection <Signal> >().Add(s2); Signal s3 = new Signal(strategyHeader, BrokerDateTime.Make(DateTime.Now), TradeAction.Buy, OrderType.Stop, 150000, 150000, 0); s3.Id = 3; this.tradingData.Get <ICollection <Signal> >().Add(s3); Order o1 = new Order(s1); o1.Id = 1; this.tradingData.Get <ICollection <Order> >().Add(o1); Order o2 = new Order(s2); o2.Id = 2; this.tradingData.Get <ICollection <Order> >().Add(o2); Order o3 = new Order(s3); o3.Id = 3; this.tradingData.Get <ICollection <Order> >().Add(o3); ITransaction import = new ImportTradesTransaction((IObservableHashSetFactory)this.tradingData, this.path); Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Trade> >().Count()); import.Execute(); Assert.AreEqual(3, this.tradingData.Get <IEnumerable <Trade> >().Count()); }
public void ignore_signals_when_backup_loaded_at_not_trading_time() { ITransaction importSignals = new ImportSignalsTransaction(this.tradingData, ProjectRootFolderNameFactory.Make() + "\\TestData\\signals-backup.txt"); ITransaction importOrders = new ImportOrdersTransaction((IObservableHashSetFactory)this.tradingData, ProjectRootFolderNameFactory.Make() + "\\TestData\\orders-backup.txt"); ITransaction importTrades = new ImportTradesTransaction((IObservableHashSetFactory)this.tradingData, ProjectRootFolderNameFactory.Make() + "\\TestData\\trades-backup.txt"); importSignals.Execute(); importOrders.Execute(); importTrades.Execute(); Assert.AreEqual(1, this.tradingData.Get <IEnumerable <Signal> >().Count()); Assert.AreEqual(1, this.tradingData.Get <IEnumerable <Order> >().Count()); Assert.AreEqual(1, this.tradingData.Get <IEnumerable <Trade> >().Count()); Assert.AreEqual(1, this.tradingData.Get <IEnumerable <Position> >().Count()); Assert.AreEqual(0, this.signalQueue.Count); Assert.AreEqual(0, this.orderQueue.Count); Assert.AreEqual(0, ((MockOrderManager)this.orderManager).PlaceCounter); }
public void Transaction_import_trades_only_for_existent_orderss() { StrategyHeader strategyHeader = new StrategyHeader(1, "First strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(strategyHeader); Signal signal = new Signal(strategyHeader, BrokerDateTime.Make(DateTime.Now), TradeAction.Buy, OrderType.Market, 150000, 0, 0); signal.Id = 1; this.tradingData.Get <ICollection <Signal> >().Add(signal); Order o1 = new Order(signal); o1.Id = 1; this.tradingData.Get <ICollection <Order> >().Add(o1); Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Trade> >().Count()); ITransaction import = new ImportTradesTransaction((IObservableHashSetFactory)this.tradingData, this.path); import.Execute(); Assert.AreEqual(1, this.tradingData.Get <IEnumerable <Trade> >().Count()); }
public void Transaction_ExportTradesTransaction_test() { StrategyHeader st1 = new StrategyHeader(1, "First strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10); this.tradingData.Get <ICollection <StrategyHeader> >().Add(st1); StrategyHeader st2 = new StrategyHeader(2, "Second strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 8); this.tradingData.Get <ICollection <StrategyHeader> >().Add(st2); StrategyHeader st3 = new StrategyHeader(3, "Third strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 5); this.tradingData.Get <ICollection <StrategyHeader> >().Add(st3); Signal s1 = new Signal(st1, BrokerDateTime.Make(DateTime.Now), TradeAction.Buy, OrderType.Market, 150000, 0, 0); this.tradingData.Get <ICollection <Signal> >().Add(s1); Order o1 = new Order(s1); this.tradingData.Get <ICollection <Order> >().Add(o1); Signal s2 = new Signal(st2, BrokerDateTime.Make(DateTime.Now), TradeAction.Sell, OrderType.Limit, 150000, 0, 150000); this.tradingData.Get <ICollection <Signal> >().Add(s2); Order o2 = new Order(s2); this.tradingData.Get <ICollection <Order> >().Add(o2); Signal s3 = new Signal(st3, BrokerDateTime.Make(DateTime.Now), TradeAction.Buy, OrderType.Stop, 150000, 150000, 0); this.tradingData.Get <ICollection <Signal> >().Add(s3); Order o3 = new Order(s3); this.tradingData.Get <ICollection <Order> >().Add(o3); Trade t1 = new Trade(o1, o1.Portfolio, o1.Symbol, 150000, o1.Amount, BrokerDateTime.Make(DateTime.Now)); this.tradingData.Get <ObservableHashSet <Trade> >().Add(t1); Trade t2 = new Trade(o2, o2.Portfolio, o2.Symbol, 150000, o2.Amount, BrokerDateTime.Make(DateTime.Now)); this.tradingData.Get <ObservableHashSet <Trade> >().Add(t2); Trade t3 = new Trade(o3, o3.Portfolio, o3.Symbol, 150000, o3.Amount, BrokerDateTime.Make(DateTime.Now)); this.tradingData.Get <ObservableHashSet <Trade> >().Add(t3); Assert.AreEqual(3, this.tradingData.Get <IEnumerable <Trade> >().Count()); ITransaction export = new ExportTradesTransaction((IObservableHashSetFactory)this.tradingData, this.path); Assert.IsFalse(File.Exists(this.path)); export.Execute(); Assert.IsTrue(File.Exists(this.path)); this.tradingData.Get <ICollection <Trade> >().Clear(); Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Trade> >().Count()); ITransaction import = new ImportTradesTransaction((IObservableHashSetFactory)this.tradingData, this.path); import.Execute(); Assert.AreEqual(3, this.tradingData.Get <IEnumerable <Trade> >().Count()); }