internal Snapshot(DataTrade trade, DataFeed feed, StateCalculator calculator, object synchronizer, AutoResetEvent syncEvent) { this.synchronizer = synchronizer; this.syncEvent = syncEvent; this.calculator = calculator; this.Quotes = new Dictionary<string, Quote>(); trade.Logon += this.OnTradeLogon; trade.SessionInfo += this.OnTradeSession; trade.AccountInfo += this.OnAccountInfo; trade.Logout += this.OnTradeLogout; feed.Logon += this.OnFeedLogon; feed.Logout += this.OnFeedLogout; feed.SymbolInfo += this.OnFeedSymbolInfo; feed.SessionInfo += this.OnFeedSessionInfo; calculator.StateInfoChanged += this.OnFinancialInfoChanged; }
void DoRun() { this.Trade.Initialize(this.dataTradeBuilder.ToString()); this.Feed.Initialize(this.dataFeedBuilder.ToString()); this.Calculator = new StateCalculator(this.Trade, this.Feed); this.Trade.Start(); this.Feed.Start(); if (!dataTradeEvent.WaitOne(this.Trade.SynchOperationTimeout)) throw new TimeoutException("Timeout of data trade logon waiting has been reached"); if (!dataFeedEvent.WaitOne(this.Trade.SynchOperationTimeout)) throw new TimeoutException("Timeout of data feed logon waiting has been reached"); this.RunExample(); }
public void StateInfoChanged() { string connectionString = Configuration.ConnectionBuilders(AccountType.Gross, Configuration.ConnectionType.Feed).First().ToString(); this.dataFeed = new DataFeed(connectionString); this.dataFeed.Logon += this.OnFeedLogon; connectionString = Configuration.ConnectionBuilders(AccountType.Gross, Configuration.ConnectionType.Trade).First().ToString(); this.dataTrade = new DataTrade(connectionString); this.dataTrade.Logon += this.OnTradeLogon; StateCalculator stateCalculator = new StateCalculator(dataTrade, dataFeed); stateCalculator.StateInfoChanged += StateCalculator_StateInfoChanged; this.dataFeed.Start(); this.dataTrade.Start(); var status = this.feedLogonEvent.WaitOne(LogonWaitingTimeout); Assert.IsTrue(status, "Timeout of feed logon event"); status = this.tradeLogonEvent.WaitOne(LogonWaitingTimeout); Assert.IsTrue(status, "Timeout of trade logon event"); status = this.stateInfoEvent.WaitOne(LogonWaitingTimeout*10000); this.dataFeed.Stop(); this.dataTrade.Stop(); this.dataFeed.Logon -= this.OnFeedLogon; this.dataTrade.Logon -= this.OnTradeLogon; }