Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Calculators/OnlineSharpeRatioCalculator.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Calculators/OnlineSharpeRatioCalculator.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Calculators/OnlineSharpeRatioCalculator.cs (revision 6123)
@@ -0,0 +1,109 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ public class OnlineSharpeRatioCalculator : IOnlineCalculator {
+
+ private int p;
+ private double transactionCost;
+ private OnlineMeanAndVarianceCalculator meanAndVarianceCalculator;
+ public double SharpeRatio {
+ get {
+ if (meanAndVarianceCalculator.Variance > 0)
+ return meanAndVarianceCalculator.Mean / Math.Sqrt(meanAndVarianceCalculator.Variance);
+ else return 0.0;
+ }
+ }
+
+ public OnlineSharpeRatioCalculator(double transactionCost) {
+ this.transactionCost = transactionCost;
+ this.meanAndVarianceCalculator = new OnlineMeanAndVarianceCalculator();
+ Reset();
+ }
+
+ #region IOnlineCalculator Members
+ public OnlineCalculatorError ErrorState {
+ get {
+ return meanAndVarianceCalculator.MeanErrorState | meanAndVarianceCalculator.VarianceErrorState;
+ }
+ }
+ public double Value {
+ get { return SharpeRatio; }
+ }
+ public void Reset() {
+ p = 0;
+ meanAndVarianceCalculator.Reset();
+ }
+
+ public void Add(double actualReturn, double signal) {
+ double iterationReturn = 0.0;
+ if (p == 0 && signal.IsAlmost(0)) {
+ } else if (p == 0 && signal.IsAlmost(1)) {
+ p = 1;
+ } else if (p == 0 && signal.IsAlmost(-1)) {
+ p = -1;
+ } else if (p == 1 && signal.IsAlmost(1)) {
+ iterationReturn = actualReturn;
+ } else if (p == 1 && signal.IsAlmost(0)) {
+ iterationReturn = actualReturn - transactionCost;
+ p = 0;
+ } else if (p == 1 && signal.IsAlmost(-1)) {
+ iterationReturn = actualReturn - transactionCost;
+ p = -1;
+ } else if (p == -1 && signal.IsAlmost(-1)) {
+ iterationReturn = -actualReturn;
+ } else if (p == -1 && signal.IsAlmost(0)) {
+ iterationReturn = -actualReturn - transactionCost;
+ p = 0;
+ } else if (p == -1 && signal.IsAlmost(1)) {
+ iterationReturn = -actualReturn - transactionCost;
+ p = -1;
+ }
+ meanAndVarianceCalculator.Add(iterationReturn);
+ }
+ #endregion
+
+ public static double Calculate(IEnumerable returns, IEnumerable signals, double transactionCost, out OnlineCalculatorError errorState) {
+ IEnumerator returnsEnumerator = returns.GetEnumerator();
+ IEnumerator signalsEnumerator = signals.GetEnumerator();
+ OnlineSharpeRatioCalculator calculator = new OnlineSharpeRatioCalculator(transactionCost);
+
+ // always move forward both enumerators (do not use short-circuit evaluation!)
+ while (returnsEnumerator.MoveNext() & signalsEnumerator.MoveNext()) {
+ double signal = signalsEnumerator.Current;
+ double @return = returnsEnumerator.Current;
+ calculator.Add(@return, signal);
+ }
+
+ // check if both enumerators are at the end to make sure both enumerations have the same length
+ if (returnsEnumerator.MoveNext() || signalsEnumerator.MoveNext()) {
+ throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
+ } else {
+ errorState = calculator.ErrorState;
+ return calculator.SharpeRatio;
+ }
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Trading-3.4.csproj
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Trading-3.4.csproj (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Trading-3.4.csproj (revision 6123)
@@ -0,0 +1,247 @@
+
+
+
+ Debug
+ AnyCPU
+ 9.0.30729
+ 2.0
+ {E4EE5AFB-D552-447B-8A16-6CBE7938AF32}
+ Library
+ Properties
+ HeuristicLab.Problems.DataAnalysis.SymbolicTrading
+ HeuristicLab.Problems.DataAnalysis.Symbolic.Trading-3.4
+ v4.0
+
+
+ 512
+ true
+ HeuristicLab.snk
+
+
+ 3.5
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ AllRules.ruleset
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ AllRules.ruleset
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ AllRules.ruleset
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ AllRules.ruleset
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ AllRules.ruleset
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ AllRules.ruleset
+
+
+
+
+ 3.5
+
+
+
+
+ 3.5
+
+
+ 3.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SymbolicTradingSolutionView.cs
+
+
+
+
+
+
+
+ TradingSolutionLineChartView.cs
+
+
+
+ TradingSolutionView.cs
+
+
+
+
+
+
+
+
+ {887425B4-4348-49ED-A457-B7D2C26DDBF9}
+ HeuristicLab.Analysis-3.3
+
+
+ {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}
+ HeuristicLab.Collections-3.3
+
+
+ {A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}
+ HeuristicLab.Common-3.3
+
+
+ {C36BD924-A541-4A00-AFA8-41701378DDC5}
+ HeuristicLab.Core-3.3
+
+
+ {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}
+ HeuristicLab.Data-3.3
+
+
+ {06D4A186-9319-48A0-BADE-A2058D462EEA}
+ HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4
+
+
+ {FC841674-62A7-4055-BE91-E41944B6C606}
+ ALGLIB-3.1.0
+
+
+ {DE69A359-A5B8-4D3D-BA8D-D5780D7F96D6}
+ HeuristicLab.ALGLIB-3.1.0 %28HeuristicLab.ExtLibs\HeuristicLab.ALGLIB\HeuristicLab.ALGLIB-3.1.0\HeuristicLab.ALGLIB-3.1.0%29
+
+
+ {23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}
+ HeuristicLab.Operators-3.3
+
+
+ {14AB8D24-25BC-400C-A846-4627AA945192}
+ HeuristicLab.Optimization-3.3
+
+
+ {56F9106A-079F-4C61-92F6-86A84C2D84B7}
+ HeuristicLab.Parameters-3.3
+
+
+ {102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}
+ HeuristicLab.Persistence-3.3
+
+
+ {94186A6A-5176-4402-AE83-886557B53CCA}
+ HeuristicLab.PluginInfrastructure-3.3
+
+
+ {3D28463F-EC96-4D82-AFEE-38BE91A0CA00}
+ HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
+
+
+ {DF87C13E-A889-46FF-8153-66DCAA8C5674}
+ HeuristicLab.Problems.DataAnalysis-3.4
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
+
+
+ set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd
+SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin.cs.frame" "%25ProjectDir%25\HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin.cs"
+
+
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin.cs.frame
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin.cs.frame (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin.cs.frame (revision 6123)
@@ -0,0 +1,45 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Trading","Provides classes to perform symbolic trading (single- or multiobjective).", "3.4.0.$WCREV$")]
+ [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.Trading-3.4.dll", PluginFileType.Assembly)]
+ [PluginDependency("HeuristicLab.ALGLIB", "3.1")]
+ [PluginDependency("HeuristicLab.Analysis", "3.3")]
+ [PluginDependency("HeuristicLab.Common", "3.3")]
+ [PluginDependency("HeuristicLab.Collections", "3.3")]
+ [PluginDependency("HeuristicLab.Core", "3.3")]
+ [PluginDependency("HeuristicLab.Data", "3.3")]
+ [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
+ [PluginDependency("HeuristicLab.Operators", "3.3")]
+ [PluginDependency("HeuristicLab.Optimization", "3.3")]
+ [PluginDependency("HeuristicLab.Parameters", "3.3")]
+ [PluginDependency("HeuristicLab.Persistence", "3.3")]
+ [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
+ [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
+ public class HeuristicLabProblemsDataAnalysisSymbolicTradingPlugin : PluginBase {
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingEvaluator.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingEvaluator.cs (revision 6123)
@@ -0,0 +1,26 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ public interface ISymbolicTradingEvaluator : ISymbolicDataAnalysisEvaluator {
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingModel.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingModel.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingModel.cs (revision 6123)
@@ -0,0 +1,26 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ public interface ISymbolicTradingModel : ITradingModel, ISymbolicDataAnalysisModel {
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSingleObjectiveEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSingleObjectiveEvaluator.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSingleObjectiveEvaluator.cs (revision 6123)
@@ -0,0 +1,25 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ public interface ISymbolicTradingSingleObjectiveEvaluator : ISymbolicTradingEvaluator, ISymbolicDataAnalysisSingleObjectiveEvaluator {
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSolution.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSolution.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ISymbolicTradingSolution.cs (revision 6123)
@@ -0,0 +1,28 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ public interface ISymbolicTradingSolution : ITradingSolution, ISymbolicDataAnalysisSolution {
+ new ISymbolicTradingModel Model { get; }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingEnsembleModel.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingEnsembleModel.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingEnsembleModel.cs (revision 6123)
@@ -0,0 +1,28 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+namespace HeuristicLab.Problems.DataAnalysis {
+ public interface ITradingEnsembleModel : ITradingModel {
+ IEnumerable Models { get; }
+ IEnumerable> GetSignalVectors(Dataset dataset, IEnumerable rows);
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingModel.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingModel.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingModel.cs (revision 6123)
@@ -0,0 +1,27 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+namespace HeuristicLab.Problems.DataAnalysis {
+ public interface ITradingModel : IDataAnalysisModel {
+ IEnumerable GetSignals(Dataset dataset, IEnumerable rows);
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblem.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblem.cs (revision 6123)
@@ -0,0 +1,25 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ public interface ITradingProblem : IDataAnalysisProblem {
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblemData.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblemData.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingProblemData.cs (revision 6123)
@@ -0,0 +1,27 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ public interface ITradingProblemData : IDataAnalysisProblemData {
+ string PriceVariable { get; }
+ double TransactionCosts { get; }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingSolution.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingSolution.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Interfaces/ITradingSolution.cs (revision 6123)
@@ -0,0 +1,36 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+namespace HeuristicLab.Problems.DataAnalysis {
+ public interface ITradingSolution : IDataAnalysisSolution {
+ new ITradingModel Model { get; }
+ new ITradingProblemData ProblemData { get; }
+
+ IEnumerable Signals { get; }
+ IEnumerable TrainingSignals { get; }
+ IEnumerable TestSignals { get; }
+ IEnumerable GetSignals(IEnumerable rows);
+
+ double TrainingSharpeRatio { get; }
+ double TestSharpeRatio { get; }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Properties/AssemblyInfo.frame
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Properties/AssemblyInfo.frame (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Properties/AssemblyInfo.frame (revision 6123)
@@ -0,0 +1,55 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.Problems.DataAnalysis.Symbolic.Trading")]
+[assembly: AssemblyDescription("Provides classes to perform symbolic trading.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2011 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("BB953FDE-86BA-48A2-A684-5CD3A9BB3E31")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.4.0.0")]
+[assembly: AssemblyFileVersion("3.4.0.$WCREV$")]
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveEvaluator.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveEvaluator.cs (revision 6123)
@@ -0,0 +1,35 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+
+using HeuristicLab.Common;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ public abstract class SymbolicTradingSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator, ISymbolicTradingSingleObjectiveEvaluator {
+ [StorableConstructor]
+ protected SymbolicTradingSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
+ protected SymbolicTradingSingleObjectiveEvaluator(SymbolicTradingSingleObjectiveEvaluator original, Cloner cloner)
+ : base(original, cloner) {
+ }
+
+ protected SymbolicTradingSingleObjectiveEvaluator() : base() { }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveProblem.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveProblem.cs (revision 6123)
@@ -0,0 +1,65 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ [Item("Symbolic Trading Problem (single objective)", "Represents a single objective symbolic trading problem.")]
+ [StorableClass]
+ [Creatable("Problems")]
+ public class SymbolicTradingSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem, ITradingProblem {
+ private const int InitialMaximumTreeDepth = 8;
+ private const int InitialMaximumTreeLength = 25;
+
+ [StorableConstructor]
+ protected SymbolicTradingSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
+ protected SymbolicTradingSingleObjectiveProblem(SymbolicTradingSingleObjectiveProblem original, Cloner cloner) : base(original, cloner) { }
+ public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicTradingSingleObjectiveProblem(this, cloner); }
+
+ public SymbolicTradingSingleObjectiveProblem()
+ : base(new TradingProblemData(), new SymbolicTradingSingleObjectiveSharpeRatioEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
+ Maximization.Value = true;
+ MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
+ MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
+
+ InitializeOperators();
+ }
+
+ private void InitializeOperators() {
+ Operators.Add(new SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer());
+ Operators.Add(new SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer());
+ ParameterizeOperators();
+ }
+
+ protected override void ParameterizeOperators() {
+ base.ParameterizeOperators();
+ }
+
+ public override void ImportProblemDataFromFile(string fileName) {
+ TradingProblemData problemData = TradingProblemData.ImportFromFile(fileName);
+ ProblemData = problemData;
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveSharpeRatioEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveSharpeRatioEvaluator.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveSharpeRatioEvaluator.cs (revision 6123)
@@ -0,0 +1,95 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Linq;
+using System.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Parameters;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ [Item("Sharpe Ratio Evaluator", "")]
+ [StorableClass]
+ public class SymbolicTradingSingleObjectiveSharpeRatioEvaluator : SymbolicTradingSingleObjectiveEvaluator {
+ [StorableConstructor]
+ protected SymbolicTradingSingleObjectiveSharpeRatioEvaluator(bool deserializing) : base(deserializing) { }
+ protected SymbolicTradingSingleObjectiveSharpeRatioEvaluator(SymbolicTradingSingleObjectiveSharpeRatioEvaluator original, Cloner cloner)
+ : base(original, cloner) {
+ }
+ public SymbolicTradingSingleObjectiveSharpeRatioEvaluator()
+ : base() {
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new SymbolicTradingSingleObjectiveSharpeRatioEvaluator(this, cloner);
+ }
+
+ public override bool Maximization { get { return true; } }
+
+ public override IOperation Apply() {
+ var solution = SymbolicExpressionTreeParameter.ActualValue;
+ IEnumerable rows = GenerateRowsToEvaluate();
+
+ double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, ProblemDataParameter.ActualValue, rows);
+ QualityParameter.ActualValue = new DoubleValue(quality);
+
+ return base.Apply();
+ }
+
+ public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, ITradingProblemData problemData, IEnumerable rows) {
+ IEnumerable signals = GetSignals(interpreter, solution, problemData.Dataset, rows);
+ IEnumerable returns = problemData.Dataset.GetEnumeratedVariableValues(problemData.PriceVariable, rows);
+ OnlineCalculatorError errorState;
+ double sharpRatio = OnlineSharpeRatioCalculator.Calculate(returns, signals, problemData.TransactionCosts, out errorState);
+ if (errorState != OnlineCalculatorError.None) return 0.0;
+ else return sharpRatio;
+ }
+
+ private static IEnumerable GetSignals(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, Dataset dataset, IEnumerable rows) {
+ double signal = 0;
+ double prevSignal = 0;
+ foreach (var x in interpreter.GetSymbolicExpressionTreeValues(solution, dataset, rows)) {
+ if (prevSignal == 1) {
+ signal = x > -1 ? 1 : x > -2 ? 0 : -1; // 0, -1, -2
+ } else if (prevSignal == 0) {
+ signal = x > 1 ? 1 : x < -1 ? -1 : 0; // 1, 0 , -1
+ } else if (prevSignal == -1) {
+ signal = x < 1 ? -1 : x < 2 ? 0 : 1; // 2, 1, 0
+ }
+ yield return signal;
+ prevSignal = signal;
+ }
+ }
+
+ public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, ITradingProblemData problemData, IEnumerable rows) {
+ SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
+
+ double sharpRatio = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, problemData, rows);
+
+ SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
+
+ return sharpRatio;
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer.cs (revision 6123)
@@ -0,0 +1,65 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ ///
+ /// An operator that analyzes the training best symbolic trading solution for single objective symbolic trading problems.
+ ///
+ [Item("SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic trading solution for single objective symbolic trading problems.")]
+ [StorableClass]
+ public sealed class SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer,
+ ISymbolicDataAnalysisInterpreterOperator {
+ private const string ProblemDataParameterName = "ProblemData";
+ private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
+ #region parameter properties
+ public ILookupParameter ProblemDataParameter {
+ get { return (ILookupParameter)Parameters[ProblemDataParameterName]; }
+ }
+ public ILookupParameter SymbolicDataAnalysisTreeInterpreterParameter {
+ get { return (ILookupParameter)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ private SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
+ private SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer(SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
+ public SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer()
+ : base() {
+ Parameters.Add(new LookupParameter(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
+ Parameters.Add(new LookupParameter(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
+ }
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new SymbolicTradingSingleObjectiveTrainingBestSolutionAnalyzer(this, cloner);
+ }
+
+ protected override ISymbolicTradingSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
+ var model = new SymbolicTradingModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue);
+ return new SymbolicTradingSolution(model, (ITradingProblemData)ProblemDataParameter.ActualValue.Clone());
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SingleObjective/SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer.cs (revision 6123)
@@ -0,0 +1,53 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ ///
+ /// An operator that analyzes the validation best symbolic trading solution for single objective symbolic trading problems.
+ ///
+ [Item("SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer", "An operator that analyzes the validation best symbolic trading solution for single objective symbolic trading problems.")]
+ [StorableClass]
+ public sealed class SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer {
+
+ [StorableConstructor]
+ private SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
+ private SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer(SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
+ public SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer()
+ : base() {
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new SymbolicTradingSingleObjectiveValidationBestSolutionAnalyzer(this, cloner);
+ }
+
+ protected override ISymbolicTradingSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
+ var model = new SymbolicTradingModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue);
+ return new SymbolicTradingSolution(model, (ITradingProblemData)ProblemDataParameter.ActualValue.Clone());
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingModel.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingModel.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingModel.cs (revision 6123)
@@ -0,0 +1,65 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ ///
+ /// Represents a symbolic trading model
+ ///
+ [StorableClass]
+ [Item(Name = "SymbolicTradingModel", Description = "Represents a symbolic trading model.")]
+ public class SymbolicTradingModel : SymbolicDataAnalysisModel, ISymbolicTradingModel {
+
+ [StorableConstructor]
+ protected SymbolicTradingModel(bool deserializing) : base(deserializing) { }
+ protected SymbolicTradingModel(SymbolicTradingModel original, Cloner cloner)
+ : base(original, cloner) { }
+ public SymbolicTradingModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter)
+ : base(tree, interpreter) { }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new SymbolicTradingModel(this, cloner);
+ }
+
+ public IEnumerable GetSignals(Dataset dataset, IEnumerable rows) {
+ ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = Interpreter;
+ ISymbolicExpressionTree tree = SymbolicExpressionTree;
+ double signal = 0;
+ double prevSignal = 0;
+ foreach (var x in interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)) {
+ if (prevSignal == 1) {
+ signal = x > -1 ? 1 : x > -2 ? 0 : -1; // 0, -1, -2
+ } else if (prevSignal == 0) {
+ signal = x > 1 ? 1 : x < -1 ? -1 : 0; // 1, 0 , -1
+ } else if (prevSignal == -1) {
+ signal = x < 1 ? -1 : x < 2 ? 0 : 1; // 2, 1, 0
+ }
+ yield return signal;
+ prevSignal = signal;
+ }
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingSolution.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingSolution.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/SymbolicTradingSolution.cs (revision 6123)
@@ -0,0 +1,82 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading {
+ ///
+ /// Represents a symbolic trading solution (model + data) and attributes of the solution like accuracy and complexity
+ ///
+ [StorableClass]
+ [Item(Name = "SymbolicTradingSolution", Description = "Represents a symbolic trading solution (model + data) and attributes of the solution like accuracy and complexity.")]
+ public sealed class SymbolicTradingSolution : TradingSolution, ISymbolicTradingSolution {
+ private const string ModelLengthResultName = "Model Length";
+ private const string ModelDepthResultName = "Model Depth";
+
+ public new ISymbolicTradingModel Model {
+ get { return (ISymbolicTradingModel)base.Model; }
+ set { base.Model = value; }
+ }
+ ISymbolicDataAnalysisModel ISymbolicDataAnalysisSolution.Model {
+ get { return (ISymbolicDataAnalysisModel)base.Model; }
+ }
+ public int ModelLength {
+ get { return ((IntValue)this[ModelLengthResultName].Value).Value; }
+ private set { ((IntValue)this[ModelLengthResultName].Value).Value = value; }
+ }
+
+ public int ModelDepth {
+ get { return ((IntValue)this[ModelDepthResultName].Value).Value; }
+ private set { ((IntValue)this[ModelDepthResultName].Value).Value = value; }
+ }
+
+ [StorableConstructor]
+ private SymbolicTradingSolution(bool deserializing) : base(deserializing) { }
+ private SymbolicTradingSolution(SymbolicTradingSolution original, Cloner cloner)
+ : base(original, cloner) {
+ }
+ public SymbolicTradingSolution(ISymbolicTradingModel model, ITradingProblemData problemData)
+ : base(model, problemData) {
+ Add(new Result(ModelLengthResultName, "Length of the symbolic trading model.", new IntValue()));
+ Add(new Result(ModelDepthResultName, "Depth of the symbolic trading model.", new IntValue()));
+ RecalculateResults();
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new SymbolicTradingSolution(this, cloner);
+ }
+
+ protected override void OnModelChanged(EventArgs e) {
+ base.OnModelChanged(e);
+ RecalculateResults();
+ }
+
+ private new void RecalculateResults() {
+ ModelLength = Model.SymbolicExpressionTree.Length;
+ ModelDepth = Model.SymbolicExpressionTree.Depth;
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingEnsembleModel.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingEnsembleModel.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingEnsembleModel.cs (revision 6123)
@@ -0,0 +1,81 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ ///
+ /// Represents trading solutions that contain an ensemble of multiple trading models
+ ///
+ [StorableClass]
+ [Item("TradingEnsembleModel", "A trading model that contains an ensemble of multiple trading models")]
+ public class TradingEnsembleModel : NamedItem, ITradingEnsembleModel {
+
+ [Storable]
+ private List models;
+ public IEnumerable Models {
+ get { return new List(models); }
+ }
+ [StorableConstructor]
+ protected TradingEnsembleModel(bool deserializing) : base(deserializing) { }
+ protected TradingEnsembleModel(TradingEnsembleModel original, Cloner cloner)
+ : base(original, cloner) {
+ this.models = original.Models.Select(m => cloner.Clone(m)).ToList();
+ }
+ public TradingEnsembleModel(IEnumerable models)
+ : base() {
+ this.name = ItemName;
+ this.description = ItemDescription;
+ this.models = new List(models);
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new TradingEnsembleModel(this, cloner);
+ }
+
+ #region ITradingEnsembleModel Members
+
+ public IEnumerable> GetSignalVectors(Dataset dataset, IEnumerable rows) {
+ var signalEnumerators = (from model in models
+ select model.GetSignals(dataset, rows).GetEnumerator())
+ .ToList();
+
+ while (signalEnumerators.All(en => en.MoveNext())) {
+ yield return from enumerator in signalEnumerators
+ select enumerator.Current;
+ }
+ }
+
+ #endregion
+
+ #region ITradingModel Members
+
+ public IEnumerable GetSignals(Dataset dataset, IEnumerable rows) {
+ throw new System.NotImplementedException();
+ }
+
+ #endregion
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblem.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblem.cs (revision 6123)
@@ -0,0 +1,47 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ [StorableClass]
+ [Item("Trading Problem", "A general trading problem.")]
+ [Creatable("Problems")]
+ public class TradingProblem : DataAnalysisProblem, ITradingProblem {
+ [StorableConstructor]
+ protected TradingProblem(bool deserializing) : base(deserializing) { }
+ protected TradingProblem(TradingProblem original, Cloner cloner) : base(original, cloner) { }
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new TradingProblem(this, cloner); }
+
+ public TradingProblem()
+ : base() {
+ ProblemData = new TradingProblemData();
+ }
+
+ public override void ImportProblemDataFromFile(string fileName) {
+ TradingProblemData problemData = TradingProblemData.ImportFromFile(fileName);
+ ProblemData = problemData;
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblemData.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblemData.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblemData.cs (revision 6123)
@@ -0,0 +1,1664 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ [StorableClass]
+ [Item("TradingProblemData", "Represents an item containing all data defining a trading problem.")]
+ public sealed class TradingProblemData : DataAnalysisProblemData, ITradingProblemData {
+ private const string PriceVariableParameterName = "PriceVariable";
+ private const string TransactionCostsParameterName = "TransactionCosts";
+
+ #region default data
+ private static double[,] audInUsd = new double[,] {
+ { 0.0000},
+ { 0.0003},
+ {-0.0004},
+ { 0.0000},
+ { 0.0003},
+ { 0.0003},
+ {-0.0005},
+ { 0.0001},
+ { 0.0004},
+ { 0.0001},
+ {-0.0005},
+ {-0.0014},
+ {-0.0002},
+ { 0.0000},
+ { 0.0011},
+ { 0.0024},
+ {-0.0022},
+ {-0.0035},
+ { 0.0003},
+ { 0.0005},
+ { 0.0014},
+ {-0.0003},
+ { 0.0001},
+ { 0.0001},
+ { 0.0001},
+ { 0.0008},
+ {-0.0004},
+ { 0.0012},
+ { 0.0001},
+ {-0.0001},
+ { 0.0004},
+ {-0.0004},
+ {-0.0007},
+ {-0.0007},
+ {-0.0011},
+ { 0.0001},
+ {-0.0003},
+ {-0.0009},
+ { 0.0001},
+ {-0.0009},
+ { 0.0006},
+ { 0.0006},
+ {-0.0006},
+ { 0.0015},
+ { 0.0003},
+ {-0.0005},
+ {-0.0010},
+ {-0.0005},
+ { 0.0002},
+ {-0.0005},
+ {-0.0002},
+ {-0.0010},
+ { 0.0015},
+ { 0.0001},
+ {-0.0010},
+ {-0.0003},
+ { 0.0004},
+ {-0.0022},
+ { 0.0008},
+ {-0.0007},
+ { 0.0004},
+ { 0.0036},
+ {-0.0005},
+ { 0.0002},
+ { 0.0009},
+ {-0.0002},
+ { 0.0004},
+ { 0.0012},
+ {-0.0005},
+ { 0.0004},
+ {-0.0010},
+ {-0.0006},
+ {-0.0028},
+ { 0.0007},
+ { 0.0009},
+ { 0.0005},
+ {-0.0001},
+ { 0.0001},
+ {-0.0011},
+ { 0.0004},
+ { 0.0007},
+ {-0.0004},
+ { 0.0005},
+ {-0.0008},
+ {-0.0005},
+ {-0.0011},
+ { 0.0004},
+ {-0.0008},
+ { 0.0016},
+ { 0.0008},
+ {-0.0002},
+ { 0.0000},
+ {-0.0015},
+ { 0.0002},
+ {-0.0008},
+ {-0.0005},
+ {-0.0001},
+ { 0.0002},
+ { 0.0038},
+ { 0.0007},
+ {-0.0001},
+ { 0.0000},
+ { 0.0015},
+ { 0.0000},
+ { 0.0009},
+ {-0.0008},
+ {-0.0001},
+ {-0.0006},
+ { 0.0019},
+ {-0.0002},
+ { 0.0002},
+ {-0.0017},
+ {-0.0003},
+ {-0.0004},
+ {-0.0017},
+ { 0.0003},
+ { 0.0000},
+ { 0.0001},
+ { 0.0003},
+ { 0.0006},
+ {-0.0001},
+ {-0.0009},
+ { 0.0007},
+ { 0.0004},
+ { 0.0002},
+ { 0.0001},
+ {-0.0001},
+ {-0.0013},
+ { 0.0009},
+ { 0.0003},
+ { 0.0004},
+ { 0.0001},
+ { 0.0001},
+ { 0.0001},
+ { 0.0007},
+ { 0.0013},
+ { 0.0029},
+ {-0.0011},
+ { 0.0003},
+ { 0.0001},
+ { 0.0003},
+ {-0.0005},
+ { 0.0003},
+ { 0.0004},
+ { 0.0008},
+ {-0.0006},
+ { 0.0005},
+ {-0.0001},
+ { 0.0000},
+ { 0.0003},
+ { 0.0013},
+ { 0.0005},
+ { 0.0002},
+ { 0.0005},
+ {-0.0005},
+ { 0.0012},
+ {-0.0006},
+ { 0.0001},
+ {-0.0012},
+ { 0.0015},
+ {-0.0005},
+ {-0.0005},
+ { 0.0012},
+ {-0.0006},
+ {-0.0001},
+ {-0.0002},
+ { 0.0000},
+ { 0.0003},
+ {-0.0008},
+ { 0.0010},
+ { 0.0003},
+ {-0.0006},
+ { 0.0001},
+ {-0.0001},
+ { 0.0014},
+ {-0.0011},
+ {-0.0002},
+ {-0.0001},
+ { 0.0005},
+ { 0.0006},
+ {-0.0018},
+ {-0.0007},
+ {-0.0001},
+ {-0.0001},
+ { 0.0002},
+ {-0.0008},
+ { 0.0027},
+ { 0.0006},
+ {-0.0005},
+ {-0.0003},
+ {-0.0003},
+ {-0.0001},
+ { 0.0005},
+ { 0.0003},
+ { 0.0004},
+ { 0.0013},
+ { 0.0006},
+ { 0.0000},
+ { 0.0011},
+ { 0.0003},
+ {-0.0008},
+ {-0.0003},
+ { 0.0005},
+ {-0.0004},
+ {-0.0015},
+ {-0.0006},
+ { 0.0008},
+ { 0.0016},
+ {-0.0009},
+ { 0.0007},
+ {-0.0009},
+ {-0.0005},
+ { 0.0001},
+ { 0.0005},
+ { 0.0002},
+ {-0.0011},
+ { 0.0006},
+ {-0.0016},
+ {-0.0013},
+ {-0.0006},
+ {-0.0004},
+ {-0.0002},
+ {-0.0006},
+ { 0.0014},
+ { 0.0002},
+ {-0.0006},
+ {-0.0007},
+ {-0.0001},
+ {-0.0010},
+ {-0.0012},
+ { 0.0009},
+ {-0.0009},
+ {-0.0006},
+ { 0.0000},
+ { 0.0014},
+ {-0.0011},
+ {-0.0002},
+ {-0.0012},
+ {-0.0003},
+ { 0.0003},
+ {-0.0010},
+ {-0.0008},
+ { 0.0001},
+ {-0.0005},
+ {-0.0011},
+ { 0.0006},
+ {-0.0008},
+ { 0.0012},
+ { 0.0007},
+ {-0.0009},
+ { 0.0005},
+ { 0.0017},
+ { 0.0003},
+ {-0.0011},
+ { 0.0034},
+ {-0.0017},
+ {-0.0006},
+ {-0.0008},
+ { 0.0004},
+ {-0.0005},
+ {-0.0006},
+ { 0.0001},
+ { 0.0009},
+ {-0.0036},
+ {-0.0010},
+ { 0.0005},
+ { 0.0000},
+ { 0.0003},
+ {-0.0007},
+ { 0.0021},
+ { 0.0003},
+ { 0.0005},
+ { 0.0003},
+ {-0.0005},
+ {-0.0001},
+ {-0.0011},
+ {-0.0009},
+ { 0.0007},
+ { 0.0003},
+ { 0.0006},
+ { 0.0001},
+ {-0.0002},
+ { 0.0006},
+ { 0.0005},
+ { 0.0005},
+ {-0.0008},
+ {-0.0008},
+ { 0.0005},
+ { 0.0006},
+ {-0.0007},
+ { 0.0003},
+ { 0.0005},
+ { 0.0000},
+ { 0.0003},
+ { 0.0010},
+ {-0.0018},
+ { 0.0003},
+ {-0.0001},
+ { 0.0008},
+ {-0.0015},
+ {-0.0008},
+ { 0.0032},
+ { 0.0009},
+ { 0.0005},
+ {-0.0014},
+ {-0.0003},
+ { 0.0029},
+ { 0.0002},
+ {-0.0002},
+ {-0.0002},
+ { 0.0005},
+ { 0.0008},
+ {-0.0007},
+ { 0.0014},
+ {-0.0004},
+ {-0.0003},
+ { 0.0004},
+ {-0.0001},
+ {-0.0007},
+ { 0.0002},
+ { 0.0002},
+ { 0.0005},
+ { 0.0012},
+ {-0.0018},
+ { 0.0014},
+ { 0.0004},
+ { 0.0012},
+ { 0.0002},
+ { 0.0009},
+ {-0.0007},
+ { 0.0002},
+ { 0.0000},
+ {-0.0011},
+ {-0.0002},
+ { 0.0008},
+ {-0.0010},
+ { 0.0013},
+ {-0.0003},
+ {-0.0001},
+ {-0.0002},
+ { 0.0001},
+ { 0.0003},
+ {-0.0012},
+ { 0.0009},
+ {-0.0003},
+ { 0.0005},
+ {-0.0018},
+ { 0.0013},
+ { 0.0004},
+ { 0.0006},
+ { 0.0003},
+ {-0.0016},
+ {-0.0005},
+ { 0.0005},
+ { 0.0004},
+ { 0.0000},
+ {-0.0007},
+ {-0.0007},
+ { 0.0008},
+ {-0.0007},
+ { 0.0008},
+ { 0.0004},
+ { 0.0003},
+ { 0.0019},
+ { 0.0003},
+ {-0.0004},
+ { 0.0021},
+ {-0.0013},
+ { 0.0006},
+ {-0.0009},
+ { 0.0012},
+ { 0.0011},
+ { 0.0003},
+ { 0.0011},
+ {-0.0003},
+ {-0.0007},
+ { 0.0001},
+ { 0.0009},
+ {-0.0002},
+ {-0.0012},
+ {-0.0010},
+ {-0.0002},
+ {-0.0007},
+ {-0.0001},
+ {-0.0008},
+ { 0.0001},
+ { 0.0001},
+ { 0.0005},
+ { 0.0007},
+ {-0.0004},
+ {-0.0007},
+ {-0.0003},
+ {-0.0005},
+ { 0.0006},
+ { 0.0001},
+ {-0.0012},
+ {-0.0004},
+ { 0.0014},
+ {-0.0005},
+ { 0.0007},
+ {-0.0001},
+ {-0.0002},
+ { 0.0010},
+ {-0.0015},
+ {-0.0003},
+ { 0.0009},
+ { 0.0000},
+ {-0.0009},
+ { 0.0010},
+ { 0.0016},
+ {-0.0002},
+ {-0.0001},
+ {-0.0004},
+ {-0.0011},
+ { 0.0004},
+ { 0.0010},
+ {-0.0007},
+ {-0.0003},
+ {-0.0008},
+ {-0.0012},
+ { 0.0003},
+ { 0.0016},
+ {-0.0019},
+ {-0.0006},
+ { 0.0006},
+ { 0.0006},
+ {-0.0002},
+ {-0.0004},
+ { 0.0003},
+ { 0.0008},
+ {-0.0013},
+ {-0.0012},
+ {-0.0002},
+ {-0.0005},
+ { 0.0010},
+ {-0.0009},
+ {-0.0003},
+ { 0.0016},
+ {-0.0013},
+ { 0.0003},
+ { 0.0003},
+ {-0.0007},
+ { 0.0016},
+ { 0.0002},
+ {-0.0013},
+ {-0.0002},
+ {-0.0009},
+ {-0.0003},
+ { 0.0010},
+ { 0.0002},
+ { 0.0013},
+ {-0.0006},
+ {-0.0006},
+ { 0.0001},
+ {-0.0005},
+ { 0.0018},
+ { 0.0002},
+ { 0.0006},
+ {-0.0002},
+ {-0.0004},
+ { 0.0000},
+ { 0.0016},
+ {-0.0011},
+ {-0.0004},
+ { 0.0002},
+ { 0.0001},
+ { 0.0025},
+ {-0.0011},
+ {-0.0008},
+ { 0.0009},
+ {-0.0001},
+ {-0.0005},
+ {-0.0001},
+ { 0.0005},
+ { 0.0001},
+ {-0.0008},
+ {-0.0001},
+ { 0.0003},
+ { 0.0008},
+ {-0.0011},
+ { 0.0003},
+ { 0.0004},
+ { 0.0005},
+ { 0.0014},
+ {-0.0002},
+ { 0.0008},
+ { 0.0004},
+ { 0.0019},
+ {-0.0005},
+ {-0.0005},
+ {-0.0005},
+ { 0.0000},
+ {-0.0006},
+ { 0.0015},
+ {-0.0011},
+ {-0.0017},
+ {-0.0002},
+ { 0.0007},
+ { 0.0004},
+ {-0.0018},
+ {-0.0001},
+ {-0.0002},
+ {-0.0001},
+ { 0.0005},
+ {-0.0003},
+ { 0.0000},
+ { 0.0007},
+ { 0.0006},
+ {-0.0014},
+ { 0.0006},
+ {-0.0003},
+ { 0.0002},
+ {-0.0002},
+ {-0.0002},
+ { 0.0002},
+ {-0.0009},
+ {-0.0001},
+ {-0.0001},
+ { 0.0000},
+ { 0.0012},
+ { 0.0000},
+ { 0.0003},
+ {-0.0008},
+ { 0.0004},
+ { 0.0000},
+ {-0.0003},
+ {-0.0013},
+ {-0.0005},
+ {-0.0005},
+ {-0.0001},
+ {-0.0004},
+ { 0.0006},
+ { 0.0000},
+ {-0.0008},
+ {-0.0004},
+ {-0.0024},
+ { 0.0003},
+ {-0.0005},
+ { 0.0007},
+ { 0.0003},
+ {-0.0004},
+ {-0.0004},
+ { 0.0003},
+ { 0.0000},
+ { 0.0014},
+ {-0.0004},
+ { 0.0000},
+ {-0.0009},
+ { 0.0012},
+ {-0.0008},
+ { 0.0028},
+ { 0.0003},
+ { 0.0001},
+ { 0.0010},
+ {-0.0005},
+ { 0.0004},
+ {-0.0005},
+ { 0.0001},
+ {-0.0005},
+ { 0.0017},
+ {-0.0012},
+ {-0.0002},
+ { 0.0010},
+ {-0.0009},
+ {-0.0001},
+ { 0.0003},
+ { 0.0001},
+ { 0.0031},
+ {-0.0005},
+ { 0.0004},
+ { 0.0002},
+ {-0.0001},
+ {-0.0003},
+ {-0.0013},
+ {-0.0015},
+ {-0.0003},
+ { 0.0010},
+ { 0.0010},
+ {-0.0002},
+ { 0.0027},
+ { 0.0004},
+ { 0.0001},
+ {-0.0007},
+ { 0.0000},
+ {-0.0002},
+ { 0.0011},
+ {-0.0009},
+ {-0.0003},
+ {-0.0006},
+ { 0.0007},
+ {-0.0015},
+ { 0.0004},
+ {-0.0002},
+ { 0.0002},
+ { 0.0001},
+ {-0.0005},
+ { 0.0000},
+ { 0.0003},
+ {-0.0011},
+ { 0.0001},
+ {-0.0001},
+ { 0.0002},
+ {-0.0006},
+ { 0.0003},
+ {-0.0004},
+ {-0.0005},
+ {-0.0005},
+ { 0.0000},
+ { 0.0007},
+ {-0.0032},
+ { 0.0001},
+ { 0.0007},
+ {-0.0008},
+ {-0.0004},
+ {-0.0004},
+ {-0.0004},
+ { 0.0010},
+ {-0.0001},
+ {-0.0001},
+ { 0.0002},
+ { 0.0000},
+ { 0.0001},
+ {-0.0009},
+ {-0.0002},
+ {-0.0009},
+ {-0.0002},
+ { 0.0002},
+ { 0.0002},
+ { 0.0010},
+ { 0.0002},
+ {-0.0005},
+ {-0.0005},
+ {-0.0021},
+ { 0.0008},
+ { 0.0000},
+ { 0.0006},
+ {-0.0006},
+ {-0.0007},
+ { 0.0007},
+ {-0.0007},
+ { 0.0005},
+ { 0.0011},
+ {-0.0006},
+ {-0.0004},
+ { 0.0012},
+ { 0.0001},
+ { 0.0010},
+ {-0.0002},
+ {-0.0004},
+ {-0.0004},
+ {-0.0003},
+ {-0.0006},
+ { 0.0011},
+ { 0.0000},
+ { 0.0012},
+ { 0.0001},
+ {-0.0003},
+ { 0.0011},
+ { 0.0007},
+ {-0.0007},
+ { 0.0005},
+ {-0.0002},
+ { 0.0008},
+ { 0.0002},
+ { 0.0008},
+ {-0.0002},
+ { 0.0005},
+ { 0.0002},
+ {-0.0009},
+ { 0.0003},
+ {-0.0008},
+ { 0.0004},
+ {-0.0009},
+ { 0.0006},
+ { 0.0011},
+ { 0.0010},
+ { 0.0006},
+ {-0.0006},
+ { 0.0005},
+ { 0.0002},
+ {-0.0035},
+ { 0.0008},
+ {-0.0006},
+ {-0.0011},
+ { 0.0008},
+ {-0.0003},
+ {-0.0005},
+ { 0.0004},
+ { 0.0000},
+ { 0.0002},
+ {-0.0011},
+ { 0.0001},
+ {-0.0009},
+ { 0.0007},
+ {-0.0003},
+ { 0.0005},
+ {-0.0005},
+ { 0.0002},
+ {-0.0021},
+ {-0.0004},
+ { 0.0000},
+ { 0.0014},
+ {-0.0004},
+ {-0.0006},
+ {-0.0031},
+ {-0.0006},
+ { 0.0004},
+ { 0.0001},
+ {-0.0012},
+ {-0.0011},
+ { 0.0004},
+ {-0.0002},
+ { 0.0000},
+ {-0.0004},
+ {-0.0002},
+ { 0.0013},
+ {-0.0007},
+ {-0.0007},
+ { 0.0001},
+ { 0.0001},
+ {-0.0010},
+ { 0.0001},
+ { 0.0006},
+ {-0.0001},
+ {-0.0008},
+ {-0.0015},
+ {-0.0008},
+ {-0.0001},
+ { 0.0010},
+ {-0.0004},
+ { 0.0000},
+ {-0.0016},
+ { 0.0000},
+ { 0.0001},
+ {-0.0004},
+ {-0.0001},
+ { 0.0014},
+ {-0.0025},
+ {-0.0006},
+ {-0.0011},
+ {-0.0002},
+ {-0.0001},
+ {-0.0005},
+ {-0.0005},
+ {-0.0014},
+ { 0.0000},
+ {-0.0007},
+ { 0.0021},
+ { 0.0002},
+ {-0.0005},
+ {-0.0009},
+ {-0.0002},
+ { 0.0020},
+ { 0.0004},
+ {-0.0011},
+ {-0.0018},
+ { 0.0005},
+ { 0.0005},
+ { 0.0000},
+ { 0.0000},
+ { 0.0004},
+ { 0.0008},
+ {-0.0004},
+ {-0.0007},
+ { 0.0001},
+ { 0.0009},
+ {-0.0001},
+ { 0.0010},
+ {-0.0005},
+ {-0.0023},
+ { 0.0004},
+ { 0.0022},
+ {-0.0013},
+ { 0.0003},
+ {-0.0003},
+ {-0.0003},
+ { 0.0010},
+ {-0.0002},
+ { 0.0000},
+ { 0.0002},
+ {-0.0004},
+ {-0.0007},
+ {-0.0005},
+ {-0.0003},
+ { 0.0005},
+ {-0.0010},
+ {-0.0004},
+ { 0.0001},
+ { 0.0003},
+ { 0.0000},
+ { 0.0008},
+ { 0.0001},
+ { 0.0004},
+ { 0.0002},
+ { 0.0001},
+ {-0.0005},
+ {-0.0005},
+ {-0.0003},
+ { 0.0016},
+ { 0.0006},
+ {-0.0014},
+ { 0.0016},
+ { 0.0016},
+ { 0.0009},
+ {-0.0002},
+ {-0.0002},
+ { 0.0005},
+ {-0.0005},
+ {-0.0004},
+ {-0.0008},
+ {-0.0003},
+ {-0.0001},
+ { 0.0005},
+ {-0.0002},
+ {-0.0004},
+ {-0.0003},
+ { 0.0003},
+ { 0.0003},
+ {-0.0003},
+ { 0.0003},
+ {-0.0004},
+ { 0.0000},
+ {-0.0008},
+ {-0.0013},
+ { 0.0007},
+ {-0.0011},
+ { 0.0015},
+ {-0.0008},
+ { 0.0007},
+ {-0.0002},
+ {-0.0004},
+ { 0.0005},
+ {-0.0008},
+ { 0.0000},
+ {-0.0008},
+ { 0.0007},
+ { 0.0007},
+ { 0.0011},
+ { 0.0000},
+ { 0.0003},
+ {-0.0005},
+ { 0.0003},
+ { 0.0012},
+ { 0.0005},
+ {-0.0006},
+ {-0.0002},
+ {-0.0007},
+ {-0.0027},
+ {-0.0012},
+ {-0.0005},
+ { 0.0005},
+ { 0.0002},
+ { 0.0001},
+ { 0.0003},
+ { 0.0003},
+ { 0.0002},
+ {-0.0002},
+ {-0.0003},
+ { 0.0009},
+ { 0.0003},
+ { 0.0003},
+ { 0.0006},
+ {-0.0002},
+ {-0.0003},
+ {-0.0004},
+ { 0.0011},
+ { 0.0000},
+ { 0.0000},
+ { 0.0000},
+ {-0.0007},
+ { 0.0001},
+ { 0.0019},
+ { 0.0011},
+ {-0.0011},
+ { 0.0002},
+ { 0.0009},
+ { 0.0002},
+ { 0.0004},
+ {-0.0001},
+ {-0.0008},
+ { 0.0001},
+ { 0.0003},
+ {-0.0002},
+ {-0.0002},
+ { 0.0002},
+ { 0.0003},
+ { 0.0000},
+ { 0.0010},
+ { 0.0013},
+ {-0.0004},
+ {-0.0009},
+ {-0.0005},
+ { 0.0018},
+ { 0.0018},
+ {-0.0006},
+ {-0.0006},
+ {-0.0009},
+ { 0.0005},
+ {-0.0004},
+ {-0.0001},
+ { 0.0012},
+ {-0.0002},
+ {-0.0006},
+ {-0.0024},
+ {-0.0002},
+ {-0.0011},
+ { 0.0003},
+ { 0.0009},
+ { 0.0002},
+ { 0.0002},
+ { 0.0003},
+ {-0.0002},
+ {-0.0002},
+ { 0.0000},
+ { 0.0000},
+ {-0.0010},
+ {-0.0007},
+ { 0.0009},
+ { 0.0001},
+ { 0.0020},
+ { 0.0001},
+ { 0.0005},
+ {-0.0003},
+ { 0.0004},
+ {-0.0005},
+ { 0.0005},
+ { 0.0002},
+ { 0.0001},
+ { 0.0001},
+ { 0.0004},
+ { 0.0008},
+ { 0.0000},
+ {-0.0008},
+ { 0.0002},
+ {-0.0012},
+ {-0.0004},
+ { 0.0004},
+ {-0.0001},
+ { 0.0010},
+ {-0.0009},
+ {-0.0007},
+ {-0.0006},
+ {-0.0002},
+ { 0.0001},
+ {-0.0004},
+ { 0.0002},
+ { 0.0000},
+ { 0.0000},
+ {-0.0012},
+ {-0.0002},
+ {-0.0002},
+ { 0.0009},
+ {-0.0008},
+ {-0.0001},
+ { 0.0008},
+ {-0.0001},
+ {-0.0002},
+ {-0.0004},
+ { 0.0009},
+ { 0.0001},
+ { 0.0005},
+ { 0.0015},
+ {-0.0001},
+ {-0.0002},
+ {-0.0004},
+ { 0.0009},
+ {-0.0010},
+ {-0.0005},
+ { 0.0004},
+ { 0.0011},
+ { 0.0009},
+ {-0.0003},
+ {-0.0002},
+ { 0.0006},
+ { 0.0003},
+ {-0.0003},
+ {-0.0002},
+ { 0.0015},
+ { 0.0003},
+ { 0.0001},
+ {-0.0001},
+ {-0.0001},
+ {-0.0005},
+ {-0.0001},
+ { 0.0003},
+ { 0.0002},
+ { 0.0001},
+ {-0.0002},
+ {-0.0008},
+ { 0.0003},
+ {-0.0001},
+ { 0.0000},
+ { 0.0002},
+ {-0.0002},
+ {-0.0001},
+ {-0.0005},
+ { 0.0002},
+ { 0.0000},
+ { 0.0000},
+ { 0.0004},
+ { 0.0000},
+ {-0.0013},
+ {-0.0043},
+ { 0.0007},
+ { 0.0001},
+ {-0.0007},
+ {-0.0001},
+ { 0.0003},
+ { 0.0013},
+ { 0.0005},
+ {-0.0007},
+ { 0.0002},
+ {-0.0014},
+ {-0.0002},
+ { 0.0000},
+ { 0.0020},
+ { 0.0009},
+ {-0.0018},
+ {-0.0005},
+ {-0.0009},
+ {-0.0005},
+ { 0.0008},
+ { 0.0005},
+ {-0.0004},
+ { 0.0004},
+ { 0.0001},
+ { 0.0003},
+ { 0.0003},
+ {-0.0008},
+ {-0.0007},
+ { 0.0008},
+ {-0.0004},
+ {-0.0028},
+ {-0.0006},
+ {-0.0022},
+ {-0.0009},
+ { 0.0003},
+ { 0.0003},
+ { 0.0000},
+ { 0.0021},
+ {-0.0017},
+ { 0.0009},
+ {-0.0001},
+ {-0.0005},
+ {-0.0015},
+ { 0.0009},
+ { 0.0009},
+ {-0.0009},
+ { 0.0010},
+ { 0.0000},
+ { 0.0018},
+ {-0.0011},
+ { 0.0001},
+ {-0.0008},
+ { 0.0009},
+ { 0.0022},
+ { 0.0011},
+ {-0.0002},
+ {-0.0018},
+ { 0.0019},
+ {-0.0004},
+ {-0.0004},
+ { 0.0002},
+ { 0.0027},
+ {-0.0012},
+ {-0.0003},
+ {-0.0002},
+ { 0.0013},
+ { 0.0002},
+ {-0.0003},
+ { 0.0002},
+ { 0.0003},
+ {-0.0002},
+ { 0.0020},
+ {-0.0003},
+ { 0.0002},
+ {-0.0001},
+ {-0.0001},
+ { 0.0006},
+ {-0.0012},
+ { 0.0011},
+ { 0.0001},
+ { 0.0001},
+ { 0.0004},
+ {-0.0002},
+ { 0.0029},
+ {-0.0016},
+ { 0.0005},
+ {-0.0029},
+ {-0.0002},
+ { 0.0013},
+ { 0.0011},
+ {-0.0003},
+ { 0.0002},
+ { 0.0001},
+ { 0.0001},
+ {-0.0005},
+ { 0.0000},
+ { 0.0009},
+ { 0.0016},
+ { 0.0005},
+ { 0.0003},
+ { 0.0004},
+ {-0.0001},
+ { 0.0020},
+ { 0.0006},
+ {-0.0006},
+ {-0.0004},
+ { 0.0012},
+ { 0.0012},
+ { 0.0017},
+ { 0.0017},
+ {-0.0004},
+ { 0.0001},
+ { 0.0001},
+ {-0.0006},
+ {-0.0003},
+ { 0.0004},
+ { 0.0008},
+ {-0.0014},
+ { 0.0011},
+ {-0.0003},
+ { 0.0004},
+ {-0.0001},
+ { 0.0017},
+ { 0.0008},
+ { 0.0005},
+ {-0.0002},
+ { 0.0001},
+ {-0.0013},
+ { 0.0009},
+ {-0.0008},
+ {-0.0003},
+ { 0.0013},
+ {-0.0002},
+ {-0.0004},
+ { 0.0007},
+ {-0.0009},
+ { 0.0002},
+ {-0.0002},
+ {-0.0006},
+ { 0.0003},
+ {-0.0003},
+ {-0.0004},
+ {-0.0006},
+ {-0.0004},
+ { 0.0006},
+ {-0.0006},
+ { 0.0019},
+ {-0.0012},
+ {-0.0002},
+ { 0.0003},
+ { 0.0001},
+ { 0.0001},
+ { 0.0002},
+ { 0.0004},
+ { 0.0000},
+ {-0.0013},
+ {-0.0017},
+ {-0.0017},
+ {-0.0006},
+ {-0.0003},
+ { 0.0006},
+ { 0.0001},
+ { 0.0007},
+ {-0.0004},
+ { 0.0000},
+ { 0.0019},
+ {-0.0008},
+ {-0.0006},
+ { 0.0003},
+ {-0.0004},
+ {-0.0002},
+ { 0.0008},
+ {-0.0007},
+ {-0.0004},
+ {-0.0001},
+ {-0.0004},
+ {-0.0003},
+ { 0.0004},
+ {-0.0008},
+ { 0.0015},
+ { 0.0011},
+ {-0.0013},
+ {-0.0003},
+ { 0.0000},
+ { 0.0006},
+ {-0.0003},
+ {-0.0003},
+ { 0.0005},
+ {-0.0016},
+ { 0.0005},
+ {-0.0002},
+ {-0.0009},
+ {-0.0001},
+ {-0.0004},
+ { 0.0007},
+ { 0.0004},
+ { 0.0015},
+ { 0.0005},
+ {-0.0007},
+ { 0.0002},
+ {-0.0007},
+ {-0.0009},
+ {-0.0029},
+ { 0.0003},
+ {-0.0002},
+ {-0.0010},
+ {-0.0001},
+ { 0.0005},
+ {-0.0003},
+ { 0.0002},
+ {-0.0006},
+ { 0.0008},
+ {-0.0010},
+ { 0.0005},
+ { 0.0003},
+ { 0.0009},
+ { 0.0002},
+ { 0.0001},
+ { 0.0002},
+ {-0.0010},
+ {-0.0017},
+ { 0.0004},
+ {-0.0007},
+ { 0.0019},
+ {-0.0001},
+ {-0.0004},
+ {-0.0023},
+ { 0.0015},
+ { 0.0009},
+ {-0.0006},
+ {-0.0001},
+ { 0.0000},
+ { 0.0001},
+ { 0.0003},
+ {-0.0002},
+ { 0.0039},
+ {-0.0007},
+ { 0.0000},
+ {-0.0002},
+ {-0.0005},
+ { 0.0007},
+ { 0.0010},
+ {-0.0004},
+ { 0.0006},
+ {-0.0003},
+ {-0.0006},
+ { 0.0003},
+ { 0.0022},
+ {-0.0030},
+ { 0.0010},
+ { 0.0005},
+ { 0.0000},
+ {-0.0005},
+ {-0.0004},
+ {-0.0010},
+ {-0.0001},
+ { 0.0000},
+ {-0.0002},
+ { 0.0003},
+ {-0.0003},
+ {-0.0007},
+ {-0.0001},
+ { 0.0016},
+ {-0.0009},
+ { 0.0001},
+ { 0.0005},
+ { 0.0016},
+ {-0.0013},
+ {-0.0003},
+ {-0.0002},
+ { 0.0014},
+ {-0.0008},
+ { 0.0026},
+ {-0.0003},
+ { 0.0007},
+ { 0.0011},
+ { 0.0005},
+ {-0.0001},
+ { 0.0004},
+ {-0.0003},
+ { 0.0006},
+ {-0.0013},
+ { 0.0002},
+ {-0.0003},
+ {-0.0010},
+ { 0.0000},
+ {-0.0007},
+ {-0.0001},
+ { 0.0008},
+ {-0.0010},
+ {-0.0005},
+ { 0.0010},
+ { 0.0013},
+ { 0.0008},
+ {-0.0004},
+ { 0.0020},
+ {-0.0002},
+ { 0.0005},
+ { 0.0003},
+ { 0.0004},
+ { 0.0005},
+ { 0.0007},
+ {-0.0008},
+ { 0.0003},
+ {-0.0008},
+ { 0.0011},
+ { 0.0005},
+ { 0.0002},
+ {-0.0005},
+ {-0.0011},
+ { 0.0001},
+ {-0.0002},
+ {-0.0003},
+ { 0.0016},
+ {-0.0005},
+ {-0.0002},
+ {-0.0008},
+ { 0.0023},
+ { 0.0015},
+ { 0.0001},
+ {-0.0004},
+ { 0.0015},
+ {-0.0002},
+ { 0.0003},
+ { 0.0001},
+ { 0.0002},
+ {-0.0007},
+ { 0.0005},
+ {-0.0001},
+ { 0.0007},
+ {-0.0007},
+ { 0.0018},
+ {-0.0002},
+ { 0.0005},
+ {-0.0002},
+ {-0.0004},
+ {-0.0001},
+ {-0.0001},
+ { 0.0002},
+ { 0.0009},
+ { 0.0003},
+ {-0.0006},
+ {-0.0003},
+ {-0.0022},
+ { 0.0002},
+ { 0.0004},
+ { 0.0004},
+ {-0.0005},
+ {-0.0008},
+ {-0.0001},
+ { 0.0000},
+ { 0.0010},
+ { 0.0001},
+ {-0.0005},
+ {-0.0003},
+ {-0.0005},
+ { 0.0005},
+ {-0.0003},
+ { 0.0000},
+ { 0.0002},
+ { 0.0001},
+ {-0.0014},
+ {-0.0005},
+ {-0.0001},
+ { 0.0006},
+ { 0.0004},
+ { 0.0005},
+ { 0.0017},
+ { 0.0009},
+ { 0.0008},
+ { 0.0017},
+ { 0.0006},
+ {-0.0003},
+ { 0.0004},
+ { 0.0000},
+ {-0.0015},
+ {-0.0001},
+ { 0.0000},
+ {-0.0008},
+ { 0.0000},
+ { 0.0004},
+ {-0.0006},
+ { 0.0001},
+ { 0.0001},
+ { 0.0003},
+ {-0.0001},
+ { 0.0001},
+ {-0.0011},
+ {-0.0011},
+ { 0.0010},
+ { 0.0004},
+ { 0.0008},
+ { 0.0007},
+ { 0.0004},
+ {-0.0023},
+ { 0.0023},
+ {-0.0001},
+ {-0.0004},
+ { 0.0000},
+ {-0.0003},
+ {-0.0008},
+ { 0.0005},
+ { 0.0004},
+ {-0.0004},
+ { 0.0001},
+ {-0.0007},
+ {-0.0001},
+ {-0.0006},
+ {-0.0012},
+ {-0.0027},
+ { 0.0002},
+ {-0.0012},
+ { 0.0013},
+ { 0.0000},
+ {-0.0008},
+ { 0.0009},
+ {-0.0015},
+ { 0.0007},
+ { 0.0002},
+ { 0.0001},
+ {-0.0013},
+ { 0.0002},
+ {-0.0004},
+ {-0.0002},
+ {-0.0027},
+ { 0.0013},
+ {-0.0005},
+ { 0.0006},
+ { 0.0000},
+ {-0.0005},
+ { 0.0011},
+ { 0.0000},
+ {-0.0003},
+ { 0.0018},
+ {-0.0003},
+ { 0.0006},
+ {-0.0008},
+ {-0.0006},
+ {-0.0015},
+ {-0.0009},
+ {-0.0017},
+ { 0.0005},
+ { 0.0007},
+ {-0.0006},
+ {-0.0004},
+ { 0.0016},
+ { 0.0000},
+ { 0.0003},
+ {-0.0019},
+ { 0.0003},
+ { 0.0005},
+ { 0.0003},
+ { 0.0001},
+ {-0.0002},
+ { 0.0007},
+ { 0.0001},
+ {-0.0012},
+ { 0.0008},
+ {-0.0011},
+ { 0.0008},
+ { 0.0010},
+ {-0.0003},
+ {-0.0003},
+ {-0.0006},
+ {-0.0004},
+ { 0.0000},
+ { 0.0011},
+ { 0.0003},
+ {-0.0005},
+ {-0.0002},
+ { 0.0001},
+ {-0.0004},
+ { 0.0008},
+ {-0.0007},
+ {-0.0005},
+ {-0.0005},
+ {-0.0003},
+ {-0.0005},
+ { 0.0006},
+ {-0.0014},
+ {-0.0001},
+ { 0.0003},
+ { 0.0009},
+ { 0.0012},
+ {-0.0023},
+ {-0.0004},
+ { 0.0002},
+ { 0.0001},
+ {-0.0019},
+ { 0.0012},
+ {-0.0022},
+ { 0.0001},
+ {-0.0004},
+ {-0.0001},
+ { 0.0012},
+ { 0.0001},
+ { 0.0000},
+ { 0.0004},
+ {-0.0008},
+ { 0.0006},
+ {-0.0007},
+ { 0.0008},
+ {-0.0009},
+ {-0.0005},
+ {-0.0001},
+ {-0.0004},
+ { 0.0001},
+ {-0.0005},
+ {-0.0004},
+ {-0.0012},
+ { 0.0002},
+ { 0.0011},
+ { 0.0008},
+ {-0.0009},
+ { 0.0010},
+ {-0.0003},
+ {-0.0006},
+ { 0.0005},
+ { 0.0002},
+ {-0.0003},
+ { 0.0016},
+ {-0.0006},
+ { 0.0000},
+ { 0.0008},
+ {-0.0002},
+ { 0.0000},
+ { 0.0000},
+ { 0.0003},
+ {-0.0011},
+ {-0.0009},
+ {-0.0013},
+ {-0.0003},
+ { 0.0009},
+ { 0.0007},
+ {-0.0005},
+ { 0.0012},
+ {-0.0009},
+ { 0.0004},
+ {-0.0008},
+ {-0.0011},
+ { 0.0013},
+ { 0.0013},
+ { 0.0005 }};
+
+ private static Dataset defaultDataset;
+ private static IEnumerable defaultAllowedInputVariables;
+ private static string defaultPriceVariable;
+
+ static TradingProblemData() {
+ defaultDataset = new Dataset(new string[] { "AUD" }, audInUsd);
+ defaultDataset.Name = "AUD in USD";
+ defaultDataset.Description = "Price of Australian dollar in US dollar.";
+ defaultAllowedInputVariables = new List() { "AUD" };
+ defaultPriceVariable = "AUD";
+ }
+ #endregion
+
+ public IValueParameter PriceVariableParameter {
+ get { return (IValueParameter)Parameters[PriceVariableParameterName]; }
+ }
+ public IValueParameter TransactionCostsParameter {
+ get { return (IValueParameter)Parameters[TransactionCostsParameterName]; }
+ }
+ public string PriceVariable {
+ get { return PriceVariableParameter.Value.Value; }
+ }
+ public double TransactionCosts {
+ get { return TransactionCostsParameter.Value.Value; }
+ }
+
+ [StorableConstructor]
+ private TradingProblemData(bool deserializing) : base(deserializing) { }
+ [StorableHook(HookType.AfterDeserialization)]
+ private void AfterDeserialization() {
+ RegisterParameterEvents();
+ }
+
+ private TradingProblemData(TradingProblemData original, Cloner cloner)
+ : base(original, cloner) {
+ RegisterParameterEvents();
+ }
+ public override IDeepCloneable Clone(Cloner cloner) { return new TradingProblemData(this, cloner); }
+
+ public TradingProblemData()
+ : this(defaultDataset, defaultAllowedInputVariables, defaultPriceVariable) {
+ }
+
+ public TradingProblemData(Dataset dataset, IEnumerable allowedInputVariables, string targetVariable)
+ : base(dataset, allowedInputVariables) {
+ var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
+ Parameters.Add(new ConstrainedValueParameter(PriceVariableParameterName, new ItemSet(variables), variables.Where(x => x.Value == targetVariable).First()));
+ Parameters.Add(new FixedValueParameter(TransactionCostsParameterName, "The absolute cost of on buy/sell transaction (assumed to be constant and independent of transaction volume)", new DoubleValue(0.0002)));
+ RegisterParameterEvents();
+ }
+
+ private void RegisterParameterEvents() {
+ PriceVariableParameter.ValueChanged += new EventHandler(PriceVariableParameter_ValueChanged);
+ TransactionCostsParameter.Value.ValueChanged += new EventHandler(TransactionCostsParameter_ValueChanged);
+ }
+
+ private void TransactionCostsParameter_ValueChanged(object sender, EventArgs e) {
+ OnChanged();
+ }
+ private void PriceVariableParameter_ValueChanged(object sender, EventArgs e) {
+ OnChanged();
+ }
+
+ #region Import from file
+ public static TradingProblemData ImportFromFile(string fileName) {
+ TableFileParser csvFileParser = new TableFileParser();
+ csvFileParser.Parse(fileName);
+
+ Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
+ dataset.Name = Path.GetFileName(fileName);
+
+ TradingProblemData problemData = new TradingProblemData(dataset, dataset.VariableNames.Skip(1), dataset.VariableNames.First());
+ problemData.Name = "Data imported from " + Path.GetFileName(fileName);
+ return problemData;
+ }
+ #endregion
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingSolution.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingSolution.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingSolution.cs (revision 6123)
@@ -0,0 +1,117 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+ ///
+ /// Abstract base class for trading data analysis solutions
+ ///
+ [StorableClass]
+ public abstract class TradingSolution : DataAnalysisSolution, ITradingSolution {
+ private const string TrainingSharpeRatioResultName = "Sharpe ratio (training)";
+ private const string TestSharpeRatioResultName = "Sharpe ratio (test)";
+
+ public new ITradingModel Model {
+ get { return (ITradingModel)base.Model; }
+ protected set { base.Model = value; }
+ }
+
+ public new ITradingProblemData ProblemData {
+ get { return (ITradingProblemData)base.ProblemData; }
+ protected set { base.ProblemData = value; }
+ }
+
+ public double TrainingSharpeRatio {
+ get { return ((DoubleValue)this[TrainingSharpeRatioResultName].Value).Value; }
+ private set { ((DoubleValue)this[TrainingSharpeRatioResultName].Value).Value = value; }
+ }
+
+ public double TestSharpeRatio {
+ get { return ((DoubleValue)this[TestSharpeRatioResultName].Value).Value; }
+ private set { ((DoubleValue)this[TestSharpeRatioResultName].Value).Value = value; }
+ }
+
+ [StorableConstructor]
+ protected TradingSolution(bool deserializing) : base(deserializing) { }
+ protected TradingSolution(TradingSolution original, Cloner cloner)
+ : base(original, cloner) {
+ }
+ public TradingSolution(ITradingModel model, ITradingProblemData problemData)
+ : base(model, problemData) {
+ Add(new Result(TrainingSharpeRatioResultName, "Share ratio of the signals of the model on the training partition", new DoubleValue()));
+ Add(new Result(TestSharpeRatioResultName, "Sharpe ratio of the signals of the model on the test partition", new DoubleValue()));
+
+ RecalculateResults();
+ }
+
+ protected override void OnProblemDataChanged(EventArgs e) {
+ base.OnProblemDataChanged(e);
+ RecalculateResults();
+ }
+ protected override void OnModelChanged(EventArgs e) {
+ base.OnModelChanged(e);
+ RecalculateResults();
+ }
+
+ protected void RecalculateResults() {
+ double[] trainingSignals = TrainingSignals.ToArray(); // cache values
+ IEnumerable trainingReturns = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.PriceVariable, ProblemData.TrainingIndizes);
+ double[] testSignals = TestSignals.ToArray(); // cache values
+ IEnumerable testReturns = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.PriceVariable, ProblemData.TestIndizes);
+
+ OnlineCalculatorError errorState;
+ double trainingSharpeRatio = OnlineSharpeRatioCalculator.Calculate(trainingReturns, trainingSignals, ProblemData.TransactionCosts, out errorState);
+ TrainingSharpeRatio = errorState == OnlineCalculatorError.None ? trainingSharpeRatio : double.NaN;
+ double testSharpeRatio = OnlineSharpeRatioCalculator.Calculate(testReturns, testSignals, ProblemData.TransactionCosts, out errorState);
+ TestSharpeRatio = errorState == OnlineCalculatorError.None ? testSharpeRatio : double.NaN;
+
+ }
+
+ public virtual IEnumerable Signals {
+ get {
+ return GetSignals(Enumerable.Range(0, ProblemData.Dataset.Rows));
+ }
+ }
+
+ public virtual IEnumerable TrainingSignals {
+ get {
+ return GetSignals(ProblemData.TrainingIndizes);
+ }
+ }
+
+ public virtual IEnumerable TestSignals {
+ get {
+ return GetSignals(ProblemData.TestIndizes);
+ }
+ }
+
+ public virtual IEnumerable GetSignals(IEnumerable rows) {
+ return Model.GetSignals(ProblemData.Dataset, rows);
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.Designer.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.Designer.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.Designer.cs (revision 6123)
@@ -0,0 +1,84 @@
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading.Views {
+ partial class SymbolicTradingSolutionView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
+ this.splitContainer.Panel1.SuspendLayout();
+ this.splitContainer.Panel2.SuspendLayout();
+ this.splitContainer.SuspendLayout();
+ this.itemsGroupBox.SuspendLayout();
+ this.detailsGroupBox.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // splitContainer
+ //
+ //
+ // splitContainer.Panel1
+ //
+ this.splitContainer.Size = new System.Drawing.Size(480, 275);
+ this.splitContainer.SplitterDistance = 255;
+ //
+ // itemsGroupBox
+ //
+ this.itemsGroupBox.Size = new System.Drawing.Size(486, 294);
+ //
+ // itemsListView
+ //
+ this.itemsListView.Size = new System.Drawing.Size(249, 238);
+ //
+ // detailsGroupBox
+ //
+ this.detailsGroupBox.Size = new System.Drawing.Size(215, 246);
+ //
+ // addButton
+ //
+ this.toolTip.SetToolTip(this.addButton, "Add");
+ //
+ // removeButton
+ //
+ this.toolTip.SetToolTip(this.removeButton, "Remove");
+ //
+ // viewHost
+ //
+ this.viewHost.Size = new System.Drawing.Size(203, 221);
+
+ //
+ // SymbolicRegressionSolutionView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.Name = "SymbolicRegressionSolutionView";
+ this.Size = new System.Drawing.Size(486, 294);
+ this.splitContainer.Panel1.ResumeLayout(false);
+ this.splitContainer.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+ this.splitContainer.ResumeLayout(false);
+ this.itemsGroupBox.ResumeLayout(false);
+ this.detailsGroupBox.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/SymbolicTradingSolutionView.cs (revision 6123)
@@ -0,0 +1,40 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Windows.Forms;
+using HeuristicLab.MainForm;
+using HeuristicLab.Problems.DataAnalysis.Views;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Trading.Views {
+ [Content(typeof(SymbolicTradingSolution), true)]
+ [View("SymbolicTradingSolution View")]
+ public partial class SymbolicTradingSolutionView : TradingSolutionView {
+ public SymbolicTradingSolutionView() {
+ InitializeComponent();
+ }
+
+ protected new SymbolicTradingSolution Content {
+ get { return (SymbolicTradingSolution)base.Content; }
+ set { base.Content = value; }
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.Designer.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.Designer.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.Designer.cs (revision 6123)
@@ -0,0 +1,84 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ partial class TradingSolutionLineChartView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
+ ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
+ this.SuspendLayout();
+ //
+ // chart
+ //
+ chartArea1.Name = "ChartArea";
+ this.chart.ChartAreas.Add(chartArea1);
+ this.chart.Dock = System.Windows.Forms.DockStyle.Fill;
+ legend1.Alignment = System.Drawing.StringAlignment.Center;
+ legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
+ legend1.Name = "Default";
+ this.chart.Legends.Add(legend1);
+ this.chart.Location = new System.Drawing.Point(0, 0);
+ this.chart.Name = "chart";
+ this.chart.Size = new System.Drawing.Size(358, 225);
+ this.chart.TabIndex = 0;
+ this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Chart_MouseDoubleClick);
+ //
+ // LineChartView
+ //
+ this.AllowDrop = true;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.chart);
+ this.Name = "LineChartView";
+ this.Size = new System.Drawing.Size(358, 225);
+ ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart;
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.cs (revision 6123)
@@ -0,0 +1,156 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+using System;
+using System.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
+using HeuristicLab.Core.Views;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ [View("Line Chart")]
+ [Content(typeof(ITradingSolution))]
+ public partial class TradingSolutionLineChartView : ItemView, ITradingSolutionEvaluationView {
+ private const string PRICEVARIABLE_SERIES_NAME = "PriceVariable";
+ private const string SIGNALS_SERIES_NAME = "Signals";
+
+ public new ITradingSolution Content {
+ get { return (ITradingSolution)base.Content; }
+ set { base.Content = value; }
+ }
+
+ public TradingSolutionLineChartView()
+ : base() {
+ InitializeComponent();
+ //configure axis
+ this.chart.CustomizeAllChartAreas();
+ this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
+ this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
+ this.chart.ChartAreas[0].CursorX.Interval = 1;
+
+ this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
+ this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
+ this.chart.ChartAreas[0].CursorY.Interval = 0;
+ }
+
+ private void RedrawChart() {
+ this.chart.Series.Clear();
+ if (Content != null) {
+ this.chart.Series.Add(PRICEVARIABLE_SERIES_NAME);
+ this.chart.Series[PRICEVARIABLE_SERIES_NAME].LegendText = Content.ProblemData.PriceVariable;
+ this.chart.Series[PRICEVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine;
+ this.chart.Series[PRICEVARIABLE_SERIES_NAME].Points.DataBindY(Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.PriceVariable));
+ this.UpdateStripLines();
+
+ this.chart.Series.Add(SIGNALS_SERIES_NAME);
+ this.chart.Series[SIGNALS_SERIES_NAME].LegendText = Content.ItemName;
+ this.chart.Series[SIGNALS_SERIES_NAME].ChartType = SeriesChartType.FastLine;
+ this.chart.Series[SIGNALS_SERIES_NAME].Points.DataBindY(Content.Signals.ToArray());
+ this.chart.Series[SIGNALS_SERIES_NAME].Tag = Content;
+ UpdateCursorInterval();
+ }
+ }
+
+ private void UpdateCursorInterval() {
+ var estimatedValues = this.chart.Series[SIGNALS_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
+ var targetValues = this.chart.Series[PRICEVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
+ double estimatedValuesRange = estimatedValues.Max() - estimatedValues.Min();
+ double targetValuesRange = targetValues.Max() - targetValues.Min();
+ double interestingValuesRange = Math.Min(Math.Max(targetValuesRange, 1.0), Math.Max(estimatedValuesRange, 1.0));
+ double digits = (int)Math.Log10(interestingValuesRange) - 3;
+ double yZoomInterval = Math.Max(Math.Pow(10, digits), 10E-5);
+ this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
+ }
+
+ #region events
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ Content.ModelChanged += new EventHandler(Content_ModelChanged);
+ Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
+ }
+ protected override void DeregisterContentEvents() {
+ base.DeregisterContentEvents();
+ Content.ModelChanged -= new EventHandler(Content_ModelChanged);
+ Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
+ }
+
+ private void Content_ProblemDataChanged(object sender, EventArgs e) {
+ RedrawChart();
+ }
+
+ private void Content_ModelChanged(object sender, EventArgs e) {
+ UpdateEstimatedValuesLineChart();
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ RedrawChart();
+ }
+
+ private void UpdateEstimatedValuesLineChart() {
+ if (InvokeRequired) Invoke((Action)UpdateEstimatedValuesLineChart);
+ else {
+ if (this.chart.Series.Count > 0) {
+ Series s = this.chart.Series.SingleOrDefault(x => x.Tag == Content);
+ if (s != null) {
+ s.Points.DataBindY(Content.Signals.ToArray());
+ s.LegendText = Content.ItemName;
+ this.UpdateStripLines();
+ UpdateCursorInterval();
+ }
+ }
+ }
+ }
+
+ private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) {
+ HitTestResult result = chart.HitTest(e.X, e.Y);
+ if (result.ChartArea != null && (result.ChartElementType == ChartElementType.PlottingArea ||
+ result.ChartElementType == ChartElementType.Gridlines) ||
+ result.ChartElementType == ChartElementType.StripLines) {
+ foreach (var axis in result.ChartArea.Axes)
+ axis.ScaleView.ZoomReset(int.MaxValue);
+ }
+ }
+ #endregion
+
+ private void UpdateStripLines() {
+ this.chart.ChartAreas[0].AxisX.StripLines.Clear();
+ this.CreateAndAddStripLine("Training", Color.FromArgb(20, Color.Green),
+ Content.ProblemData.TrainingPartition.Start,
+ Content.ProblemData.TrainingPartition.End);
+ this.CreateAndAddStripLine("Test", Color.FromArgb(20, Color.Red),
+ Content.ProblemData.TestPartition.Start,
+ Content.ProblemData.TestPartition.End);
+ }
+
+ private void CreateAndAddStripLine(string title, Color c, int start, int end) {
+ StripLine stripLine = new StripLine();
+ stripLine.BackColor = c;
+ stripLine.Text = title;
+ stripLine.Font = new Font("Times New Roman", 12, FontStyle.Bold);
+ stripLine.StripWidth = end - start;
+ stripLine.IntervalOffset = start;
+ this.chart.ChartAreas[0].AxisX.StripLines.Add(stripLine);
+ }
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.Designer.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.Designer.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.Designer.cs (revision 6123)
@@ -0,0 +1,87 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ partial class TradingSolutionView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
+ this.splitContainer.Panel1.SuspendLayout();
+ this.splitContainer.Panel2.SuspendLayout();
+ this.splitContainer.SuspendLayout();
+ this.itemsGroupBox.SuspendLayout();
+ this.detailsGroupBox.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // splitContainer
+ //
+ //
+ // itemsGroupBox
+ //
+ this.itemsGroupBox.Text = "Regression Solution";
+ //
+ // addButton
+ //
+ this.toolTip.SetToolTip(this.addButton, "Add");
+ //
+ // removeButton
+ //
+ this.toolTip.SetToolTip(this.removeButton, "Remove");
+ //
+ // RegressionSolutionView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Name = "RegressionSolutionView";
+ this.splitContainer.Panel1.ResumeLayout(false);
+ this.splitContainer.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+ this.splitContainer.ResumeLayout(false);
+ this.itemsGroupBox.ResumeLayout(false);
+ this.detailsGroupBox.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
Index: /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.cs
===================================================================
--- /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.cs (revision 6123)
+++ /branches/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.cs (revision 6123)
@@ -0,0 +1,44 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Windows.Forms;
+using HeuristicLab.MainForm;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ [View("TradingSolution View")]
+ [Content(typeof(TradingSolution), true)]
+ public partial class TradingSolutionView : DataAnalysisSolutionView {
+ public TradingSolutionView() {
+ InitializeComponent();
+
+ var regressionSolutionEvaluationViewTypes = ApplicationManager.Manager.GetTypes(typeof(ITradingSolutionEvaluationView), true);
+ foreach (Type viewType in regressionSolutionEvaluationViewTypes)
+ AddViewListViewItem(viewType);
+ }
+
+ public new TradingSolution Content {
+ get { return (TradingSolution)base.Content; }
+ set { base.Content = value; }
+ }
+ }
+}