Ejemplo n.º 1
0
        public static void TestExtremums(string toolName, int startStop, int endStop, int stopStep,
                                         int startPegTopSize, int endPegTopSize, int pegTopSizeStep)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            //var good = new List<int>();
            //var bad = new List<int>();

            for (int stop = startStop; stop <= endStop; stop += stopStep)
            {
                for (int pegTopSize = startPegTopSize; pegTopSize <= endPegTopSize; pegTopSize += pegTopSizeStep)
                {
                    for (double breakevenSize = 0.8; breakevenSize <= 2.0; breakevenSize += 0.1)
                    {
                        var strat = new ExtremumStrategy(stop, pegTopSize, breakevenSize);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop.ToString("D4") + "_" + pegTopSize + "_" + ((int)(100 * breakevenSize)).ToString("D2") + ".txt");

                        resultText.Add("stop: " + stop + " pegTopSize: " + pegTopSize + " breakevenSize: " + breakevenSize.ToString(new CultureInfo("en-us")));
                        resultText.Add(result.ToString());
                        resultText.Add("");
                        //good.Add(strat.Good);
                        //bad.Add(strat.Bad);
                    }
                }
            }

            //var a = good.Average();
            //var b = bad.Average();

            File.WriteAllLines("out.txt", resultText);
        }
Ejemplo n.º 2
0
        public static void TestExtremumsSimple(string toolName)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            for (int stop = 200; stop <= 1000; stop += 100)
            {
                var strat = new ExtremumStrategy(stop, 0, 50);

                var result = strat.Run(repository.Days);
                result.PrintDepo(@"depo\" + stop + ".txt");

                resultText.Add("stop: " + stop);
                resultText.Add(result.ToString());
                resultText.Add("");
            }

            File.WriteAllLines("out.txt", resultText);
        }
Ejemplo n.º 3
0
        public static void RunExtremums(string toolName, int stopLoss, int pegTopSize, double breakevenSize)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            /*var date = new DateTime(2014, 06, 01);
             * var avgCandles = repository.Days.SelectMany(day => day.FiveMins).ToList();
             * var avg = avgCandles.Average(c => Math.Abs(c.Close - c.Open));*/

            var strat = new ExtremumStrategy(stopLoss, pegTopSize, breakevenSize);

            var result = strat.Run(repository.Days);

            result.PrintDepo(@"depo\run.txt");

            resultText.Add(result.ToString());
            resultText.Add("");

            File.WriteAllLines("out.txt", resultText);
        }
Ejemplo n.º 4
0
        public static void TestEndTimeExtremums(string toolName, int stopLoss, int pegTopSize, double breakevenSize)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            for (int hours = 15; hours <= 23; ++hours)
            {
                for (int minutes = 0; minutes < 60; minutes += 15)
                {
                    var time  = new TimeSpan(hours, minutes, 0);
                    var strat = new ExtremumStrategy(stopLoss, pegTopSize, breakevenSize, time);

                    var result = strat.Run(repository.Days);
                    result.PrintDepo(@"depo\" + hours + "_" + minutes + ".txt");

                    resultText.Add(hours + "_" + minutes);
                    resultText.Add(result.ToString());
                    resultText.Add("");
                }
            }

            File.WriteAllLines("out.txt", resultText);
        }