Beispiel #1
0
        private TradingResult PerformBackTesting( SystemResult systemResult )
        {
            if ( systemResult.Prices.Empty() || systemResult.Signals.Empty() )
            {
                return null;
            }

            const int InitialCash = 10000;
            var tradingLog = new TradingLog();
            var portfolio = new Portfolio( InitialCash, Broker, tradingLog );

            foreach ( var signal in systemResult.Signals )
            {
                if ( signal.Value.Type == SignalType.Buy )
                {
                    var price = systemResult.Prices[ signal.Time ];
                    portfolio.Buy( signal.Time, price.Value );
                }
                else if ( signal.Value.Type == SignalType.Sell )
                {
                    var price = systemResult.Prices[ signal.Time ];
                    portfolio.Sell( signal.Time, price.Value );
                }
            }

            return new TradingResult( systemResult )
            {
                TradingTimeSpan = systemResult.Prices.Last().Time - systemResult.Prices.First().Time,
                TradingLog = tradingLog,
                InitialCash = InitialCash,
                PortfolioValue = portfolio.GetValue( systemResult.Prices.Last().Value )
            };
        }
Beispiel #2
0
        public BasicSystemReport( string systemName, DateTime dateUnderUnderAnalysis, SystemResult result )
            : base(systemName, "Analyis of system: " + result.Stock.Name)
        {
            SystemResult = result;

            AddSections( dateUnderUnderAnalysis );
        }
Beispiel #3
0
        public BasicSystemReport(string systemName, DateTime dateUnderUnderAnalysis, SystemResult result)
            : base(systemName, "Analyis of system: " + result.Stock.Name)
        {
            SystemResult = result;

            AddSections(dateUnderUnderAnalysis);
        }
Beispiel #4
0
            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);
            }
Beispiel #5
0
        public SystemResult Evaluate( StockHandle stock, DateTime dateUnderAnalysis )
        {
            var indicatorResult = EvaluateIndicator( stock, dateUnderAnalysis );

            var systemResult = new SystemResult( Name, stock, Prices.ForStock( stock ), indicatorResult );

            var report = CreateReport( dateUnderAnalysis, systemResult );
            report.SystemDetails.Indicator = indicatorResult;

            systemResult.Report = report;

            AddReports( report );

            report.Sections.Add( myChartGenerator.Generate( systemResult ) );

            return systemResult;
        }
Beispiel #6
0
        public SystemResult Evaluate(StockHandle stock, DateTime dateUnderAnalysis)
        {
            var indicatorResult = EvaluateIndicator(stock, dateUnderAnalysis);

            var systemResult = new SystemResult(Name, stock, Prices.ForStock(stock), indicatorResult);

            var report = CreateReport(dateUnderAnalysis, systemResult);

            report.SystemDetails.Indicator = indicatorResult;

            systemResult.Report = report;

            AddReports(report);

            report.Sections.Add(myChartGenerator.Generate(systemResult));

            return(systemResult);
        }
Beispiel #7
0
 protected virtual BasicSystemReport CreateReport(DateTime dateUnderAnalysis, SystemResult systemResult)
 {
     return(new BasicSystemReport(Name, dateUnderAnalysis, systemResult));
 }
Beispiel #8
0
            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;
            }
Beispiel #9
0
 protected virtual BasicSystemReport CreateReport( DateTime dateUnderAnalysis, SystemResult systemResult )
 {
     return new BasicSystemReport( Name, dateUnderAnalysis, systemResult );
 }
Beispiel #10
0
 public TradingResult( SystemResult systemResult )
 {
     mySystemResult = systemResult;
 }