示例#1
0
 @Override
 public List<TimePointStats> start(UserOutput output) {
   Thread.currentThread().setName("Main engine execution thread");
   double result = 1;
   initPopulation();
   TimePoint timePoint = new TimePoint(engineSettings.startTimePoint);
   List<TimePointStats> timePointStats = new ArrayList<>();
   while (engineSettings.endTimePoint.compareTo(timePoint) >= 0) {
     TimePointStats stat = executeTimePoint(timePoint);
     if (stat != null) {
       timePointStats.add(stat);
       result *= (stat.getPercentEarned() / 100 + 1);
       profitRecorder.recordProfit(stat.getPercentEarned());
       output.reportProfitForTimePoint(timePoint, (result - 1) * 100, stat.getPercentEarned());
       Debug.d("Time:", timePoint, "Percent earned so far:", (result - 1) * 100);
     }
     timePoint = timePoint.next();
   }
   if (!engineSettings.executionOnly) {
     savePopulation();
   }
   Debug.d(
       "Profit:",
       profitRecorder.getProfit(),
       "Drawdown:",
       profitRecorder.getMaxDrawdown(),
       "Profit / DD:",
       profitRecorder.getProfit() / profitRecorder.getMaxDrawdown());
   return timePointStats;
 }
示例#2
0
 private void printPercentEarned(DataSetName name, Double actualChange, Prediction prediction) {
   double percent;
   if (prediction == Prediction.OUT) {
     Debug.d("No position");
     return;
   }
   if (prediction.isCorrect(actualChange)) percent = Math.abs(actualChange);
   else percent = -Math.abs(actualChange);
   Debug.d("Profit for", name, percent);
 }
示例#3
0
 private void savePopulation() {
   String dirName = getSavedPopulationDirName();
   File dirFile = new File(dirName);
   if (!dirFile.exists() && !dirFile.mkdirs()) {
     Debug.d("Unable to create directory", dirName);
   } else {
     population.savePopulation(dirName);
   }
 }
示例#4
0
文件: Main.java 项目: neosb/genotick
 private static void checkShowPopulation(Parameters parameters) {
   String value = parameters.getValue("showPopulation");
   if (value != null) {
     try {
       showPopulation(value);
     } catch (IllegalAccessException e) {
       Debug.d(e);
     }
     System.exit(0);
   }
 }
示例#5
0
 private TimePointStats executeTimePoint(TimePoint timePoint) {
   List<ProgramData> programDataList = data.prepareProgramDataList(timePoint);
   if (programDataList.isEmpty()) return null;
   Debug.d("Starting TimePoint:", timePoint);
   TimePointResult timePointResult =
       timePointExecutor.execute(
           timePoint, programDataList, population, !engineSettings.executionOnly);
   TimePointStats timePointStats = TimePointStats.getNewStats(timePoint);
   for (DataSetResult dataSetResult : timePointResult.listDataSetResults()) {
     Prediction prediction = dataSetResult.getCumulativePrediction();
     Debug.d("Prediction for:", dataSetResult.getName(), prediction);
     Double actualChange = data.getActualChange(dataSetResult.getName(), timePoint);
     if (!actualChange.isNaN()) {
       Debug.d("Actual change:", actualChange);
       printPercentEarned(dataSetResult.getName(), actualChange, prediction);
       timePointStats.update(dataSetResult.getName(), actualChange, prediction);
     }
   }
   if (!engineSettings.executionOnly) {
     updatePopulation();
   }
   Debug.d("Finished TimePoint:", timePoint);
   return timePointStats;
 }