Пример #1
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 3)
     {
         Console.WriteLine(@"MarketPredict [data dir] [generate/train/prune/evaluate] PathToFile");
         Console.WriteLine(@"e.g csvMarketPredict [data dir] [generate/train/prune/evaluate] c:\\EURUSD.csv");
     }
     else
     {
         var dataDir = new FileInfo(app.Args[0]);
         if (String.Compare(app.Args[1], "generate", true) == 0)
         {
             MarketBuildTraining.Generate(app.Args[2]);
         }
         else if (String.Compare(app.Args[1], "train", true) == 0)
         {
             MarketTrain.Train(dataDir);
         }
         else if (String.Compare(app.Args[1], "evaluate", true) == 0)
         {
             MarketEvaluate.Evaluate(dataDir, app.Args[2]);
         }
         else if (String.Compare(app.Args[1], "prune", true) == 0)
         {
             {
                 MarketPrune.Incremental(dataDir);
             }
         }
     }
 }
Пример #2
0
        public void Execute(IExampleInterface app)
        {
            //placed a try catch in case something bugs.
            try
            {
                //lets check the lenght of the input from the console.
                if (app.Args.Length < 1)
                {
                    Console.WriteLine(@"MarketPredict [generate/train/prune/evaluate] [PathToFile]");
                    Console.WriteLine(@"e.g csvMarketPredict [generate/train/prune/evaluate] c:\\EURUSD.csv");
                }

                //looks like we are fine.
                else
                {
                    //save the files in the directory where the consoleexample.exe is located.
                    FileInfo dataDir = new FileInfo(@"c:\");

                    //we generate the network , by calling the CSVloader.
                    if (String.Compare(app.Args[0], "generate", true) == 0)
                    {
                        Console.WriteLine("Generating your network with file:" + app.Args[1]);
                        MarketBuildTraining.Generate(app.Args[1]);
                    }

                    //train the network here.
                    else if (String.Compare(app.Args[0], "train", true) == 0)
                    {
                        MarketTrain.Train(dataDir);
                    }
                    //Evaluate the network that was built and trained.
                    else if (String.Compare(app.Args[0], "evaluate", true) == 0)
                    {
                        MarketEvaluate.Evaluate(dataDir, app.Args[1]);
                    }
                    //Lets prune the network.
                    else if (String.Compare(app.Args[0], "prune", true) == 0)
                    {
                        MarketPrune.Incremental(dataDir);
                    }
                    else
                    {
                        Console.WriteLine("Didnt understand the command you typed:" + app.Args[0]);
                    }
                }
            }


            catch (Exception ex)
            {
                Console.WriteLine("Error Message:" + ex.Message);
                Console.WriteLine("Error Innerexception:" + ex.InnerException);
                Console.WriteLine("Error stacktrace:" + ex.StackTrace);
                Console.WriteLine("Error source:" + ex.Source);
            }
        }
Пример #3
0
        public void Execute(IExampleInterface app)
        {
            for (int a = 0; a < 10; a++)
            {
                string name = "";
                switch (a)
                {
                case 0:
                    name = "Lukoil1440";
                    break;
                    //case 1: name = "DAI1440"; break;
                    //case 2: name = "EURUSD5"; break;
                    //case 3: name = "Gazprom1440"; break;
                    //case 4: name = "BMW1440"; break;
                    //case 5: name = "Sberbank1440"; break;
                    //case 6: name = "USDCHF5"; break;
                    //case 7: name = "USDJPY5"; break;
                    //case 8: name = "USDJPY5_1"; break;
                    //case 9: name = "XAUUSD5"; break;
                }

                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var forexFile = $"D:\\1\\{name}.csv";


                var dataDir = new FileInfo(AppDomain.CurrentDomain.BaseDirectory);

                //for (Config.DAYS_OFFSET = 0; Config.DAYS_OFFSET <= 300; Config.DAYS_OFFSET += 100)
                Config.TEST_STRATCH = 80;
                for (Config.TEST_OFFSET = 0; Config.TEST_OFFSET <= 200; Config.TEST_OFFSET += 50)
                //for (Config.TEST_STRATCH = 0; Config.TEST_STRATCH <= 160; Config.TEST_STRATCH += 40)
                {
                    var resultFile = $"D:\\1\\_res_{name}_{Config.DAYS_OFFSET}_{Config.TEST_OFFSET}_{Config.TEST_STRATCH}.txt";
                    for (int i = 0; i < 3; i++)
                    {
                        Config.OFFSET = i;

                        for (int j = 0; j < 3; j++)
                        {
                            var timeStart = DateTime.Now;
                            Config.TRAINING_FILE = $"marketData({name}-{i}-{j}){DateTime.Now.Ticks}.egb";
                            Config.NETWORK_FILE  = $"marketNetwork({name}-{i}-{j}){DateTime.Now.Ticks}.eg";

                            //public static readonly String TRAINING_FILE = $"marketData{DateTime.Now.Ticks}.egb";
                            //public static readonly String NETWORK_FILE = $"marketNetwork{DateTime.Now.Ticks}.eg";

                            MarketBuildTraining.Generate(forexFile);
                            var err  = MarketTrain.Train(dataDir);
                            var best = MarketPrune.Incremental(dataDir);
                            var gErr = MarketEvaluate.Evaluate(dataDir, forexFile);

                            var result =
                                $"Offset = {i};\t trainErr = {err};\t best: {NetworkToString(best)};\t result = {gErr:0.00};\t timeTaken: {DateTime.Now - timeStart:g};\t startTime: {timeStart:g}";

                            File.AppendAllLines(resultFile, new[] { result });
                        }
                    }
                }
            }

            //if (app.Args.Length < 3)
            //{
            //    Console.WriteLine(@"MarketPredict [data dir] [generate/train/prune/evaluate] PathToFile");
            //    Console.WriteLine(@"e.g csvMarketPredict [data dir] [generate/train/prune/evaluate] c:\\EURUSD.csv");
            //}
            //else
            //{
            //    var dataDir1 = new FileInfo(app.Args[0]);
            //    if (String.Compare(app.Args[1], "generate", true) == 0)
            //    {
            //    }
            //    else if (String.Compare(app.Args[1], "train", true) == 0)
            //    {
            //    }
            //    else if (String.Compare(app.Args[1], "evaluate", true) == 0)
            //    {
            //    }
            //    else if (String.Compare(app.Args[1], "prune", true) == 0)
            //    {
            //        {
            //        }
            //    }
            //}
        }