public UpdateHandler(DataTrade trade, DataFeed feed, Action<SymbolInfo[], AccountInfo, Quote> updateCallback, Processor processor) { if (trade == null) throw new ArgumentNullException(nameof(trade)); if (feed == null) throw new ArgumentNullException(nameof(feed)); if (updateCallback == null) throw new ArgumentNullException(nameof(updateCallback)); if (processor == null) throw new ArgumentNullException(nameof(processor)); this.updateCallback = updateCallback; this.processor = processor; this.SyncRoot = new object(); feed.SymbolInfo += this.OnSymbolInfo; feed.Tick += this.OnTick; trade.AccountInfo += this.OnAccountInfo; trade.BalanceOperation += this.OnBalanceOperation; trade.ExecutionReport += this.OnExecutionReport; trade.PositionReport += this.OnPositionReport; }
/// <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); }