Changeset 9386 for branches/sluengo
- Timestamp:
- 04/20/13 14:08:49 (12 years ago)
- Location:
- branches/sluengo/HeuristicLab.Problems.TradeRules
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/EvaluatorTradeRules.cs
r9325 r9386 44 44 double quality = Calculate((ITradeRulesExpresionTree) SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 45 45 QualityParameter.ActualValue = new DoubleValue(quality); 46 ITradeRulesExpresionTree interpreter = (ITradeRulesExpresionTree)SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;47 interpreter.clearVariables();48 46 return base.Apply(); 49 47 } … … 52 50 { 53 51 interpreter.setInitialTraining(initialTraining); 54 interpreter.setInitialTest( initialTest);52 interpreter.setInitialTest(rows.ToArray()[0]); 55 53 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 54 interpreter.clearVariables(); 55 double tradingCash = OnlineTradeRulesCalculator.Calculate(estimatedValues, problemData, rows); 56 56 57 double tradingCash = OnlineTradeRulesCalculator.Calculate(estimatedValues, problemData, problemData.TrainingIndices);58 59 57 return tradingCash; 60 58 } … … 69 67 EstimationLimitsParameter.ExecutionContext = null; 70 68 71 72 69 return r2; 73 70 } -
branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/OnlineTradeRulesCalculator.cs
r9262 r9386 4 4 using System.Text; 5 5 using HeuristicLab.Problems.DataAnalysis; 6 using HeuristicLab.Core; 7 using HeuristicLab.Data; 8 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 6 9 7 10 namespace HeuristicLab.Problems.TradeRules … … 9 12 class OnlineTradeRulesCalculator 10 13 { 14 private static int numberTrades; 15 private static int tradeDays; 16 private static int totalTradeDays; 17 11 18 public static double Calculate(IEnumerable<double> estimatedValues, IRegressionProblemData problemData, IEnumerable<int> rows) 12 {/* 13 const double commission = 0.25; 14 const double EAR = 4.00; //Effective Anual Rate 19 { 20 double[] arrayOpen = problemData.Dataset.GetDoubleValues("\"Open\"").ToArray(); //Array with all Open prices 21 int[] tick = rows.ToArray(); 22 double[] arrayIO = estimatedValues.ToArray(); 23 double[] arrayDate = problemData.Dataset.GetDoubleValues("\"Date\"").ToArray(); //Array with all dates 24 25 const double COMISSION = 0.25; 26 const double EAR = 5.00; //Effective Anual Rate 27 const double CASHINI = 10000.00; 28 int tickIni = tick[0]; 29 int tickEnd = tick[tick.Length-1]; 30 const double DAYSYEAR = 365.00; 15 31 16 double DayRat = 0 ; //One day interest32 double DayRat = 0.0; //One day interest 17 33 double interest = 0.0; // Interest for one day 18 double[] arrayDate = problemData.Dataset.GetDoubleValues("\"Date\"").ToArray(); //Array with all dates in UNIX format 34 int nDias1 = 0; 35 int nDias2 = 0; 36 int dayBefore=0; 37 int yesterday=0; 19 38 20 //int count = rows.ToList()[0]; 21 39 int actualRow = 0; 40 int nData = tick.Length; 41 22 42 bool intoMarket = false;//Equivalent to be into the market 23 int totalTradeDays = 0; 24 int numberTrades = 0; 25 int tradeDays = 0; 26 double dayBefore = 0.0; 27 double yesterday = 0.0; 43 numberTrades = 0; 44 tradeDays = 0; 45 totalTradeDays = 0; 28 46 double buyPrice = 0.0; 29 47 double sellPrice = 0.0; 30 string stringPrice = "";31 48 int nShares = 0; 32 double cash = 10000.00; 49 50 double cash = CASHINI; 33 51 double expend = 0.0; 34 double equity = 0.0; 35 double profit1 = 0.0; 52 double profitTrade = 0.0; 36 53 double charged = 0.0; 37 54 38 IEnumerator<int> initialRow = rows.GetEnumerator(); 39 initialRow.MoveNext(); 40 int numDays1 = (int)arrayDate[initialRow.Current-1]; 41 int numDays2 = (int) arrayDate[(initialRow.Current)]; 42 int count = initialRow.Current + 1; 43 44 IEnumerator<double> enumerator = estimatedValues.GetEnumerator(); 45 enumerator.MoveNext(); 46 dayBefore = enumerator.Current; 47 enumerator.MoveNext(); 48 yesterday = enumerator.Current; 55 double [] equity = new double [nData]; 56 DayRat = DAYSYEAR * (Math.Pow((1.0 + (EAR/100)), (1.0/ DAYSYEAR)) - 1.0); 49 57 50 DayRat = 360 * (Math.Pow((1 + (EAR / 100)), (1 / 360)) - 1); 58 //First Day 59 equity[0] = CASHINI; 60 actualRow++; 61 nDias2 = Convert.ToInt32(arrayDate[tick[1]] - arrayDate[tick[0]]); 62 //Second day in the marquet. ----------------------------------------- 63 cash = CASHINI * Math.Pow((1.0 + DayRat / DAYSYEAR), nDias2); 64 equity[1] = cash; 65 nDias2 = Convert.ToInt32(arrayDate[tick[2]] - arrayDate[tick[1]]); 66 interest = cash * Math.Pow((1.0 + DayRat / DAYSYEAR), nDias2) - cash; 67 dayBefore = Convert.ToInt32(arrayIO[0]); 68 yesterday = Convert.ToInt32(arrayIO[1]); 69 //Earnings computation ----------------------------------------------- 70 actualRow = 2; 51 71 52 while ( enumerator.MoveNext())72 while (actualRow<(nData-1)) 53 73 { 54 74 if (!intoMarket) … … 57 77 { 58 78 intoMarket = true; 59 stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values 60 buyPrice = Convert.ToDouble(stringPrice); 61 totalTradeDays++; numberTrades++; tradeDays++; //Increasing trading variables 62 nShares = (int)Math.Floor(cash / (buyPrice * (1.0 + commission / 100))); 63 expend = buyPrice * nShares * (1 + commission / 100); 64 cash = cash - expend + interest; 65 equity = cash + nShares * buyPrice * (1 - commission / 100); 66 interest = cash * Math.Pow((1 + DayRat / 360), numDays2) - cash; 79 buyPrice = arrayOpen[tick[actualRow]]; 80 totalTradeDays++; numberTrades++; tradeDays=1; //Increasing trading variables 81 nShares = Convert.ToInt32(Math.Floor(cash / (buyPrice * (1.0 + COMISSION / 100)))); 82 expend = buyPrice * nShares * (1.0 + COMISSION / 100); 83 cash = cash + interest - expend; 84 equity[actualRow] = cash + nShares * (buyPrice * (1.0 - COMISSION / 100)); 67 85 } 68 86 else //Dia normal fuera del mercado 69 87 { 70 88 cash = cash + interest; 71 equity = equity + cash; 72 interest = cash * Math.Pow((1 + DayRat / 360), numDays2) - cash; 73 } 74 75 } 76 else if (dayBefore == 1 && yesterday == -1) 77 { 78 intoMarket = false; 79 stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values 80 sellPrice = Convert.ToDouble(stringPrice); 81 profit1 += sellPrice - buyPrice; 82 charged = sellPrice * nShares * (1 - commission / 100); 83 cash = cash + charged + interest; 84 equity = cash; 85 interest = cash * Math.Pow((1 + DayRat / 360), numDays2) - cash; 86 nShares = 0; 87 } 88 else 89 { 90 cash = cash + interest; 91 tradeDays += numDays1; 92 totalTradeDays += numDays1; 93 equity = cash + nShares * Convert.ToDouble(problemData.Dataset.GetValue(count, 0)) * (1 - commission / 100); 94 interest = cash * Math.Pow((1 + DayRat / 360), numDays2) - cash; 95 } 96 97 dayBefore = yesterday; 98 yesterday = enumerator.Current; 99 numDays1 = numDays2; 100 numDays2 = (int) arrayDate[count]; 101 count++; 102 } 103 if (intoMarket) 104 { 105 intoMarket = false; 106 stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values 107 sellPrice = Convert.ToDouble(stringPrice); 108 profit1 += sellPrice - buyPrice; 109 charged = sellPrice * nShares * (1 - commission / 100); 110 cash = cash + charged + interest; 111 equity = cash; 112 nShares = 0; 113 } 114 return numDays1;*/ 115 116 const double commission = 0.25; 117 const double EAR = 4.00; //Effective Anual Rate 118 119 double DayRat = 0; //One day interest 120 double interest = 0.0; // Interest for one day 121 double[] arrayDate = problemData.Dataset.GetDoubleValues("\"Date\"").ToArray(); //Array with all dates in UNIX format 122 int nDias1 = 0; 123 int nDias2 = 0; 124 125 126 bool intoMarket = false;//Equivalent to be into the market 127 int totalTradeDays = 0; 128 int numberTrades = 0; 129 int tradeDays = 0; 130 double buyPrice = 0.0; 131 double sellPrice = 0.0; 132 string stringPrice = ""; 133 int nShares = 0; 134 double cash = 10000.00; 135 double expend = 0.0; 136 double equity = 0.0; 137 double profit1 = 0.0; 138 double charged = 0.0; 139 140 //SECOND EVALUATOR 141 var enumerator = estimatedValues.GetEnumerator(); 142 int count = rows.ToList()[2]; 143 int count2 = 2; 144 int date1 = (int)arrayDate[rows.ToList()[0]]; 145 int date2 = (int)arrayDate[rows.ToList()[1]]; 146 147 enumerator.MoveNext(); 148 double dayBefore = enumerator.Current; 149 enumerator.MoveNext(); 150 double yesterday = enumerator.Current; 151 152 DayRat = 268 * (Math.Pow((1 + (EAR / 100)),(1 / 268)) - 1); 153 nDias2 = date2 - date1; 154 155 while (enumerator.MoveNext()) 156 { 157 if (!intoMarket) 158 { 159 if (dayBefore == -1 && yesterday == 1) 160 { 161 intoMarket = true; 162 stringPrice = problemData.Dataset.GetValue(count, 1); //Extracting Open values 163 buyPrice = Convert.ToDouble(stringPrice); 164 totalTradeDays++; numberTrades++; tradeDays++; //Increasing trading variables 165 nShares = (int)Math.Floor(cash / (buyPrice * (1.0 + commission / 100))); 166 expend = buyPrice * nShares * (1 + commission / 100); 167 cash = cash - expend + interest; 168 equity = cash + nShares * buyPrice * (1 - commission / 100); 169 interest = cash * Math.Pow((1 + DayRat / 268), nDias2) - cash; 170 } 171 else //Dia normal fuera del mercado 172 { 173 tradeDays++; 174 totalTradeDays++; 175 cash = cash + interest; 176 equity = equity+cash; 177 interest = cash * Math.Pow((1 + DayRat / 268), nDias2) - cash; 89 equity[actualRow] = cash; 178 90 } 179 91 } … … 181 93 { 182 94 intoMarket = false; 183 stringPrice = problemData.Dataset.GetValue(count, 1); //Extracting Open values 184 sellPrice = Convert.ToDouble(stringPrice); 185 profit1 += sellPrice - buyPrice; 186 charged = sellPrice * nShares * (1 - commission / 100); 187 cash = cash + charged+interest; 188 equity = cash; 189 interest = cash + Math.Pow((1 + DayRat / 268), nDias2) - cash; 95 sellPrice = Convert.ToDouble(arrayOpen[tick[actualRow]]); 96 profitTrade = profitTrade + sellPrice - buyPrice; 97 charged = nShares * sellPrice * (1.0 - COMISSION / 100); 98 cash = cash + interest + charged; 99 equity[actualRow] = cash; 190 100 nShares = 0; 101 totalTradeDays = totalTradeDays + nDias1 - 1; 102 tradeDays = tradeDays + nDias1 - 1; 103 tradeDays = 0; 191 104 } 192 105 else 193 106 { 107 totalTradeDays = totalTradeDays + nDias1; 108 tradeDays = tradeDays + nDias1; 194 109 cash = cash + interest; 195 tradeDays++; 196 totalTradeDays++; 197 equity = cash + nShares * Convert.ToDouble(problemData.Dataset.GetValue(count,1)) * (1 - commission / 100); 198 interest = cash * Math.Pow((1 + DayRat / 268), nDias2) - cash; 110 equity[actualRow] = cash + nShares * arrayOpen[tick[actualRow]] * (1.0 - COMISSION / 100); 111 199 112 } 200 113 201 dayBefore = yesterday; 202 yesterday = enumerator.Current; 203 date1 = date2; 204 date2 = (int)arrayDate[rows.ToList()[count2]]; 205 206 int nDiasAux = nDias1; 114 nDias2 = Convert.ToInt32(arrayDate[tick[(actualRow + 1)]] - arrayDate[tick[actualRow]]); 115 interest = cash * Math.Pow((1.0 + DayRat / DAYSYEAR), nDias2) - cash; 116 actualRow++; 207 117 nDias1 = nDias2; 208 nDias2 = date2-date1; 209 210 count++; 211 count2++; 118 dayBefore = Convert.ToInt32(arrayIO[(actualRow - 2)]); 119 yesterday = Convert.ToInt32(arrayIO[(actualRow - 1)]); 120 212 121 } 213 214 122 if (intoMarket) 215 123 { 216 124 intoMarket = false; 217 stringPrice = problemData.Dataset.GetValue((count-1), 1); //Extracting Open values 218 sellPrice = Convert.ToDouble(stringPrice); 219 profit1 += sellPrice - buyPrice; 220 charged = sellPrice * nShares * (1 - commission / 100); 221 cash = cash + charged + interest; 222 equity = cash; 125 sellPrice = Convert.ToDouble(arrayOpen[tick[actualRow]]); 126 profitTrade = profitTrade + sellPrice - buyPrice; 127 charged = nShares * sellPrice * (1.0 - COMISSION / 100); 128 cash = cash + interest + charged; 129 equity[actualRow] = cash; 223 130 nShares = 0; 131 totalTradeDays = totalTradeDays + nDias1 - 1; 132 tradeDays = tradeDays + nDias1 - 1; 224 133 } 134 else 135 { 136 cash = cash + interest; 137 equity[actualRow] = cash; 138 } 139 225 140 return cash; 141 } 142 143 public static int getNumberTrades() 144 { 145 return numberTrades; 146 } 147 public static int getTradeDays() 148 { 149 return tradeDays; 150 } 151 public static int getTotalTradesDays() 152 { 153 return totalTradeDays; 226 154 } 227 155 } -
branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj
r9325 r9386 56 56 <Compile Include="Symbols\Lag.cs" /> 57 57 <Compile Include="Symbols\MACD.cs" /> 58 <Compile Include="Symbols\MACDTreeNode.cs" />59 58 <Compile Include="Symbols\Max.cs" /> 60 59 <Compile Include="Symbols\Min.cs" /> … … 62 61 <Compile Include="Plugin.cs" /> 63 62 <Compile Include="Properties\HeuristicLab.Problems.TradeRules-1.0.cs" /> 64 <Compile Include="Symbols\RSI.cs" />65 63 <Compile Include="Evaluator\TradeRulesAnalysisEvaluator.cs" /> 66 64 <Compile Include="Evaluator\TradeRulesAnalysisSingleObjectiveEvaluator.cs" /> … … 69 67 <Compile Include="Problem\TradeRulesAbstractProblem.cs" /> 70 68 <Compile Include="Problem\TradeRulesProblem.cs" /> 69 <Compile Include="Symbols\RSI.cs" /> 71 70 <Compile Include="TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer.cs" /> 72 71 <Compile Include="TradeRulesSingleObjectiveValidationBestSolutionAnalyzer.cs" /> -
branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs
r9325 r9386 12 12 using HeuristicLab.Problems.DataAnalysis; 13 13 using System.Threading; 14 using HeuristicLab.Problems.TradeRules.Symbols;15 14 16 15 namespace HeuristicLab.Problems.TradeRules … … 268 267 double result2 = Evaluate(dataset, ref row, state); 269 268 double total = result + result2; 270 return total < 2 ? -1.0 : 1.0;269 return total < 2.0 ? -1.0 : 1.0; 271 270 } 272 271 case OpCodes.OR: … … 275 274 double result2 = Evaluate(dataset, ref row, state); 276 275 double total = result + result2; 277 return total > -2 ? 1.0 : -1.0;276 return total > -2.0 ? 1.0 : -1.0; 278 277 } 279 278 case OpCodes.NOT: 280 279 { 281 return Evaluate(dataset, ref row, state) > 0.0 ? -1.0 : 1.0;280 return Evaluate(dataset, ref row, state) > -1.0 ? -1.0 : 1.0; 282 281 } 283 282 … … 373 372 double signalValue = -100000; 374 373 double macd = 0; 375 double longitud = 0;376 374 377 375 //Check if this MACD has previous values and retrieve them … … 381 379 382 380 383 384 385 386 381 //Calculating the factor for each EMA 382 double factor = 2.0 / (firstEMA + 1.0); 383 double factor2 = 2.0 / (secondEMA + 1.0); 384 double factor3 = 2.0 / (signal + 1.0); 387 385 388 386 //Calculate the first value in the training for the two EMAs and the signal. 389 if (row <= initialTraining || row== initialTest)387 if (row == initialTest) 390 388 { 391 389 double [] meanValues = dataset.GetDoubleValues("\"Close\"", Enumerable.Range(0, row+1)).ToArray(); … … 424 422 secondEMACache[currentInstr.dynamicNode] = secondElementEMA; 425 423 signalCache[currentInstr.dynamicNode] = signalValue; 426 424 427 425 return macd > signalValue ? 1.0 : -1.0; 428 426 } … … 447 445 double factor = 1.0 / numberOfDays; 448 446 449 if (row == initialT raining || row == initialTest)447 if (row == initialTest) 450 448 { 451 449 double[] closeValues = dataset.GetDoubleValues("\"Close\"", Enumerable.Range(0, (row + 1))).ToArray(); … … 573 571 public void clearVariables() 574 572 { 575 signalCache.Clear();576 firstEMACache.Clear();577 secondEMACache.Clear();578 RSIPositiveCache.Clear();579 RSINegativeCache.Clear();580 RSICache.Clear();581 RSIOutputCache.Clear();573 if (signalCache != null) signalCache.Clear(); 574 if (firstEMACache != null) firstEMACache.Clear(); 575 if (secondEMACache != null) secondEMACache.Clear(); 576 if (RSIPositiveCache != null) RSIPositiveCache.Clear(); 577 if (RSINegativeCache != null) RSINegativeCache.Clear(); 578 if (RSICache != null) RSICache.Clear(); 579 if (RSIOutputCache != null) RSIOutputCache.Clear(); 582 580 } 583 581 … … 617 615 int row = rowEnum; 618 616 state.Reset(); 619 if (row < initialT raining) yield return -1;617 if (row < initialTest) yield return -1; 620 618 else yield return Evaluate(dataset, ref row, state); 621 619 } -
branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradeRulesSolutionBase.cs
r9262 r9386 29 29 private const string TrainingMeanErrorResultName = "Mean error (training)"; 30 30 private const string TestMeanErrorResultName = "Mean error (test)"; 31 private const string TestTradeDaysResultName = "Trade days"; 32 private const string TestNumberTradesResultName = "Number of trades"; 33 private const string TestTotalTradesResultName = "Total trades"; 34 31 35 32 36 public new IRegressionModel Model … … 58 62 get { return ((DoubleValue)this[TestCashResultName].Value).Value; } 59 63 private set { ((DoubleValue)this[TestCashResultName].Value).Value = value; } 64 } 65 public double TradeDays 66 { 67 get { return ((DoubleValue)this[TestTradeDaysResultName].Value).Value; } 68 private set { ((DoubleValue)this[TestTradeDaysResultName].Value).Value = value; } 69 } 70 public double NumberTrades 71 { 72 get { return ((DoubleValue)this[TestNumberTradesResultName].Value).Value; } 73 private set { ((DoubleValue)this[TestNumberTradesResultName].Value).Value = value; } 74 } 75 public double TotalTrades 76 { 77 get { return ((DoubleValue)this[TestTotalTradesResultName].Value).Value; } 78 private set { ((DoubleValue)this[TestTotalTradesResultName].Value).Value = value; } 60 79 } 61 80 public double TrainingMeanSquaredError … … 129 148 protected TradeRulesSolutionBase(IRegressionModel model, IRegressionProblemData problemData) 130 149 : base(model, problemData) { 131 150 Add(new Result(TrainingCashResultName, "Cash obtained after training period in the stock market", new DoubleValue())); 132 151 Add(new Result(TestCashResultName, "Cash obtained after test period in the stock market", new DoubleValue())); 133 Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue())); 134 Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue())); 135 Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue())); 136 Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue())); 137 Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 138 Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 139 Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue())); 140 Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue())); 141 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue())); 142 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue())); 143 Add(new Result(TrainingMeanErrorResultName, "Mean of errors of the model on the training partition", new DoubleValue())); 144 Add(new Result(TestMeanErrorResultName, "Mean of errors of the model on the test partition", new DoubleValue())); 145 } 152 Add(new Result(TestTradeDaysResultName, "Number of trading days", new DoubleValue())); 153 Add(new Result(TestNumberTradesResultName, "Number of trades", new DoubleValue())); 154 Add(new Result(TestTotalTradesResultName, "Total trades", new DoubleValue())); 155 } 146 156 147 157 [StorableHook(HookType.AfterDeserialization)] … … 194 204 IEnumerable<double> originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices); 195 205 196 OnlineCalculatorError errorState;197 double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);198 TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN;199 double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);200 TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;201 202 double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);203 TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;204 double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);205 TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;206 207 double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);208 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;209 double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);210 TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;211 212 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);213 TrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;214 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);215 TestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;216 217 double trainingNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);218 TrainingNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingNMSE : double.NaN;219 double testNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);220 TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNMSE : double.NaN;221 222 double trainingME = OnlineMeanErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);223 TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;224 double testME = OnlineMeanErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);225 TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;226 227 206 double trainingCTR = OnlineTradeRulesCalculator.Calculate(estimatedTrainingValues, ProblemData, ProblemData.TrainingIndices); 228 207 TrainingCash = trainingCTR; 229 208 double testCTR = OnlineTradeRulesCalculator.Calculate(estimatedTestValues, ProblemData, ProblemData.TestIndices); 230 209 TestCash = testCTR; 210 double testTradeDays = OnlineTradeRulesCalculator.getTradeDays(); 211 TradeDays = testTradeDays; 212 double testNumberTrades = OnlineTradeRulesCalculator.getNumberTrades(); 213 NumberTrades = testNumberTrades; 214 double testTotalTradeDays = OnlineTradeRulesCalculator.getTotalTradesDays(); 215 TotalTrades = testTotalTradeDays; 216 231 217 } 232 218 -
branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/MACD.cs
r9262 r9386 7 7 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 8 8 using HeuristicLab.Common; 9 using HeuristicLab.Problems.TradeRules.Symbols;10 9 11 10 namespace HeuristicLab.Problems.TradeRules … … 38 37 } 39 38 40 public override ISymbolicExpressionTreeNode CreateTreeNode()41 {42 return new MACDTreeNode(this);43 }44 45 39 public override IDeepCloneable Clone(Cloner cloner) 46 40 {
Note: See TracChangeset
for help on using the changeset viewer.