Example #1
0
 public static GPSolutionProxy LoadFromFile(string file)
 {
     try
     {
         var fileStream = File.Open(file, FileMode.Open);
         DataContractJsonSerializer ser    = new DataContractJsonSerializer(typeof(GPSolutionProxy));
         GPSolutionProxy            config = (GPSolutionProxy)ser.ReadObject(fileStream);
         fileStream.Close();
         return(config);
     }
     catch (System.Exception e)
     {
         Utils.Error("Erro ao carregar solution: " + file + ": " + e.Message);
     }
     return(null);
 }
Example #2
0
        public override void EndSolution(GPSolution solution)
        {
            solution.RemovePropriedade(UsoComum.ConstsComuns.OBJ_MONTECARLO);

            if (solution.iterations >= config.saveMinIterations)
            {
                float totalProfit = solution.GetPropriedadeAsFloat(UsoComum.ConstsComuns.OBJ_TOTAL_PROFIT);
                float totalLoss   = Math.Abs(solution.GetPropriedadeAsFloat(UsoComum.ConstsComuns.OBJ_TOTAL_LOSS));
                float profitRatio = totalProfit / (totalProfit + totalLoss + 1);
                if (profitRatio > config.saveMinProfitRatio)
                {
                    GPSolutionProxy proxy = new GPSolutionProxy();
                    proxy.solution    = solution;
                    proxy.tradeSystem = solution.GetPropriedade(UsoComum.ConstsComuns.OBJ_TRADESYSTEM) as TradeSystem;
                    solution.RemovePropriedade(UsoComum.ConstsComuns.OBJ_TRADESYSTEM);
                    SaveSolutionToCheck(proxy);
                }
            }
        }
Example #3
0
 private void SaveSolutionToCheck(GPSolutionProxy proxy)
 {
     Utils.CreateFolder(GPConsts.DIRECTORY_TO_CHECK);
     Utils.CreateFolder(GPConsts.DIRECTORY_TO_CHECK + config.tipoPeriodo.ToString());
     proxy.SaveToFile(GPConsts.DIRECTORY_TO_CHECK + config.tipoPeriodo.ToString() + "/" + proxy.solution.name + ".json");
 }