/// <summary> /// Creates new financial state of account calculator. /// </summary> /// <param name="trade">valid instance of not started data trade</param> /// <param name="feed">valid instance of not started data feed</param> public StateCalculator(DataTrade trade, DataFeed feed) { if (trade == null) throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null"); if (trade.IsStarted) throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade)); if (feed == null) throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null"); if (feed.IsStarted) throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed)); this.quotes = new Dictionary<string, Quote>(); this.calculatorQuotes = new Dictionary<string, Quote>(); this.calculator = new FinancialCalculator(); this.account = new AccountEntry(calculator); this.calculator.Accounts.Add(this.account); this.trade = trade; this.feed = feed; this.processor = new Processor(this.Calculate); this.processor.Exception += this.OnException; this.processor.Executed += this.OnExecuted; this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor); }
/// <summary> /// Creates new financial state of account calculator. /// </summary> /// <param name="trade">valid instance of not started data trade</param> /// <param name="feed">valid instance of not started data feed</param> public StateCalculator(DataTrade trade, DataFeed feed) { if (trade == null) { throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null"); } if (trade.IsStarted) { throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade)); } if (feed == null) { throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null"); } if (feed.IsStarted) { throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed)); } this.quotes = new Dictionary <string, Quote>(); this.calculatorQuotes = new Dictionary <string, Quote>(); this.calculator = new FinancialCalculator(); this.account = new AccountEntry(calculator); this.calculator.Accounts.Add(this.account); this.trade = trade; this.feed = feed; this.processor = new Processor(this.Calculate); this.processor.Exception += this.OnException; this.processor.Executed += this.OnExecuted; this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor); }