public BacktestResult(IDictionary <string, Chart> charts, IDictionary <int, Order> orders, IDictionary <DateTime, decimal> profitLoss, IDictionary <string, string> statistics, Dictionary <string, AlgorithmPerformance> rollingWindow, AlgorithmPerformance totalPerformance = null)
 {
     Charts           = charts;
     Orders           = orders;
     ProfitLoss       = profitLoss;
     Statistics       = statistics;
     RollingWindow    = rollingWindow;
     TotalPerformance = totalPerformance;
 }
        public static Dictionary <string, decimal> Transform(AlgorithmPerformance performance, IDictionary <string, string> summary)
        {
            var list = performance.PortfolioStatistics.GetType().GetProperties().ToDictionary(k => k.Name, v => (decimal)v.GetValue(performance.PortfolioStatistics));

            list.Add("TotalNumberOfTrades", int.Parse(summary["Total Trades"]));
            list.Add("TotalFees", decimal.Parse(summary["Total Fees"].Substring(1)));

            return(list);
        }
Exemple #3
0
        public static Dictionary <string, decimal> Transform(AlgorithmPerformance performance)
        {
            var list = performance.PortfolioStatistics.GetType().GetProperties().ToDictionary(k => k.Name, v => (decimal)v.GetValue(performance.PortfolioStatistics));

            list.Add("TotalNumberOfTrades", performance.TradeStatistics.TotalNumberOfTrades);
            list.Add("TotalFees", performance.TradeStatistics.TotalFees);

            return(list);
        }
Exemple #4
0
 /// <summary>
 /// Constructor for the result class using dictionary objects.
 /// </summary>
 public BacktestResult(BacktestResultParameters parameters)
 {
     Charts                 = parameters.Charts;
     Orders                 = parameters.Orders;
     ProfitLoss             = parameters.ProfitLoss;
     Statistics             = parameters.Statistics;
     RuntimeStatistics      = parameters.RuntimeStatistics;
     RollingWindow          = parameters.RollingWindow;
     TotalPerformance       = parameters.TotalPerformance;
     AlphaRuntimeStatistics = parameters.AlphaRuntimeStatistics;
 }
Exemple #5
0
        public static AlgorithmPerformance RunAlgorithmForAllArrays(int algorithmIndex)
        {
            AlgorithmPerformance currentPerformance = new AlgorithmPerformance(algorithmNames[algorithmIndex]);

            for (int i = 0; i < sortedArrays.Count; i++)
            {
                long elapsedTicks = RunAlgorithmForArray(algorithmIndex, i);
                currentPerformance.AddResult(i, elapsedTicks);
                if (log)
                {
                    Console.WriteLine("Sorting array " + i + " took " + FormatTimeFromTicks(elapsedTicks) + " (" + elapsedTicks + " ticks)");
                }
            }

            return(currentPerformance);
        }
 /// <summary>
 /// Creates a new instance
 /// </summary>
 public BacktestResultParameters(IDictionary <string, Chart> charts,
                                 IDictionary <int, Order> orders,
                                 IDictionary <DateTime, decimal> profitLoss,
                                 IDictionary <string, string> statistics,
                                 IDictionary <string, string> runtimeStatistics,
                                 Dictionary <string, AlgorithmPerformance> rollingWindow,
                                 List <OrderEvent> orderEvents,
                                 AlgorithmPerformance totalPerformance         = null,
                                 AlphaRuntimeStatistics alphaRuntimeStatistics = null)
 {
     Charts                 = charts;
     Orders                 = orders;
     ProfitLoss             = profitLoss;
     Statistics             = statistics;
     RuntimeStatistics      = runtimeStatistics;
     RollingWindow          = rollingWindow;
     OrderEvents            = orderEvents;
     TotalPerformance       = totalPerformance;
     AlphaRuntimeStatistics = alphaRuntimeStatistics;
 }
Exemple #7
0
        public static AlgorithmPerformance RunAlgorithm(int algorithmIndex)
        {
            if (log)
            {
                Console.WriteLine("Calling algorithm \"" + algorithmNames[algorithmIndex] + "\"");
            }

            stopWatch.Reset();
            ResetSortedArrays();

            AlgorithmPerformance currentPerformance = RunAlgorithmForAllArrays(algorithmIndex);

            if (log)
            {
                Console.WriteLine("Before reset");
                PrintArrays(sortedArrays);
                ResetSortedArrays();
                Console.WriteLine("After reset");
                PrintArrays(sortedArrays);
            }

            return(currentPerformance);
        }