Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 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);
   }
 }
Esempio n. 4
0
 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);
   }
 }
Esempio n. 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;
 }
Esempio n. 6
0
 @SuppressWarnings("unused")
 public static void setDebugInfoNone() {
   Debug.setDebugInfo(params, DebugInfo.NONE);
 }
Esempio n. 7
0
 public static synchronized void d(Object... output) {
   Debug.log(params, output);
 }
Esempio n. 8
0
 @SuppressWarnings("unused")
 public static void setPrefix(String prefix) {
   Debug.setPrefix(params, prefix);
 }
Esempio n. 9
0
 public static void toFile(String path) {
   Debug.setOutputStream(new ToFile(path));
 }
Esempio n. 10
0
 public static void setShowTime(boolean enabled) {
   Debug.setShowTime(params, enabled);
 }
Esempio n. 11
0
 @SuppressWarnings("unused")
 public static void setAllowedPattern(String regex) {
   Debug.setAllowedPattern(params, regex);
 }
Esempio n. 12
0
 public void setAllowedPattern(String regex) {
   Debug.setAllowedPattern(params, regex);
 }
Esempio n. 13
0
 public void setDebugInfoFullTrace() {
   Debug.setDebugInfo(params, DebugInfo.TRACE);
 }
Esempio n. 14
0
 public void setDebugInfoFileAndLine() {
   Debug.setDebugInfo(params, DebugInfo.LINE);
 }
Esempio n. 15
0
 public void setDebugInfoNone() {
   Debug.setDebugInfo(params, DebugInfo.NONE);
 }
Esempio n. 16
0
 public void d(Object... output) {
   Debug.log(params, output);
 }
Esempio n. 17
0
 public void setPrefix(String prefix) {
   Debug.setPrefix(params, prefix);
 }
Esempio n. 18
0
 public void setOutputStream(OutputStream outputStream) {
   Debug.setOutPutStream(params, outputStream);
 }
Esempio n. 19
0
 @SuppressWarnings("unused")
 public static void setDebugInfoFileAndLine() {
   Debug.setDebugInfo(params, DebugInfo.LINE);
 }
Esempio n. 20
0
 @SuppressWarnings("unused")
 public static void setDebugInfoFullTrace() {
   Debug.setDebugInfo(params, DebugInfo.TRACE);
 }
Esempio n. 21
0
 public void setEnabled(boolean enabled) {
   Debug.setEnabled(params, enabled);
 }
Esempio n. 22
0
 @SuppressWarnings("unused")
 public static void setEnabled(boolean enabled) {
   Debug.setEnabled(params, enabled);
 }
Esempio n. 23
0
 private static void setupDebug() {
   Debug.setShowTime(true);
   String outFileName = "genotick_" + DataUtils.getDateTimeString() + ".txt";
   Debug.toFile(outFileName);
 }
Esempio n. 24
0
 @SuppressWarnings("unused")
 public static void allowedClasses(Class... classes) {
   Debug.allowClasses(params, classes);
 }
Esempio n. 25
0
 @SuppressWarnings("WeakerAccess")
 public static void setOutputStream(OutputStream outputStream) {
   Debug.setOutPutStream(params, outputStream);
 }
Esempio n. 26
0
 public void allowedClasses(Class... classes) {
   Debug.allowClasses(params, classes);
 }
Esempio n. 27
0
 @SuppressWarnings("unused")
 public static void allowAllClasses() {
   Debug.allowAllClasses(params);
 }
Esempio n. 28
0
 public void allowAllClasses() {
   Debug.allowAllClasses(params);
 }
Esempio n. 29
0
 private static void setupExceptionHandler() {
   Thread.setDefaultUncaughtExceptionHandler(Debug.createExceptionHandler());
 }