Changeset 9176
- Timestamp:
- 01/22/13 13:39:17 (12 years ago)
- Location:
- branches/HeuristicLab.Problems.DataAnalysis.Trading
- Files:
-
- 2 added
- 3 deleted
- 13 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Calculators/OnlineSharpeRatioCalculator.cs
r6861 r9176 83 83 iterationReturn = -actualReturn; 84 84 } else if (p == -1 && signal.IsAlmost(0)) { 85 iterationReturn = - (actualReturn - transactionCost);85 iterationReturn = -actualReturn - transactionCost; 86 86 p = 0; 87 87 } else if (p == -1 && signal.IsAlmost(1)) { 88 iterationReturn = - (actualReturn - transactionCost);88 iterationReturn = -actualReturn - transactionCost; 89 89 p = 1; 90 90 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLab.Problems.DataAnalysis.Trading-3.4.csproj
r6136 r9176 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> bin\Debug\</OutputPath>43 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 58 58 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> 59 59 <DebugSymbols>true</DebugSymbols> 60 <OutputPath> bin\x64\Debug\</OutputPath>60 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 61 61 <DefineConstants>DEBUG;TRACE</DefineConstants> 62 62 <DebugType>full</DebugType> … … 76 76 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 77 77 <DebugSymbols>true</DebugSymbols> 78 <OutputPath> bin\x86\Debug\</OutputPath>78 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 79 79 <DefineConstants>DEBUG;TRACE</DefineConstants> 80 80 <DebugType>full</DebugType> … … 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="ALGLIB-3.1.0"> 96 <HintPath>c:\Program Files\HeuristicLab 3.3\ALGLIB-3.1.0.dll</HintPath> 95 <Reference Include="ALGLIB-3.6.0, Version=3.6.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 <SpecificVersion>False</SpecificVersion> 97 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.6.0.dll</HintPath> 97 98 </Reference> 98 99 <Reference Include="HeuristicLab.Analysis-3.3"> … … 161 162 <Reference Include="HeuristicLab.Problems.DataAnalysis.Views-3.4"> 162 163 <HintPath>c:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Views-3.4.dll</HintPath> 164 </Reference> 165 <Reference Include="HeuristicLab.Problems.Instances-3.3"> 166 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.Instances-3.3.dll</HintPath> 167 </Reference> 168 <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3"> 169 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath> 163 170 </Reference> 164 171 <Reference Include="HeuristicLab.Random-3.3"> … … 185 192 </ItemGroup> 186 193 <ItemGroup> 194 <Compile Include="Calculators\OnlineProfitCalculator.cs" /> 187 195 <Compile Include="HeuristicLabProblemsDataAnalysisTradingPlugin.cs" /> 188 196 <Compile Include="Interfaces\ITradingEnsembleModel.cs" /> … … 192 200 <Compile Include="Interfaces\ITradingSolution.cs" /> 193 201 <Compile Include="Calculators\OnlineSharpeRatioCalculator.cs" /> 202 <Compile Include="CSVInstanceProvider.cs" /> 194 203 <Compile Include="Symbolic\Interfaces\ISymbolicTradingEvaluator.cs" /> 195 204 <Compile Include="Symbolic\Interfaces\ISymbolicTradingModel.cs" /> … … 228 237 <None Include="HeuristicLab.snk" /> 229 238 <None Include="HeuristicLabProblemsDataAnalysisTradingPlugin.cs.frame" /> 230 <None Include="Properties\AssemblyInfo.frame" />231 239 <Compile Include="Properties\AssemblyInfo.cs" /> 240 <None Include="Properties\AssemblyInfo.cs.frame" /> 232 241 </ItemGroup> 233 242 <ItemGroup> -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/HeuristicLabProblemsDataAnalysisTradingPlugin.cs.frame
r6126 r9176 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Trading","Provides classes to optimize trading rules (single- or multiobjective).", "3.4.0.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Trading-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 1")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.6")] 31 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 32 32 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Symbolic/SingleObjective/SymbolicTradingSingleObjectiveProblem.cs
r6123 r9176 58 58 } 59 59 60 public override void ImportProblemDataFromFile(string fileName) {61 TradingProblemData problemData = TradingProblemData.ImportFromFile(fileName);62 ProblemData = problemData;63 }60 //public override void ImportProblemDataFromFile(string fileName) { 61 // TradingProblemData problemData = TradingProblemData.ImportFromFile(fileName); 62 // ProblemData = problemData; 63 //} 64 64 } 65 65 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Symbolic/SingleObjective/SymbolicTradingSingleObjectiveSharpeRatioEvaluator.cs
r6861 r9176 60 60 public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, ITradingProblemData problemData, IEnumerable<int> rows) { 61 61 IEnumerable<double> signals = GetSignals(interpreter, solution, problemData.Dataset, rows); 62 IEnumerable<double> returns = problemData.Dataset.Get EnumeratedVariableValues(problemData.PriceVariable, rows);62 IEnumerable<double> returns = problemData.Dataset.GetDoubleValues(problemData.PriceVariable, rows); 63 63 OnlineCalculatorError errorState; 64 64 double sharpRatio = OnlineSharpeRatioCalculator.Calculate(returns, signals, problemData.TransactionCosts, out errorState); -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Symbolic/SymbolicTradingSolution.cs
r6126 r9176 70 70 } 71 71 72 protected override void OnModelChanged( EventArgs e) {73 base.OnModelChanged( e);72 protected override void OnModelChanged() { 73 base.OnModelChanged(); 74 74 RecalculateResults(); 75 75 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblem.cs
r6125 r9176 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Problems.Instances; 25 26 26 27 namespace HeuristicLab.Problems.DataAnalysis { … … 39 40 ProblemData = new TradingProblemData(); 40 41 } 41 42 public override void ImportProblemDataFromFile(string fileName) {43 TradingProblemData problemData = TradingProblemData.ImportFromFile(fileName);44 ProblemData = problemData;45 }46 42 } 47 43 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingProblemData.cs
r6125 r9176 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Problems.Instances; 32 using HeuristicLab.Problems.Instances.DataAnalysis; 31 33 32 34 namespace HeuristicLab.Problems.DataAnalysis { … … 1648 1650 } 1649 1651 1650 #region Import from file 1651 public static TradingProblemData ImportFromFile(string fileName) { 1652 TableFileParser csvFileParser = new TableFileParser(); 1653 csvFileParser.Parse(fileName); 1652 1654 1653 1655 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);1656 dataset.Name = Path.GetFileName(fileName);1657 1654 1658 TradingProblemData problemData = new TradingProblemData(dataset, dataset.VariableNames.Skip(1), dataset.VariableNames.First()); 1659 problemData.Name = "Data imported from " + Path.GetFileName(fileName); 1660 return problemData; 1661 } 1662 #endregion 1655 //#region Import from file 1656 //public static TradingProblemData ImportFromFile(string fileName) { 1657 // TableFileParser csvFileParser = new TableFileParser(); 1658 // csvFileParser.Parse(fileName); 1659 1660 // Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 1661 // dataset.Name = Path.GetFileName(fileName); 1662 1663 // TradingProblemData problemData = new TradingProblemData(dataset, dataset.VariableNames.Skip(1), dataset.VariableNames.First()); 1664 // problemData.Name = "Data imported from " + Path.GetFileName(fileName); 1665 // return problemData; 1666 //} 1667 //#endregion 1663 1668 } 1664 1669 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/TradingSolution.cs
r6937 r9176 36 36 private const string TrainingSharpeRatioResultName = "Sharpe ratio (training)"; 37 37 private const string TestSharpeRatioResultName = "Sharpe ratio (test)"; 38 private const string TrainingProfitResultName = "Profit (training)"; 39 private const string TestProfitResultName = "Profit (test)"; 38 40 39 41 public new ITradingModel Model { … … 56 58 private set { ((DoubleValue)this[TestSharpeRatioResultName].Value).Value = value; } 57 59 } 60 public double TrainingProfit { 61 get { return ((DoubleValue)this[TrainingProfitResultName].Value).Value; } 62 private set { ((DoubleValue)this[TrainingProfitResultName].Value).Value = value; } 63 } 64 65 public double TestProfit { 66 get { return ((DoubleValue)this[TestProfitResultName].Value).Value; } 67 private set { ((DoubleValue)this[TestProfitResultName].Value).Value = value; } 68 } 58 69 59 70 [StorableConstructor] … … 66 77 Add(new Result(TrainingSharpeRatioResultName, "Share ratio of the signals of the model on the training partition", new DoubleValue())); 67 78 Add(new Result(TestSharpeRatioResultName, "Sharpe ratio of the signals of the model on the test partition", new DoubleValue())); 79 Add(new Result(TrainingProfitResultName, "Profit of the model on the training partition", new DoubleValue())); 80 Add(new Result(TestProfitResultName, "Profit of the model on the test partition", new DoubleValue())); 68 81 69 82 RecalculateResults(); 70 83 } 71 84 72 protected override void OnProblemDataChanged(EventArgs e) { 73 base.OnProblemDataChanged(e); 85 86 protected override void OnModelChanged() { 87 base.OnModelChanged(); 74 88 RecalculateResults(); 75 89 } 76 protected override void OnModelChanged(EventArgs e) { 77 base.OnModelChanged(e); 90 91 protected override void OnProblemDataChanged() { 92 base.OnProblemDataChanged(); 78 93 RecalculateResults(); 79 94 } … … 81 96 protected override void RecalculateResults() { 82 97 double[] trainingSignals = TrainingSignals.ToArray(); // cache values 83 IEnumerable<double> trainingReturns = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.PriceVariable, ProblemData.TrainingIndizes);98 IEnumerable<double> trainingReturns = ProblemData.Dataset.GetDoubleValues(ProblemData.PriceVariable, ProblemData.TrainingIndices); 84 99 double[] testSignals = TestSignals.ToArray(); // cache values 85 IEnumerable<double> testReturns = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.PriceVariable, ProblemData.TestIndizes);86 100 IEnumerable<double> testReturns = ProblemData.Dataset.GetDoubleValues(ProblemData.PriceVariable, ProblemData.TestIndices); 101 87 102 OnlineCalculatorError errorState; 88 103 double trainingSharpeRatio = OnlineSharpeRatioCalculator.Calculate(trainingReturns, trainingSignals, ProblemData.TransactionCosts, out errorState); … … 90 105 double testSharpeRatio = OnlineSharpeRatioCalculator.Calculate(testReturns, testSignals, ProblemData.TransactionCosts, out errorState); 91 106 TestSharpeRatio = errorState == OnlineCalculatorError.None ? testSharpeRatio : double.NaN; 107 108 double trainingProfit = OnlineProfitCalculator.Calculate(trainingReturns, trainingSignals, ProblemData.TransactionCosts, out errorState); 109 TrainingProfit = errorState == OnlineCalculatorError.None ? trainingProfit : double.NaN; 110 double testProfit = OnlineProfitCalculator.Calculate(testReturns, testSignals, ProblemData.TransactionCosts, out errorState); 111 TestProfit = errorState == OnlineCalculatorError.None ? testProfit : double.NaN; 92 112 93 113 } … … 101 121 public virtual IEnumerable<double> TrainingSignals { 102 122 get { 103 return GetSignals(ProblemData.TrainingIndi zes);123 return GetSignals(ProblemData.TrainingIndices); 104 124 } 105 125 } … … 107 127 public virtual IEnumerable<double> TestSignals { 108 128 get { 109 return GetSignals(ProblemData.TestIndi zes);129 return GetSignals(ProblemData.TestIndices); 110 130 } 111 131 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionLineChartView.cs
r6861 r9176 33 33 [View("Line Chart")] 34 34 [Content(typeof(ITradingSolution))] 35 public partial class TradingSolutionLineChartView : ItemView, ITradingSolutionEvaluationView {35 public partial class TradingSolutionLineChartView : DataAnalysisSolutionEvaluationView, ITradingSolutionEvaluationView { 36 36 private const string PRICEVARIABLE_SERIES_NAME = "Price"; 37 37 private const string SIGNALS_SERIES_NAME = "Signals"; 38 38 private const string ASSET_SERIES_NAME = "Asset"; 39 39 40 40 41 public new ITradingSolution Content { … … 72 73 this.chart.Series[SIGNALS_SERIES_NAME].Tag = Content; 73 74 74 IEnumerable<double> accumulatedPrice = GetAccumulatedPrices(Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.PriceVariable));75 IEnumerable<double> accumulatedPrice = GetAccumulatedPrices(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceVariable)); 75 76 this.chart.Series.Add(PRICEVARIABLE_SERIES_NAME); 76 77 this.chart.Series[PRICEVARIABLE_SERIES_NAME].LegendText = PRICEVARIABLE_SERIES_NAME; … … 79 80 this.chart.Series[PRICEVARIABLE_SERIES_NAME].Tag = Content; 80 81 81 IEnumerable<double> profit = GetProfits(Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.PriceVariable), Content.Signals, Content.ProblemData.TransactionCosts);82 IEnumerable<double> profit = GetProfits(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceVariable), Content.Signals, Content.ProblemData.TransactionCosts); 82 83 IEnumerable<double> accumulatedProfits = GetAccumulatedPrices(profit); 83 84 this.chart.Series.Add(ASSET_SERIES_NAME); … … 94 95 95 96 private IEnumerable<double> GetProfits(IEnumerable<double> returns, IEnumerable<double> signals, double transactionCost) { 96 double p =signals.First();97 int p = (int)signals.First(); 97 98 yield return 0.0; 98 99 foreach (var signalReturn in returns.Skip(1).Zip(signals.Skip(1), (r, s) => new { Return = r, Signal = s })) { … … 118 119 iterationReturn = -actualReturn; 119 120 } else if (p == -1 && signal.IsAlmost(0)) { 120 iterationReturn = - (actualReturn - transactionCost);121 iterationReturn = -actualReturn - transactionCost; 121 122 p = 0; 122 123 } else if (p == -1 && signal.IsAlmost(1)) { 123 iterationReturn = - (actualReturn - transactionCost);124 iterationReturn = -actualReturn - transactionCost; 124 125 p = 1; 125 126 } -
branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Views/TradingSolutionView.cs
r6123 r9176 34 34 var regressionSolutionEvaluationViewTypes = ApplicationManager.Manager.GetTypes(typeof(ITradingSolutionEvaluationView), true); 35 35 foreach (Type viewType in regressionSolutionEvaluationViewTypes) 36 AddViewListViewItem(viewType );36 AddViewListViewItem(viewType, HeuristicLab.Common.Resources.VSImageLibrary.Graph); 37 37 } 38 38 -
branches/HeuristicLab.Problems.DataAnalysis.Trading/Main/Main.csproj
r6127 r9176 44 44 </ItemGroup> 45 45 <ItemGroup> 46 <None Include="CopyAssemblies.cmd" />47 46 <None Include="CustomPostBuild.cmd" /> 48 47 </ItemGroup> -
branches/HeuristicLab.Problems.DataAnalysis.Trading/PreBuildEvent.cmd
r6127 r9176 1 SubWCRev "%ProjectDir%\" "%ProjectDir%\Properties\AssemblyInfo.frame" "%ProjectDir%\Properties\AssemblyInfo.cs" 1 IF EXIST "%ProjectDir%\Properties\AssemblyInfo.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Properties\AssemblyInfo.cs.frame" "%ProjectDir%\Properties\AssemblyInfo.cs" 2 IF EXIST "%ProjectDir%\Plugin.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Plugin.cs.frame" "%ProjectDir%\Plugin.cs"
Note: See TracChangeset
for help on using the changeset viewer.