private AbstractSection CreateMergedChartsSection(StockHandle stock, IEnumerable <GenericChartSection> sections) { var chart = new StockPriceChart(stock, Prices.ForStock(stock)); AddIndicatorPoints(chart, sections); AddSignals(chart, sections); return(new GenericChartSection(Name, chart)); }
public GenericChartSection(string name, StockPriceChart chart) : base(name) { if (chart == null) { throw new ArgumentNullException("chart"); } Chart = chart; }
public GenericChartSection( string name, StockPriceChart chart ) : base(name) { if ( chart == null ) { throw new ArgumentNullException( "chart" ); } Chart = chart; }
public Report Generate(IAnalysisResult result) { var stock = result.Stock; var report = new Report("ClosedPricesChart", "Closed price chart: " + stock.Name); var chart = new StockPriceChart(stock, Prices.ForStock(stock)); var chartSection = new GenericChartSection("Closed prices", chart); report.Sections.Add(chartSection); return(report); }
public Report Generate( IAnalysisResult result ) { var stock = result.Stock; var report = new Report( "ClosedPricesChart", "Closed price chart: " + stock.Name ); var chart = new StockPriceChart( stock, Prices.ForStock( stock ) ); var chartSection = new GenericChartSection( "Closed prices", chart ); report.Sections.Add( chartSection ); return report; }
private void AddChart( Data data ) { var chart = new StockPriceChart( Name, myStock, data.Prices ); foreach ( var entry in data.Points ) { chart.IndicatorPoints.Add( entry.Key, entry.Value ); } chart.Signals = data.Signals; var section = new GenericChartSection( Name, chart ); Sections.Add( section ); }
private void AddIndicatorPoints(StockPriceChart chart, IEnumerable <GenericChartSection> sections) { foreach (var section in sections) { foreach (var entry in section.Chart.IndicatorPoints) { // could be that the chart is already added // sample: indicator 1 = SMA.200, indicator 2 = SMA.10xSMA.200 (double cross over). then SMA.200 would be added two times if (!chart.IndicatorPoints.ContainsKey(entry.Key)) { chart.IndicatorPoints.Add(entry.Key, entry.Value); } } } }
private GenericChartSection CreateChartSection( TradingResult tradingResult ) { var chart = new StockPriceChart( "TradingProtocol", tradingResult.Stock, tradingResult.Prices ); var trades = tradingResult.TradingLog.Orders .Select( o => o.Timestamp ) .ToList(); var signals = tradingResult.SystemSignals .Where( s => trades.Contains( s.Time ) ); chart.Signals = new SignalSeries( tradingResult.Prices, new SeriesIdentifier( new StockObjectIdentifier( tradingResult.Stock ), new ObjectDescriptor( "Trading" ) ), signals ); AddIndicators( chart, tradingResult.SystemReport ); var section = new GenericChartSection( "Chart", chart ); return section; }
private void AddIndicators( StockPriceChart chart, Report report ) { var visitor = new ChartSectionVisitor(); var walker = new ReportWalker( visitor ); walker.Visit( report ); foreach ( var section in visitor.Sections.OfType<GenericChartSection>() ) { foreach ( var entry in section.Chart.IndicatorPoints ) { // could be that the chart is already added // sample: indicator 1 = SMA.200, indicator 2 = SMA.10xSMA.200 (double cross over). then SMA.200 would be added two times if ( !chart.IndicatorPoints.ContainsKey( entry.Key ) ) { chart.IndicatorPoints.Add( entry.Key, entry.Value ); } } } }
private void AddSignals(StockPriceChart chart, IEnumerable <GenericChartSection> sections) { if (!MergeSignals) { return; } var signals = sections .Select(section => section.Chart.Signals) .Where(s => s != null) .ToList(); if (!signals.Any()) { return; } if (CombinedSignalCreator == null) { throw new ArgumentNullException("CombinedSignalCreator not set"); } chart.Signals = CombinedSignalCreator.Create(signals); }
public GenericChartSection Generate( SystemResult result ) { var chart = new StockPriceChart( result.System, result.Stock, result.Prices ); chart.Signals = result.Signals; var section = new GenericChartSection( "Chart", chart ); return section; }
private void AddIndicatorPoints( StockPriceChart chart, IEnumerable<GenericChartSection> sections ) { foreach ( var section in sections ) { foreach ( var entry in section.Chart.IndicatorPoints ) { // could be that the chart is already added // sample: indicator 1 = SMA.200, indicator 2 = SMA.10xSMA.200 (double cross over). then SMA.200 would be added two times if ( !chart.IndicatorPoints.ContainsKey( entry.Key ) ) { chart.IndicatorPoints.Add( entry.Key, entry.Value ); } } } }
private AbstractSection CreateMergedChartsSection( StockHandle stock, IEnumerable<GenericChartSection> sections ) { var chart = new StockPriceChart( stock, Prices.ForStock( stock ) ); AddIndicatorPoints( chart, sections ); AddSignals( chart, sections ); return new GenericChartSection( Name, chart ); }
private void AddSignals( StockPriceChart chart, IEnumerable<GenericChartSection> sections ) { if ( !MergeSignals ) { return; } var signals = sections .Select( section => section.Chart.Signals ) .Where( s => s != null ) .ToList(); if ( !signals.Any() ) { return; } if ( CombinedSignalCreator == null ) { throw new ArgumentNullException( "CombinedSignalCreator not set" ); } chart.Signals = CombinedSignalCreator.Create( signals ); }