public void Dump(ITradingObject tradingObject) { if (tradingObject == null) { throw new ArgumentNullException(); } var bars = _provider.GetAllBarsForTradingObject(tradingObject.Index); var currentBar = _context.GetBarOfTradingObjectForCurrentPeriod(tradingObject); int index = FindIndexOfBar(bars, currentBar); if (index < 0) { throw new InvalidOperationException("Logic error"); } var sequence = new List <Bar>(_numberOfBarsToDump); int actualIndexToStartWith; if (index < _numberOfBarsBacktrace) { for (int i = 0; i < _numberOfBarsBacktrace - index; ++i) { sequence.Add(Bar.DefaultValue); } actualIndexToStartWith = 0; } else { actualIndexToStartWith = index - _numberOfBarsBacktrace; } index = actualIndexToStartWith; while (index < bars.Length && sequence.Count < _numberOfBarsToDump) { var bar = bars[index]; if (bar.Time != Bar.InvalidTime) { sequence.Add(bar); } ++index; } while (sequence.Count < _numberOfBarsToDump) { sequence.Add(Bar.DefaultValue); } foreach (var bar in sequence) { // Time, O, H, L, C _writer.Write( "{4:yyyy-MM-dd},{0:0.000},{1:0.000},{2:0.000},{3:0.000},", bar.OpenPrice, bar.HighestPrice, bar.LowestPrice, bar.ClosePrice, bar.Time); } // dump metrics if (_metricProxies != null) { for (int j = 0; j < _metricProxies.Length; ++j) { ITradingObject trueObject = _forBoardIndex[j] ? _context.GetBoardIndexTradingObject(tradingObject) : tradingObject; double value = 0.0; var values = _metricProxies[j].GetMetricValues(trueObject); if (values == null) { if (!object.ReferenceEquals(trueObject, tradingObject)) { trueObject = _context.GetBoardIndexTradingObject(StockBoard.MainBoard); values = _metricProxies[j].GetMetricValues(trueObject); } } if (values == null) { value = 0.0; } else { value = values[0]; } _writer.Write("{0:0.0000},", value); } } _writer.WriteLine(); }