示例#1
0
文件: Program.cs 项目: zokocx/Mynt
        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();
        }
示例#2
0
文件: Program.cs 项目: zokocx/Mynt
        private static void Init()
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true);

            Configuration = builder.Build();

            var exchangeOptions = Configuration.Get <ExchangeOptions>();
            var backtestOptions = Configuration.Get <BacktestOptions>();

            StakeAmount     = backtestOptions.StakeAmount;
            CoinsToBacktest = backtestOptions.Coins;

            _backTester    = new BackTestRunner();
            _dataRefresher = new DataRefresher(exchangeOptions);
        }
示例#3
0
文件: Program.cs 项目: zokocx/Mynt
        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();
        }