Exemplo n.º 1
0
        private static void BackTest(ITradingStrategy strategy)
        {
            var runner  = new BackTestRunner();
            var results = runner.RunSingleStrategy(strategy, CoinsToBacktest, StakeAmount);

            Console.WriteLine();
            Console.WriteLine($"\t=============== BACKTESTING REPORT {strategy.Name.ToUpper()} ===============");
            Console.WriteLine();
            WriteColoredLine($"\tNote: Profit is based on trading with 0.1 BTC each trade.", ConsoleColor.Cyan);
            Console.WriteLine();
            // Prints the results for each coin for this strategy.
            if (results.Count > 0)
            {
                Console.WriteLine(results
                                  .OrderByDescending(x => x.SuccessRate)
                                  .ToList()
                                  .ToStringTable <BackTestResult>(new string[] { "Market", "# Trades", "# Profitable", "Success Rate", "BTC Profit", "Profit %", "Avg. Duration", "Period" },
                                                                  (x) => x.Market,
                                                                  (x) => x.AmountOfTrades,
                                                                  (x) => x.AmountOfProfitableTrades,
                                                                  (x) => $"{x.SuccessRate:0.00}%",
                                                                  (x) => $"{x.TotalProfit:0.00000000}",
                                                                  (x) => $"{x.TotalProfitPercentage:0.00}%",
                                                                  (x) => $"{(x.AverageDuration):0.00} hours",
                                                                  (x) => $"{x.DataPeriod} days"));
            }
            else
            {
                WriteColoredLine("\tNo backtests results found...", ConsoleColor.Red);
            }

            WriteSeparator();
        }
Exemplo n.º 2
0
        private static void BackTestAll()
        {
            var runner = new BackTestRunner();

            Console.WriteLine();
            Console.WriteLine($"\t=============== BACKTESTING REPORT ===============");
            Console.WriteLine();
            WriteColoredLine($"\tNote: Profit is based on trading with 0.1 BTC each trade.", ConsoleColor.Cyan);
            Console.WriteLine();

            var results = new List <BackTestStrategyResult>();

            foreach (var item in GetTradingStrategies())
            {
                var stratResult = new BackTestStrategyResult()
                {
                    Strategy = item.Name
                };
                stratResult.Results.AddRange(runner.RunSingleStrategy(item, CoinsToBacktest, StakeAmount));
                results.Add(stratResult);
            }

            // Prints the results for each coin for this strategy.
            if (results.Count > 0)
            {
                Console.WriteLine(results
                                  .OrderByDescending(x => x.SuccessRate)
                                  .ToList()
                                  .ToStringTable <BackTestStrategyResult>(new string[] { "Strategy", "# Trades", "# Profitable", "Success Rate", "BTC Profit", "Profit %", "Avg. Duration", "Max. Period" },
                                                                          (x) => x.Strategy,
                                                                          (x) => x.AmountOfTrades,
                                                                          (x) => x.AmountOfProfitableTrades,
                                                                          (x) => $"{x.SuccessRate:0.00}%",
                                                                          (x) => $"{x.TotalProfit:0.00000000}",
                                                                          (x) => $"{x.TotalProfitPercentage:0.00}%",
                                                                          (x) => $"{(x.AverageDuration):0.00} hours",
                                                                          (x) => $"{x.DataPeriod} days"));
            }
            else
            {
                WriteColoredLine("\tNo backtests results found...", ConsoleColor.Red);
            }

            WriteSeparator();
        }