Beispiel #1
0
        public static void TestSecondExtremumsAlternation(string toolName, int pegTopSize)
        {
            //TODO ошибка в том, что реализм требует сортировки firstExtremums по checkerIndex, а текущий метод поиска secondExtremums - сортировки по Date. В общем случае, обоюдная сортировка невозможна
            var repository     = new HistoryRepository(toolName, false);
            var extremumFinder = new ExtremumsFinder(pegTopSize);

            bool bad = false;

            foreach (var day in repository.Days)
            {
                var firstMaximums = extremumFinder.FindFirstExtremums(day.FiveMins, false);
                var maximums      = extremumFinder.FindSecondExtremums(firstMaximums, false);

                var firstMinimums = extremumFinder.FindFirstExtremums(day.FiveMins, true);
                var minimums      = extremumFinder.FindSecondExtremums(firstMinimums, true);

                var allExtremums = maximums
                                   .Concat(minimums)
                                   .OrderBy(ex => ex.CheckerIndex)
                                   .ToList();

                for (int i = 0; i < allExtremums.Count - 1; ++i)
                {
                    if (allExtremums[i].Date >= allExtremums[i + 1].Date && allExtremums[i].IsMinimum == allExtremums[i + 1].IsMinimum)
                    {
                        bad = true;
                        Console.Out.WriteLine(allExtremums[i] + "\t" + allExtremums[i + 1]);
                    }
                }
            }
            Assert.That(!bad);
        }
Beispiel #2
0
        public static void Run(string toolName, List <Day> days)
        {
            var outPath = toolName + @"\";

            Directory.CreateDirectory(outPath + candlesPath);
            Directory.CreateDirectory(outPath + firstMaxPath);
            Directory.CreateDirectory(outPath + firstMinPath);
            Directory.CreateDirectory(outPath + secondMaxPath);
            Directory.CreateDirectory(outPath + secondMinPath);

            var extremumsFindex = new ExtremumsFinder(pegTopSize);

            for (int i = 0; i < days.Count; ++i)
            {
                var day           = days[i];
                var candles       = day.FiveMins;
                var firstMaximums = extremumsFindex.FindFirstExtremums(candles, false);
                var firstMinimums = extremumsFindex.FindFirstExtremums(candles, true);

                var secondMaximums = extremumsFindex.FindSecondExtremums(firstMaximums, false);
                var secondMinimums = extremumsFindex.FindSecondExtremums(firstMinimums, true);

                File.WriteAllLines(outPath + candlesPath + i + ".txt", candles.ConvertAll(c => c.High + "\t" + c.Low + "\t" + c.Close + "\t" + c.Open));

                File.WriteAllLines(outPath + firstMaxPath + i + ".txt", firstMaximums.Select(ex => (candles.FindIndex(c => c.Time == ex.Date.TimeOfDay) + 1).ToString()));
                File.WriteAllLines(outPath + firstMinPath + i + ".txt", firstMinimums.Select(ex => (candles.FindIndex(c => c.Time == ex.Date.TimeOfDay) + 1).ToString()));

                File.WriteAllLines(outPath + secondMaxPath + i + ".txt", secondMaximums.Select(ex => (candles.FindIndex(c => c.Time == ex.Date.TimeOfDay) + 1).ToString()));
                File.WriteAllLines(outPath + secondMinPath + i + ".txt", secondMinimums.Select(ex => (candles.FindIndex(c => c.Time == ex.Date.TimeOfDay) + 1).ToString()));
            }
        }