quantproject-developers Mailing List for QuantProject (Page 10)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:58
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Optimizing In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5262/Optimizing Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Optimizing added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:48
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5234/Eligibles Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Eligibles added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:38
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5192/a2_Strategies Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:29
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5137/b4_Business Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:11
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b3_data/Selectors In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5035/Selectors Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b3_data/Selectors added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:28:02
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b3_data In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4946/b3_data Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b3_data added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:27:37
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/LinearAlgebra In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4874/LinearAlgebra Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/LinearAlgebra added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:27:29
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/Econometrics In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4846/Econometrics Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/Econometrics added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:27:14
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/a5_FakeImplementations In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4794/a5_FakeImplementations Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/a5_FakeImplementations added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:26:37
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4694/b1_ADT Modified Files: Sum.cs Log Message: An assertion that was faulty on purpose, has been commented out Index: Sum.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/Sum.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Sum.cs 31 Jan 2010 19:14:58 -0000 1.2 --- Sum.cs 28 Mar 2010 16:26:30 -0000 1.3 *************** *** 3,7 **** Sum.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- Sum.cs ! Copyright (C) 2010 Glauco Siliprandi *************** *** 26,30 **** using QuantProject.ADT.Statistics; ! namespace QuantProject.Testing.Statistics { /// <summary> --- 26,30 ---- using QuantProject.ADT.Statistics; ! namespace QuantTesting.ADT.Statistics { /// <summary> *************** *** 42,46 **** Assert.AreEqual( 3 , sumValue ); // this is ok // comment out the following statemente if you want to get a successfull test ! Assert.AreEqual( 3.1 , sumValue ); // this one faults } } --- 42,46 ---- Assert.AreEqual( 3 , sumValue ); // this is ok // comment out the following statemente if you want to get a successfull test ! // Assert.AreEqual( 3.1 , sumValue ); // this one faults } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:24:53
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4380 Modified Files: QPTesting.sln Log Message: The project "QPTesting" has been renamed to "t5_QPTesting" The project "ADT_SD" has been renamed to "b1_ADT" The project "b2_DataAccess", "..\b2_DataAccess\DataAccess_SD.csproj" has been added The project "b3_Data", "..\b3_Data\Data_SD.csproj" has been added The project "b4_Business", "..\b4_Business\Business_SD.csproj" has been added The project "b5_Presentation", "..\b5_Presentation\Presentation_SD.csproj" has been added The project "b7_Scripts", "..\b7_Scripts\Scripts_SD.csproj" has been added Index: QPTesting.sln =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/QPTesting.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QPTesting.sln 31 Jan 2010 18:57:44 -0000 1.1 --- QPTesting.sln 28 Mar 2010 16:24:45 -0000 1.2 *************** *** 3,9 **** # Visual Studio 2005 # SharpDevelop 2.2.1.2648 ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QPTesting", "QPTesting.csproj", "{B0673E30-FD99-465C-AE62-B703EC7BF847}" EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ADT_SD", "..\b1_ADT\ADT_SD.csproj", "{6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}" EndProject Global --- 3,19 ---- # Visual Studio 2005 # SharpDevelop 2.2.1.2648 ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "t5_QPTesting", "QPTesting.csproj", "{B0673E30-FD99-465C-AE62-B703EC7BF847}" EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b1_ADT", "..\b1_ADT\ADT_SD.csproj", "{6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}" ! EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b4_Business", "..\b4_Business\Business_SD.csproj", "{91CAD8B7-D505-40BE-8FAF-0597E62FF71D}" ! EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b2_DataAccess", "..\b2_DataAccess\DataAccess_SD.csproj", "{3D38C64D-1118-4C16-A88E-5F2FFD6481BA}" ! EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b3_Data", "..\b3_Data\Data_SD.csproj", "{1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}" ! EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b5_Presentation", "..\b5_Presentation\Presentation_SD.csproj", "{E05282BB-A762-4205-B420-812CECB48E5C}" ! EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b7_Scripts", "..\b7_Scripts\Scripts_SD.csproj", "{B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}" EndProject Global *************** *** 21,24 **** --- 31,54 ---- {6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}.Release|Any CPU.Build.0 = Release|Any CPU {6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91CAD8B7-D505-40BE-8FAF-0597E62FF71D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91CAD8B7-D505-40BE-8FAF-0597E62FF71D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91CAD8B7-D505-40BE-8FAF-0597E62FF71D}.Release|Any CPU.Build.0 = Release|Any CPU + {91CAD8B7-D505-40BE-8FAF-0597E62FF71D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D38C64D-1118-4C16-A88E-5F2FFD6481BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D38C64D-1118-4C16-A88E-5F2FFD6481BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D38C64D-1118-4C16-A88E-5F2FFD6481BA}.Release|Any CPU.Build.0 = Release|Any CPU + {3D38C64D-1118-4C16-A88E-5F2FFD6481BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}.Release|Any CPU.Build.0 = Release|Any CPU + {1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E05282BB-A762-4205-B420-812CECB48E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E05282BB-A762-4205-B420-812CECB48E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E05282BB-A762-4205-B420-812CECB48E5C}.Release|Any CPU.Build.0 = Release|Any CPU + {E05282BB-A762-4205-B420-812CECB48E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}.Release|Any CPU.Build.0 = Release|Any CPU + {B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:20:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv3253 Modified Files: Scripts_SD.csproj Log Message: General\Logging\AnalyzableLogItem.cs has been added WalkForwardTesting\LinearRegression\eligibles\EligiblesSelectorForLinearRegression.cs has been added WalkForwardTesting\LinearRegression\EntryStrategies\IEntryStrategy.cs has been added WalkForwardTesting\LinearRegression\EntryStrategies\EntryStrategyBasedOnForecastedReturn.cs has been added WalkForwardTesting\LinearRegression\ExitStrategies\ExitOnIntervalEnd.cs has been added WalkForwardTesting\LinearRegression\ExitStrategies\IExitStrategy.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\Decoding\DecoderFirstTradingTickerInEachSignalingPortfolio.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\Decoding\DecoderForLinearRegressionTestingPositions.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionFitnessEvaluator.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionSetupManager.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionValues.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionFitnessEvaluator.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionSetUpManager.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionValues.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ReturnIntervalsBuilderForTradingAndForSignaling.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\Genetic\GenomeManagerForLinearRegression.cs has been added WalkForwardTesting\LinearRegression\InSampleChoosers\Genetic\LinearRegressionGeneticChooser.cs has been added WalkForwardTesting\LinearRegression\LinearRegressionMain.cs has been added WalkForwardTesting\LinearRegression\LinearRegressionTestingPositions.cs has been added WalkForwardTesting\LinearRegression\Logging\AnalyzerForLinearRegressionTestingPositions.cs has been added WalkForwardTesting\LinearRegression\Logging\LinearRegressionLogItem.cs has been added WalkForwardTesting\LinearRegression\ReturnIntervals\ShiftedTimeIntervalSelectorForSignaling.cs has been added WalkForwardTesting\LinearRegression\ReturnIntervals\SingleDayIntervalsSelector.cs has been added WalkForwardTesting\LinearRegression\Strategies\LinearRegressionStrategy.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Scripts_SD.csproj 30 Oct 2009 23:13:43 -0000 1.42 --- Scripts_SD.csproj 28 Mar 2010 16:19:56 -0000 1.43 *************** *** 50,53 **** --- 50,54 ---- <Compile Include="EvaluatingOptimizationTechnique\TechnicalAnalysis\RunTestingOptimizationExtremeCounterTrend.cs" /> <Compile Include="General\BasicScriptForBacktesting.cs" /> + <Compile Include="General\Logging\AnalyzableLogItem.cs" /> <Compile Include="General\Logging\LogArchiver.cs" /> <Compile Include="General\Logging\LogViewer.cs" /> *************** *** 144,147 **** --- 145,171 ---- <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\Logging\TesterForFLTPTestingPositions.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\OutOfSampleChoosers\RankBasedOutOfSampleChooser.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\eligibles\EligiblesSelectorForLinearRegression.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\EntryStrategies\IEntryStrategy.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\EntryStrategies\EntryStrategyBasedOnForecastedReturn.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\ExitStrategies\ExitOnIntervalEnd.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\ExitStrategies\IExitStrategy.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Decoding\DecoderFirstTradingTickerInEachSignalingPortfolio.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Decoding\DecoderForLinearRegressionTestingPositions.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionFitnessEvaluator.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionSetupManager.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ILinearRegressionValues.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionFitnessEvaluator.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionSetUpManager.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\LinearRegressionValues.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation\ReturnIntervalsBuilderForTradingAndForSignaling.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Genetic\GenomeManagerForLinearRegression.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Genetic\LinearRegressionGeneticChooser.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\LinearRegressionMain.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\LinearRegressionTestingPositions.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\Logging\AnalyzerForLinearRegressionTestingPositions.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\Logging\LinearRegressionLogItem.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\ReturnIntervals\ShiftedTimeIntervalSelectorForSignaling.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\ReturnIntervals\SingleDayIntervalsSelector.cs" /> + <Compile Include="WalkForwardTesting\LinearRegression\Strategies\LinearRegressionStrategy.cs" /> <Compile Include="WalkForwardTesting\MSFTwalkForward\TsMSFTwalkForward.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\ExitStrategies\TakeProfitStrategyOrOnMarketClose.cs" /> *************** *** 345,348 **** --- 369,383 ---- <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\Logging" /> <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\OutOfSampleChoosers" /> + <Folder Include="WalkForwardTesting\LinearRegression" /> + <Folder Include="WalkForwardTesting\LinearRegression\InSampleChoosers" /> + <Folder Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Decoding" /> + <Folder Include="WalkForwardTesting\LinearRegression\InSampleChoosers\Genetic" /> + <Folder Include="WalkForwardTesting\LinearRegression\eligibles" /> + <Folder Include="WalkForwardTesting\LinearRegression\EntryStrategies" /> + <Folder Include="WalkForwardTesting\LinearRegression\ExitStrategies" /> + <Folder Include="WalkForwardTesting\LinearRegression\InSampleChoosers\FitnessEvaluation" /> + <Folder Include="WalkForwardTesting\LinearRegression\Logging" /> + <Folder Include="WalkForwardTesting\LinearRegression\ReturnIntervals" /> + <Folder Include="WalkForwardTesting\LinearRegression\Strategies" /> <Folder Include="WalkForwardTesting\PairsTrading" /> <Folder Include="WalkForwardTesting\PairsTrading\InSample" /> |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:17:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv1963/WalkForwardTesting/LinearRegression/Strategies Added Files: LinearRegressionStrategy.cs Log Message: Builds a model for prediction of a WeightedPositions return on the next return interval --- NEW FILE: LinearRegressionStrategy.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionStrategy.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Builds a model for prediction of a WeightedPositions return on the next /// return interval /// </summary> [Serializable] public class LinearRegressionStrategy : BasicStrategyForBacktester { private IEntryStrategy entryStrategy; private IExitStrategy exitStrategy; public LinearRegressionStrategy( int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , IIntervalsSelector intervalsSelectorForInSample , IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelectorForTradingTickers , // IEligiblesSelector eligiblesSelectorForSignalingTickers , IInSampleChooser inSampleChooser , HistoricalMarketValueProvider historicalMarketValueProviderForInSample , HistoricalMarketValueProvider historicalMarketValueProviderForChosingPositionsOutOfSample , IEntryStrategy entryStrategy , // OutOfSampleChooser outOfSampleChooser , IExitStrategy exitStrategy ) : base( numDaysBeetweenEachOtpimization , numDaysForInSampleOptimization , intervalsSelectorForInSample , intervalsSelectorForOutOfSample , eligiblesSelectorForTradingTickers , inSampleChooser , historicalMarketValueProviderForInSample ) { this.intervalsSelectorForOutOfSample = intervalsSelectorForOutOfSample; this.entryStrategy = entryStrategy; this.exitStrategy = exitStrategy; } protected override string getTextIdentifier() { return "lnrRgrssn"; } protected override LogItem getLogItem( EligibleTickers eligibleTickers ) { LinearRegressionLogItem logItem = new LinearRegressionLogItem( this.now() , this.bestTestingPositionsInSample ); // this.numDaysForInSampleOptimization , // eligibleTickers.Count ); return logItem; } protected override bool arePositionsToBeClosed() { bool areToBeClosed = ( this.Account.Portfolio.Count > 0 ); areToBeClosed = ( areToBeClosed && this.exitStrategy.ArePositionsToBeClosed( this.now() , this.outOfSampleReturnIntervals ) ); // ( this.time() == this.timeToClosePositions ) ); return ( areToBeClosed ); } protected override bool arePositionsToBeOpened() { bool areToBeOpened = false; if ( this.outOfSampleReturnIntervals.Count >= 1 && this.bestTestingPositionsInSample != null ) { // ReturnInterval seconLastInterval = // this.outOfSampleReturnIntervals.SeconLastInterval; // areToBeOpened = ( this.now() == seconLastInterval.Begin ); ReturnInterval lastOutOfSampleInterval = this.outOfSampleReturnIntervals.LastInterval; areToBeOpened = ( this.now() == lastOutOfSampleInterval.Begin ); } return areToBeOpened; } protected override WeightedPositions getPositionsToBeOpened() { // DateTime currentDateTime = this.now(); // WeightedPositions weightedPositions = // this.outOfSampleChooser.GetPositionsToBeOpened( // this.bestTestingPositionsInSample , //// firstDateTimeToTestInefficiency , // currentDateTime , //// dateTimeToClosePositions , // this.historicalMarketValueProviderForChosingPositionsOutOfSample , // this.inSampleReturnsManager ); WeightedPositions weightedPositions = this.entryStrategy.GetPositionsToBeOpened( this.bestTestingPositionsInSample , this.outOfSampleReturnIntervals ); return weightedPositions; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:16:18
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ReturnIntervals In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv1766/WalkForwardTesting/LinearRegression/ReturnIntervals Added Files: SingleDayIntervalsSelector.cs Log Message: Returns an interval only if the benchmark has values both at the interval begin and at the interval end. The interval must be one day long. Then, for instance, thursday market close to friday market close is returned, but friday market close to monday marked close is not returned, because three days elapse since friday market close to monday market close --- NEW FILE: SingleDayIntervalsSelector.cs --- /* QuantProject - Quantitative Finance Library SingleDayCloseToCloseIntervalsSelector.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using QuantProject.ADT.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Returns an interval only if the benchmark has values /// both at the interval begin and at the interval end. /// The interval must be one day long. Then, for instance, /// thursday market close to friday market close is returned, but /// friday market close to monday marked close is not returned, because /// three days elapse since friday market close to monday market close /// </summary> [Serializable] public class SingleDayIntervalsSelector : IIntervalsSelector { private Benchmark benchmark; private Time dailyTime; private List<DayOfWeek> acceptableDaysOfTheWeekForTheEndOfEachInterval; private TimeSpan maxTimeSpanToLookAhead; /// <summary> /// Returns an interval only if the benchmark has values /// both at the interval begin and at the interval end. /// The interval must be one day long. Then, for instance, /// thursday market close to friday market close is returned, but /// friday market close to monday marked close is not returned, because /// three days elapse since friday market close to monday market close /// </summary> /// <param name="benchmark"></param> /// <param name="dailyTime">each interval will go from /// this time for one day to this same time for the next day</param> /// <param name="acceptableDaysOfTheWeekForTheEndOfEachInterval">an interval /// is returned only if the day of the week on which the interval ends /// is in this list</param> /// <param name="maxTimeSpanToLookAhead">if a new interval is not found /// before maxTimeSpanToLookAhead has elapsed, then stop searching for /// the next interval</param> public SingleDayIntervalsSelector( Benchmark benchmark , Time dailyTime , List<DayOfWeek> acceptableDaysOfTheWeekForTheEndOfEachInterval , TimeSpan maxTimeSpanToLookAhead ) { this.benchmark = benchmark; this.dailyTime = dailyTime; this.acceptableDaysOfTheWeekForTheEndOfEachInterval = acceptableDaysOfTheWeekForTheEndOfEachInterval; this.maxTimeSpanToLookAhead = maxTimeSpanToLookAhead; } private bool isValidReturnInterval( ReturnInterval returnInterval ) { TimeSpan intervalLength = returnInterval.End.Subtract( returnInterval.Begin ); TimeSpan requiredIntervalLength = TimeSpan.FromDays( 1 ); bool isValidReturnInterval = ( intervalLength == requiredIntervalLength ); isValidReturnInterval &= this.acceptableDaysOfTheWeekForTheEndOfEachInterval.Contains( returnInterval.End.DayOfWeek ); return isValidReturnInterval; } #region GetFirstInterval #region getReturnIntervalCandidate private DateTime getFirstIntervalBegin( DateTime startingDateTime , DateTime lastAcceptableDateTime ) { DateTime firstIntervalBegin = this.benchmark.GetThisOrNextDateTimeWhenTraded( startingDateTime , this.dailyTime , lastAcceptableDateTime ); return firstIntervalBegin; } private DateTime getIntervalEnd( DateTime startingDateTime , DateTime lastAcceptableDateTime ) { DateTime intervalEnd = this.benchmark.GetThisOrNextDateTimeWhenTraded( startingDateTime.AddMinutes( 1 ) , this.dailyTime , lastAcceptableDateTime ); return intervalEnd; } private ReturnInterval getReturnIntervalCandidate( DateTime startingDateTime , DateTime lastAcceptableDateTime ) { ReturnInterval intervalCandidate = null; DateTime intervalCandidateBegin = this.getFirstIntervalBegin( startingDateTime , lastAcceptableDateTime ); DateTime intervalCandidateEnd = DateTime.MinValue; if ( intervalCandidateBegin != DateTime.MinValue ) // a potentially valid first interval begin has been found intervalCandidateEnd = this.getIntervalEnd( intervalCandidateBegin , lastAcceptableDateTime ); if ( ( intervalCandidateBegin != DateTime.MinValue ) && ( intervalCandidateEnd != DateTime.MinValue ) ) // a potentially valida return interval has been found intervalCandidate = new ReturnInterval( intervalCandidateBegin , intervalCandidateEnd ); return intervalCandidate; } #endregion getReturnIntervalCandidate public ReturnInterval GetFirstInterval( DateTime startingDateTime ) { DateTime lastAcceptableDateTime = startingDateTime.Add( this.maxTimeSpanToLookAhead ); ReturnInterval returnIntervalCandidate = this.getReturnIntervalCandidate( startingDateTime , lastAcceptableDateTime ); while ( ( returnIntervalCandidate != null ) && !this.isValidReturnInterval( returnIntervalCandidate ) && ( returnIntervalCandidate.End < lastAcceptableDateTime ) ) returnIntervalCandidate = this.getReturnIntervalCandidate( returnIntervalCandidate.End , lastAcceptableDateTime ); return returnIntervalCandidate; } #endregion GetFirstInterval public ReturnInterval GetNextInterval( ReturnIntervals returnIntervals ) { DateTime firstAcceptableDateTimeForNextInterval = returnIntervals.LastDateTime; ReturnInterval nextInterval = this.GetFirstInterval( firstAcceptableDateTimeForNextInterval ); return nextInterval; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:15:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ReturnIntervals In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv1250/WalkForwardTesting/LinearRegression/ReturnIntervals Added Files: ShiftedTimeIntervalSelectorForSignaling.cs Log Message: Given a trading ReturnInterval, builds a signaling ReturnInterval that is shifted the given time span --- NEW FILE: ShiftedTimeIntervalSelectorForSignaling.cs --- /* QuantProject - Quantitative Finance Library ShiftedTimeIntervalSelectorForSignaling.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Description of ShiftedTimeIntervalSelectorForSignaling. /// </summary> [Serializable] public class ShiftedTimeIntervalSelectorForSignaling : IReturnIntervalSelectorForSignaling { TimeSpan timeSpanToBeShifted; /// <summary> /// Given a trading ReturnInterval, builds a signaling ReturnInterval /// that is shifted the given time span /// </summary> /// <param name="timeSpanToBeShifted">time span used to build the /// signaling ReturnInterval; use a negative value in order to build /// a signaling ReturnInterval that is before the trading /// ReturnInterval</param> public ShiftedTimeIntervalSelectorForSignaling( TimeSpan timeSpanToBeShifted ) { this.timeSpanToBeShifted = timeSpanToBeShifted; } public ReturnInterval GetReturnIntervalUsedForSignaling( ReturnInterval returnIntervalForTrading ) { DateTime signalingReturnIntervalBegin = returnIntervalForTrading.Begin.Add( this.timeSpanToBeShifted ); DateTime signalingReturnIntervalEnd = returnIntervalForTrading.End.Add( this.timeSpanToBeShifted ); ReturnInterval returnIntervalUsedForSignaling = new ReturnInterval( signalingReturnIntervalBegin , signalingReturnIntervalEnd ); return returnIntervalUsedForSignaling; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:13:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv414/WalkForwardTesting/LinearRegression/Logging Added Files: LinearRegressionLogItem.cs Log Message: Log item for the linear regression strategy --- NEW FILE: LinearRegressionLogItem.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionLogItem.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Presentation; using QuantProject.Scripts.General.Logging; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Log item for the linear regression strategy /// </summary> [Serializable] public class LinearRegressionLogItem : AnalyzableLogItem { // private LinearRegressionTestingPositions[] bestTestingPositionsInSample; public LinearRegressionLogItem( DateTime now , TestingPositions[] bestTestingPositionsInSample ) : base( now , bestTestingPositionsInSample ) { // this.bestTestingPositionsInSample = bestTestingPositionsInSample; } #region getAnalyzerForTestingPositions private void getAnalyzerForTestingPositions_checkParameters( TestingPositions testingPositions ) { if ( ! ( testingPositions is LinearRegressionTestingPositions ) ) throw new Exception( "TestingPositions here is expected to be " + "LinearRegressionTestingPositions. But the current TestingPositions " + "is not a LinearRegressionTestingPositions!" ); } protected override IExecutable getAnalyzerForTestingPositions( DateTime now , TestingPositions testingPositionsInSample ) { this.getAnalyzerForTestingPositions_checkParameters( testingPositionsInSample ); AnalyzerForLinearRegressionTestingPositions analyzerForLinearRegressionTestingPositions = new AnalyzerForLinearRegressionTestingPositions( (LinearRegressionTestingPositions)testingPositionsInSample , now ); return analyzerForLinearRegressionTestingPositions; } #endregion getAnalyzerForTestingPositions // public override void Run() // { // QuantProject.Presentation.ExecutablesListViewer executablesListViewer = // new ExecutablesListViewer( // this.analyzersForBestTestingPositionsInSample ); // executablesListViewer.Show(); // } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:12:54
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv346/WalkForwardTesting/LinearRegression/Logging Added Files: AnalyzerForLinearRegressionTestingPositions.cs Log Message: Analyzes a LinearRegressionTestingPositions that has been logged in sample --- NEW FILE: AnalyzerForLinearRegressionTestingPositions.cs --- /* QuantProject - Quantitative Finance Library AnalyzerForLinearRegressionTestingPositions.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Scripting; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Analyzes a LinearRegressionTestingPositions that has been /// logged in sample /// </summary> [Serializable] public class AnalyzerForLinearRegressionTestingPositions : IExecutable { LinearRegressionTestingPositions linearRegressionTestingPositions; DateTime accountTimerDateTimeWhenThisObjectWasLogged; public AnalyzerForLinearRegressionTestingPositions( LinearRegressionTestingPositions linearRegressionTestingPositions , // int numberOfInSampleDays , DateTime accountTimerDateTimeWhenThisObjectWasLogged ) { this.linearRegressionTestingPositions = linearRegressionTestingPositions; this.accountTimerDateTimeWhenThisObjectWasLogged = accountTimerDateTimeWhenThisObjectWasLogged; } public void Run() { // an idea would be to show some t-statistics for the // coefficients and then show which are those who seem to // be more significant System.Windows.Forms.MessageBox.Show( "A good analyzer has not yet been thought about, for " + "a LinearRegressionTestingPositions" ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:12:33
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv32643/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic Added Files: LinearRegressionGeneticChooser.cs Log Message: enetic IInSampleChooser for the linear regression strategy --- NEW FILE: LinearRegressionGeneticChooser.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionGeneticChooser.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// genetic IInSampleChooser for the linear regression strategy /// </summary> [Serializable] public class LinearRegressionGeneticChooser : GeneticChooser { private DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions; private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; private IReturnIntervalsBuilderForTradingAndForSignaling returnIntervalsBuilderForTradingAndForSignaling; private IEligiblesSelector eligiblesSelectorForSignalingTickers; private int seedForRandomGeneratorForGenomeManagerForTradingTickers; private int seedForRandomGeneratorForGenomeManagerForSignalingTickers; public LinearRegressionGeneticChooser( int numberOfBestTestingPositionsToBeReturned , Benchmark benchmark , DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions , IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , IReturnIntervalsBuilderForTradingAndForSignaling returnIntervalsBuilderForTradingAndForSignaling , IFitnessEvaluator fitnessEvaluator , HistoricalMarketValueProvider historicalMarketValueProvider , IEligiblesSelector eligiblesSelectorForSignalingTickers , double crossoverRate , double mutationRate , double elitismRate , int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , int seedForRandomGeneratorForTheGeneticOptimizer , int seedForRandomGeneratorForGenomeManagerForTradingTickers , int seedForRandomGeneratorForGenomeManagerForSignalingTickers ) : base( 2 , numberOfBestTestingPositionsToBeReturned , benchmark , new DummyDecoderForTestingPositions() , fitnessEvaluator , historicalMarketValueProvider , crossoverRate , mutationRate , elitismRate , populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , seedForRandomGeneratorForTheGeneticOptimizer ) { this.decoderForLinearRegressionTestingPositions = decoderForLinearRegressionTestingPositions; this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; this.returnIntervalsBuilderForTradingAndForSignaling = returnIntervalsBuilderForTradingAndForSignaling; this.eligiblesSelectorForSignalingTickers = eligiblesSelectorForSignalingTickers; this.seedForRandomGeneratorForGenomeManagerForTradingTickers = seedForRandomGeneratorForGenomeManagerForTradingTickers; this.seedForRandomGeneratorForGenomeManagerForSignalingTickers = seedForRandomGeneratorForGenomeManagerForSignalingTickers; } #region GetGenomeManager public override IGenomeManager GetGenomeManager( EligibleTickers eligibleTickersForTrading , ReturnsManager returnsManager ) { // IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling = // new ShiftedTimeIntervalSelectorForSignaling( new TimeSpan( -24 , 0 , 0 ) ); EligibleTickers eligibleTickersForSignaling = this.eligiblesSelectorForSignalingTickers.GetEligibleTickers( returnsManager.ReturnIntervals.BordersHistory ); ReturnIntervals returnIntervalsForTrading; ReturnIntervals returnIntervalsForSignaling; this.returnIntervalsBuilderForTradingAndForSignaling.BuildIntervals( returnsManager , this.returnIntervalSelectorForSignaling , eligibleTickersForTrading.Tickers , eligibleTickersForSignaling.Tickers , out returnIntervalsForTrading , out returnIntervalsForSignaling ); ReturnsManager returnsManagerForTradingTickers = new ReturnsManager( returnIntervalsForTrading , this.historicalMarketValueProvider ); ReturnsManager returnsManagerForSignalingTickers = new ReturnsManager( returnIntervalsForSignaling , this.historicalMarketValueProvider ); GenomeManagerForLinearRegression genomeManagerForLinearRegression = new GenomeManagerForLinearRegression( eligibleTickersForTrading , eligibleTickersForSignaling , // returnsManager , returnsManagerForTradingTickers , returnsManagerForSignalingTickers , this.decoderForLinearRegressionTestingPositions , this.fitnessEvaluator , GenomeManagerType.ShortAndLong , this.seedForRandomGeneratorForGenomeManagerForTradingTickers , this.seedForRandomGeneratorForGenomeManagerForSignalingTickers ); return genomeManagerForLinearRegression; } #endregion GetGenomeManager protected override string getHashCodeForGenome( Genome genome ) { return ((TestingPositions)(genome.Meaning)).HashCodeForTickerComposition; } public override object AnalyzeInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { TestingPositions[] bestTestingPositionsInSample = (TestingPositions[])base.AnalyzeInSample( eligibleTickers , returnsManager ); foreach ( LinearRegressionTestingPositions linearRegressionTestingPositions in bestTestingPositionsInSample ) linearRegressionTestingPositions.LinearRegression = ((LinearRegressionFitnessEvaluator)this.fitnessEvaluator).SetUpAndRunLinearRegression( linearRegressionTestingPositions ); return bestTestingPositionsInSample; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:12:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv32529/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic Added Files: GenomeManagerForLinearRegression.cs Log Message: Decodes genes when two groups of eligibles are given --- NEW FILE: GenomeManagerForLinearRegression.cs --- /* QuantProject - Quantitative Finance Library GenomeManagerForLinearRegressionWithRatios.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Decodes genes when two groups of eligibles are given /// </summary> [Serializable] public class GenomeManagerForLinearRegression : GenomeManagerWithDuplicateGenes { private EligibleTickers eligibleTickersForTrading; private EligibleTickers eligibleTickersForSignaling; private IReturnsManager returnsManagerForTradingTickers; private IReturnsManager returnsManagerForSignalingTickers; private IGenomeManager genomeManagerForTradingTickers; private IGenomeManager genomeManagerForSignalingTickers; private DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions; public GenomeManagerForLinearRegression( EligibleTickers eligibleTickersForTrading , EligibleTickers eligibleTickersForSignaling , // ReturnsManager returnsManager , IReturnsManager returnsManagerForTradingTickers , IReturnsManager returnsManagerForSignalingTickers , DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions , IFitnessEvaluator fitnessEvaluator , GenomeManagerType genomeManagerType , int seedForRandomGeneratorForTradingTickers , int seedForRandomGeneratorForSignalingTickers ) : base( decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading , eligibleTickersForTrading , returnsManagerForTradingTickers , // this one should not be used new BasicDecoderForTestingPositions() , fitnessEvaluator , genomeManagerType , seedForRandomGeneratorForTradingTickers ) { this.eligibleTickersForTrading = eligibleTickersForTrading; this.eligibleTickersForSignaling = eligibleTickersForSignaling; this.returnsManagerForTradingTickers = returnsManagerForTradingTickers; this.returnsManagerForSignalingTickers = returnsManagerForSignalingTickers; ((LinearRegressionFitnessEvaluator)this.fitnessEvaluator).ReturnsManagerForTradingTickers = this.returnsManagerForTradingTickers; ((LinearRegressionFitnessEvaluator)this.fitnessEvaluator).ReturnsManagerForSignalingTickers = this.returnsManagerForSignalingTickers; this.genomeManagerForTradingTickers = new GenomeManagerWithDuplicateGenes( decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading , this.eligibleTickersForTrading , this.returnsManagerForTradingTickers , new BasicDecoderForTestingPositions() , fitnessEvaluator , GenomeManagerType.ShortAndLong , seedForRandomGeneratorForTradingTickers ); this.genomeManagerForSignalingTickers = new GenomeManagerWithDuplicateGenes( decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios , this.eligibleTickersForSignaling , this.returnsManagerForSignalingTickers , new BasicDecoderForTestingPositions() , fitnessEvaluator , GenomeManagerType.ShortAndLong , seedForRandomGeneratorForSignalingTickers ); this.decoderForLinearRegressionTestingPositions = new DecoderForLinearRegressionTestingPositions( // decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading , decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios ); this.genomeSize = decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading + decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios; } public override int GetMaxValueForGenes( int genePosition ) { int maxValueForGenes = 0; if ( genePosition < this.genomeManagerForTradingTickers.GenomeSize ) // genePosition referst to a tradable ticker maxValueForGenes = this.genomeManagerForTradingTickers.GetMaxValueForGenes( genePosition ); else { // genePosition referst to a signaling ticker int genePositionInTheSecondGroup = genePosition - this.genomeManagerForTradingTickers.GenomeSize; maxValueForGenes = this.genomeManagerForSignalingTickers.GetMaxValueForGenes( genePositionInTheSecondGroup ); } return maxValueForGenes; } public override int GetMinValueForGenes( int genePosition ) { int minValueForGenes = 0; if ( genePosition < this.genomeManagerForTradingTickers.GenomeSize ) // genePosition referst to a tradable ticker minValueForGenes = this.genomeManagerForTradingTickers.GetMinValueForGenes( genePosition ); else { // genePosition referst to a signaling ticker int genePositionInTheSecondGroup = genePosition - genomeManagerForTradingTickers.GenomeSize; minValueForGenes = this.genomeManagerForSignalingTickers.GetMinValueForGenes( genePositionInTheSecondGroup ); } return minValueForGenes; } // public override int GetNewGeneValue( Genome genome, int genePosition ) // { // double newGeneValue = 0; // if ( genePosition < genomeManagerForTradingTickers.GenomeSize ) // // genePosition referst to the first group of eligibles // minValueForGenes = genomeManagerForTradingTickers.GetNewGeneValue( // genePosition ); // else // { // // genePosition referst to the second group of eligibles // int genePositionInTheSecondGroup = genePosition - // genomeManagerForTradingTickers.GenomeSize; // minValueForGenes = genomeManagerForSignalingTickers.GetNewGeneValue( // genePositionInTheSecondGroup ); // // } // return minValueForGenes; // } /// <summary> /// Returns an array with two TestingPositions. The first element contains /// the decoding for the first group of eligibles, the second element contains /// the decoding for the second group of eligibles /// </summary> /// <param name="genome"></param> /// <returns></returns> public override object Decode(Genome genome) { object decoded = this.decoderForLinearRegressionTestingPositions.Decode( genome.Genes() , this.eligibleTickersForTrading , this.eligibleTickersForSignaling , this.returnsManagerForTradingTickers , this.returnsManagerForSignalingTickers ); // this.returnsManager ); return decoded; } // public virtual double GetFitnessValue(Genome genome) // { // double fitnessValue = // this.fitnessEvaluator.GetFitnessValue(genome.Meaning, this.returnsManager); // // return fitnessValue; // } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:11:31
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv32161/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: ReturnIntervalsBuilderForTradingAndForSignaling.cs Log Message: Builds (in sample) return intervals for trading and return intervals for signaling --- NEW FILE: ReturnIntervalsBuilderForTradingAndForSignaling.cs --- /* QuantProject - Quantitative Finance Library ReturnIntervalsBuilderForTradingAndForSignaling.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Builds (in sample) return intervals for trading and return intervals /// for signaling /// </summary> [Serializable] public class ReturnIntervalsBuilderForTradingAndForSignaling : IReturnIntervalsBuilderForTradingAndForSignaling { // private IReturnIntervalFilter returnIntervalFilterForTrading; // private IReturnIntervalFilter returnIntervalFilterForSignaling; public ReturnIntervalsBuilderForTradingAndForSignaling() // IReturnIntervalFilter returnIntervalFilterForTrading , // IReturnIntervalFilter returnIntervalFilterForSignaling ) { // this.returnIntervalFilterForTrading = returnIntervalFilterForTrading; // this.returnIntervalFilterForSignaling = returnIntervalFilterForSignaling; } #region BuildIntervals #region addReturnIntervalForTradingAndReturnIntervalForSignalingIfTheCase private bool wereAllTickersExchanged( string[] tickers , ReturnInterval returnInterval , IHistoricalMarketValueProvider historicalMarketValueProvider ) { bool wereAllExchanged = true; int tickerIndex = 0; while ( wereAllExchanged && ( tickerIndex < tickers.Length ) ) { string ticker = tickers[ tickerIndex ]; bool wasExchanged = ( historicalMarketValueProvider.WasExchanged( ticker , returnInterval.Begin ) && historicalMarketValueProvider.WasExchanged( ticker , returnInterval.End ) ); wereAllExchanged = wasExchanged; tickerIndex++; } return wereAllExchanged; } /// <summary> /// A return interval is added to returnIntervalsForTrading only if /// all eligibles for trading are traded on that interval, and the /// interval is a trading interval. /// A return interval is added to returnIntervalsForSignaling only if /// all eligibles for signaling are traded on that interval, and the /// interval is a signaling interval. /// </summary> /// <param name="returnInterval"></param> /// <param name="historicalMarketValueProvider"></param> /// <param name="eligibleTickersForTrading"></param> /// <param name="eligibleTickersForSignaling"></param> /// <param name="returnIntervalsForTrading"></param> /// <param name="returnIntervalsForSignaling"></param> private void addReturnIntervalForTradingAndReturnIntervalForSignalingIfTheCase( ReturnInterval returnIntervalCandidateForTrading , IHistoricalMarketValueProvider historicalMarketValueProvider , IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling , ReturnIntervals returnIntervalsForTrading , ReturnIntervals returnIntervalsForSignaling ) { ReturnInterval returnIntervalForSignaling = returnIntervalSelectorForSignaling.GetReturnIntervalUsedForSignaling( returnIntervalCandidateForTrading ); if ( this.wereAllTickersExchanged( eligibleTickersForTrading , returnIntervalCandidateForTrading , historicalMarketValueProvider ) && this.wereAllTickersExchanged( eligibleTickersForSignaling , returnIntervalForSignaling , historicalMarketValueProvider ) ) { // all eligible tickers for trading were exchanged in the current // return interval candidate for trading, and all eligible tickers // for signaling were exchanged in the current return interval candidate // for signaling returnIntervalsForTrading.Add( returnIntervalCandidateForTrading ); returnIntervalsForSignaling.Add( returnIntervalForSignaling ); } // bool wereAllEligibleTickersForTradingExchanged = // this.wereAllTickersExchanged( // eligibleTickersForTrading , // returnIntervalCandidateForTrading , historicalMarketValueProvider ); // bool isReturnIntervalValidForTrading = // this.returnIntervalFilterForTrading.IsValid( returnIntervalCandidateForTrading ); // bool isReturnIntervalToBeAddedToReturnIntervalsForTrading = ( // wereAllEligibleTickersForTradingExchanged && // isReturnIntervalValidForTrading ); // if ( isReturnIntervalToBeAddedToReturnIntervalsForTrading ) // returnIntervalsForTrading.Add( returnIntervalCandidateForTrading ); // // bool wereAllEligibleTickersForSignalingExchanged = // this.wereAllTickersExchanged( // eligibleTickersForSignaling , // returnIntervalCandidateForTrading , historicalMarketValueProvider ); // bool isReturnIntervalValidForSignaling = // this.returnIntervalFilterForSignaling.IsValid( returnIntervalCandidateForTrading ); // bool isReturnIntervalToBeAddedToReturnIntervalsForSignaling = ( // wereAllEligibleTickersForSignalingExchanged && // isReturnIntervalValidForSignaling ); // if ( isReturnIntervalToBeAddedToReturnIntervalsForSignaling ) // returnIntervalsForSignaling.Add( returnIntervalCandidateForTrading ); } #endregion addReturnIntervalForTradingAndReturnIntervalForSignalingIfTheCase #region removeReturnIntervalsFromSignalingIfTheCorrespondingIsNotInTradingAndViceversa private void removeReturnIntervalsFromSignalingIfTheCorrespondingIsNotInTradingAndViceversa( ReturnIntervals returnIntervalsCandidates , ReturnIntervals returnIntervalsForTrading , ReturnIntervals returnIntervalsForSignaling ) { // int indexForCurrentCandidate = 0; // int indexForTradingThatCouldBeRemoved = 0; // int indexForSignalingThatCouldBeRemoved = 0; // while ( indexForCurrentCandidate < returnIntervalsCandidates.Count ) // { // ReturnInterval currentCandidate = // returnIntervalsCandidates[ indexForCurrentCandidate ]; // if ( this.isToBeRemovedFromTrading( currentCandidate // } } #endregion removeReturnIntervalsFromSignalingIfTheCorrespondingIsNotInTradingAndViceversa /// <summary> /// Builds returnIntervalsForTrading and returnIntervalsForSignaling /// </summary> /// <param name="returnsManager">contains the ReturnIntervals for the /// trading tickers; it also contains the IHistoricalMarketValueProvider /// to be used to see if eligibleTickersForTrading and eligibleTickersForSignaling /// were exchanged at given DateTime(s)</param></param> /// <param name="eligibleTickersForTrading"></param> /// <param name="eligibleTickersForSignaling"></param> /// <param name="returnIntervalsForTrading"></param> /// <param name="returnIntervalsForSignaling"></param> public void BuildIntervals( IReturnsManager returnsManager , IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling , out ReturnIntervals returnIntervalsForTrading , out ReturnIntervals returnIntervalsForSignaling ) { ReturnIntervals returnIntervalsCandidatesForTrading = returnsManager.ReturnIntervals; returnIntervalsForTrading = new ReturnIntervals(); returnIntervalsForSignaling = new ReturnIntervals(); foreach ( ReturnInterval returnIntervalCandidateForTrading in returnIntervalsCandidatesForTrading ) this.addReturnIntervalForTradingAndReturnIntervalForSignalingIfTheCase( returnIntervalCandidateForTrading , returnsManager.HistoricalMarketValueProvider , returnIntervalSelectorForSignaling , eligibleTickersForTrading , eligibleTickersForSignaling , returnIntervalsForTrading , returnIntervalsForSignaling ); this.removeReturnIntervalsFromSignalingIfTheCorrespondingIsNotInTradingAndViceversa( returnIntervalsCandidatesForTrading , returnIntervalsForTrading , returnIntervalsForSignaling ); } #endregion BuildIntervals } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:08:49
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30842/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: LinearRegressionValues.cs Log Message: Values needed to set up a regression --- NEW FILE: LinearRegressionValues.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionValues.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Values needed to set up a regression /// </summary> [Serializable] public class LinearRegressionValues : ILinearRegressionValues { private double[] regressand; public double[] Regressand { get { return this.regressand; } } private double[,] regressors; public double[,] Regressors { get { return this.regressors; } } private double[] regressorWeights; public double[] RegressorWeights { get { return this.regressorWeights; } } public LinearRegressionValues( double[] regressand , double[,] regressors , double[] regressorWeights ) { this.regressand = regressand; this.regressors = regressors; this.regressorWeights = regressorWeights; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:08:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30683/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: LinearRegressionSetUpManager.cs Log Message: Sets up a linear regression so that it then can be evaluated --- NEW FILE: LinearRegressionSetUpManager.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionSetUpManager.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Collections; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Sets up a linear regression so that it then can be evaluated /// </summary> [Serializable] public class LinearRegressionSetupManager : ILinearRegressionSetupManager { public LinearRegressionSetupManager() { } #region SetUpTheLinearRegression #region getRegressand protected double[] getRegressand( IReturnsCalculator returnsCalculatorForTheRegressand , IReturnsManager returnsManager ) { // WeightedPositions weightedPositionsForRegressand = // this.getWeightedPositionsForRegressand( // weightedPositions , returnsManager ); float[] floatReturns = returnsCalculatorForTheRegressand.GetReturns( returnsManager , 0 , returnsManager.NumberOfReturns - 1 ); double[] returns = FloatArrayManager.ConvertToDouble( floatReturns ); return returns; } #endregion getRegressand #region getRegressors private void addConstantRegressor( double[,] regressors ) { for( int j = 0 ; j < regressors.GetLength( 1 ) ; j++ ) regressors[ j , 0 ] = 1; } #region addVariableRegressors #region addVariableRegressor private void addVariableRegressor( int regressorIndex , IReturnsCalculator[] returnCalculatorForTheRegressors , IReturnsManager returnsManager , double[,] regressors ) { IReturnsCalculator returnCalculatorForCurrentRegressor = returnCalculatorForTheRegressors[ regressorIndex - 1 ]; // the first regressor is the constant // this.getWeightedPositionsForRegressor( // regressorIndex , weightedPositions , returnsManager ); for( int j = 0 ; j < regressors.GetLength( 0 ) ; j++ ) regressors[ j , regressorIndex ] = returnCalculatorForCurrentRegressor.GetReturn( j , returnsManager ); } #endregion addVariableRegressor private void addVariableRegressors( IReturnsCalculator[] returnCalculatorForTheRegressors , IReturnsManager returnsManager , double[,] regressors ) { for( int i = 1 ; i < regressors.GetLength( 1 ) ; i++ ) this.addVariableRegressor( i , returnCalculatorForTheRegressors , returnsManager , regressors ); } #endregion addVariableRegressors protected double[,] getRegressors( IReturnsCalculator[] returnCalculatorForTheRegressors , IReturnsManager returnsManagerForTheRegressor ) { int numberOfObservations = returnsManagerForTheRegressor.NumberOfReturns; int numberOfRegressors = returnCalculatorForTheRegressors.Length + 1; // one is added for the constant double[,] regressors = new double[ numberOfObservations , numberOfRegressors ]; this.addConstantRegressor( regressors ); this.addVariableRegressors( returnCalculatorForTheRegressors , returnsManagerForTheRegressor , regressors ); return regressors; } #endregion getRegressors private double[] getRegressionWeights( int numberOfObservations ) { double[] regressionWeights = new double[ numberOfObservations ]; for( int i = 0 ; i < numberOfObservations ; i++ ) regressionWeights[ i ] = 1; return regressionWeights; } /// <summary> /// Sets up a linear regression so that it then can be evaluated. /// A constant regressor is always added /// </summary> /// <param name="weightedPositionsForTheRegressand"></param> /// <param name="weightedPositionsForTheRegressors"></param> /// <param name="returnsManager"></param> public ILinearRegressionValues SetUpTheLinearRegressionValues( IReturnsCalculator returnsCalculatorForTheRegressand , IReturnsCalculator[] returnCalculatorForTheRegressors , IReturnsManager returnsManagerForTheRegressand , IReturnsManager returnsManagerForTheRegressor ) { double[] regressand = this.getRegressand( returnsCalculatorForTheRegressand , returnsManagerForTheRegressand ); double[,] regressors = this.getRegressors( returnCalculatorForTheRegressors , returnsManagerForTheRegressor ); double[] regressionWeights = this.getRegressionWeights( regressand.Length ); // QuantProject.ADT.Econometrics.LinearRegression linearRegression = // new QuantProject.ADT.Econometrics.LinearRegression(); // linearRegression.Regress( regressand , regressors , regressionWeights ); LinearRegressionValues linearRegressionValues = new LinearRegressionValues( regressand , regressors , regressionWeights ); return linearRegressionValues; } #endregion SetUpTheLinearRegression } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:08:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30391/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: LinearRegressionFitnessEvaluator.cs Log Message: Computes (in sample) the OLS estimate of the following regression: the regressand is the return of the TradingPortfolio; the regressors are the constant and the SignalingPortfolios --- NEW FILE: LinearRegressionFitnessEvaluator.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionFitnessEvaluator.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Econometrics; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Computes (in sample) the OLS estimate of the following regression: /// the regressand is the return of the TradingPortfolio; the regressors /// are the constant and the SignalingPortfolios /// </summary> [Serializable] public class LinearRegressionFitnessEvaluator : // MarshalByRefObject , // MarshalByRefObject added for testing ILinearRegressionFitnessEvaluator { // private bool hasReturnsManagerForTradingTickersBeenSetSinceLastGetFitnessValueRequest; // private bool hasReturnsManagerForSignalingTickersBeenSetSinceLastGetFitnessValueRequest; // private ILinearRegressionValues linearRegressionValues; private ILinearRegressionSetupManager linearRegressionSetupManger; private IReturnsManager returnsManagerForTradingTickers; public IReturnsManager ReturnsManagerForTradingTickers { get { return this.returnsManagerForTradingTickers; } set { this.returnsManagerForTradingTickers = value; // this.hasReturnsManagerForTradingTickersBeenSetSinceLastGetFitnessValueRequest = // true; } } private IReturnsManager returnsManagerForSignalingTickers; public IReturnsManager ReturnsManagerForSignalingTickers { get { return this.returnsManagerForSignalingTickers; } set { this.returnsManagerForSignalingTickers = value; // this.hasReturnsManagerForSignalingTickersBeenSetSinceLastGetFitnessValueRequest = // true; } } public string Description { get { return "lnrRgrssnRSquare"; } } public LinearRegressionFitnessEvaluator( ILinearRegressionSetupManager linearRegressionSetupManger ) { this.linearRegressionSetupManger = linearRegressionSetupManger; // this.hasReturnsManagerForTradingTickersBeenSetSinceLastGetFitnessValueRequest = // false; // this.hasReturnsManagerForSignalingTickersBeenSetSinceLastGetFitnessValueRequest = // false; } public QuantProject.ADT.Econometrics.LinearRegression SetUpAndRunLinearRegression( LinearRegressionTestingPositions testingPositions ) { ILinearRegressionValues linearRegressionValues = this.linearRegressionSetupManger.SetUpTheLinearRegressionValues( testingPositions.TradingPortfolio , testingPositions.SignalingPortfolios , this.returnsManagerForTradingTickers , this.returnsManagerForSignalingTickers ); QuantProject.ADT.Econometrics.LinearRegression linearRegression = new QuantProject.ADT.Econometrics.LinearRegression(); linearRegression.RunRegression( linearRegressionValues.Regressand , linearRegressionValues.Regressors ); // linearRegressionValues.RegressorWeights ); return linearRegression; } #region GetFitnessValue private void getFitnessValue_checkParameters( object meaning ) { if ( !( meaning is TestingPositionsForUndecodableEncoded ) && !( meaning is LinearRegressionTestingPositions ) ) throw new Exception( "The meaning should always be a LinearRegressionTestingPositions!" ); if ( this.returnsManagerForTradingTickers == null ) throw new Exception( "The property ReturnsManagerForTradingTickers has not been set. It must " + "be set before invoking GetFitnessValue()!" ); if ( this.returnsManagerForSignalingTickers == null ) throw new Exception( "The property ReturnsManagerForSignalingTickers has not been set. It must " + "be set before invoking GetFitnessValue()!" ); } #region getFitnessValue private double getFitnessValue( WeightedPositions tradingPortfolio , WeightedPositions[] signalingPortfolios ) { ILinearRegressionValues linearRegressionValues = this.linearRegressionSetupManger.SetUpTheLinearRegressionValues( tradingPortfolio , signalingPortfolios , this.returnsManagerForTradingTickers , this.returnsManagerForSignalingTickers ); // this.getFitnessValue_checkWeightedPositions( weightedPositions ); // QuantProject.ADT.Econometrics.LinearRegression linearRegression = // this.setupAndRunTheLinearRegression( // tradingPortfolio , signalingPortfolios , returnsManager ); QuantProject.ADT.Econometrics.LinearRegression linearRegression = new QuantProject.ADT.Econometrics.LinearRegression(); linearRegression.RunRegression( linearRegressionValues.Regressand , linearRegressionValues.Regressors ); // linearRegressionValues.RegressorWeights ); double fitnessValue = linearRegression.CenteredRSquare; return fitnessValue; } private double getFitnessValue( LinearRegressionTestingPositions testingPositions ) { QuantProject.ADT.Econometrics.LinearRegression linearRegression = this.SetUpAndRunLinearRegression( testingPositions ); double fitnessValue = linearRegression.CenteredRSquare; return fitnessValue; // // double fitnessValue; // fitnessValue = this.getFitnessValue( // testingPositions.TradingPortfolio , // testingPositions.SignalingPortfolios ); // return fitnessValue; } #endregion getFitnessValue public double GetFitnessValue( object meaning , IReturnsManager returnsManager ) { this.getFitnessValue_checkParameters( meaning ); double fitnessValue = -3; // value if the encoded was not properly decodable if ( !(meaning is TestingPositionsForUndecodableEncoded ) ) // the encoded was actually decodable; meaning is a LinearRegressionTestingPositions // this method doesn't use returnsManager. It uses // this.returnsManagerForTradingTickers and this.returnsMangerForSignalingTickers instead fitnessValue = this.getFitnessValue( (LinearRegressionTestingPositions)meaning ); // this.hasReturnsManagerForTradingTickersBeenSetSinceLastGetFitnessValueRequest = // false; // this.hasReturnsManagerForSignalingTickersBeenSetSinceLastGetFitnessValueRequest = // false; return fitnessValue; } #endregion GetFitnessValue #region GetIndependentVariablesValues private bool wereAllSignalingTickersExchanged( LinearRegressionTestingPositions linearRegressionTestingPositions , ReturnInterval outOfSampleReturnIntervalForSignaling , HistoricalMarketValueProvider historicalMarketValueProvider ) { bool wereExchanged = ( historicalMarketValueProvider.WereAllExchanged( linearRegressionTestingPositions.SignalingTickers , outOfSampleReturnIntervalForSignaling.Begin ) && historicalMarketValueProvider.WereAllExchanged( linearRegressionTestingPositions.SignalingTickers , outOfSampleReturnIntervalForSignaling.End ) ); return wereExchanged; } private double[] getIndependentVariablesValuesOnValidReturnedInterval( LinearRegressionTestingPositions linearRegressionTestingPositions , ReturnInterval returnInterval , HistoricalMarketValueProvider historicalMarketValueProvider ) { double[] independentVariablesValues = // new double[ weightedPositions.Count - 2 + 1 ]; // one is added for the constant new double[ linearRegressionTestingPositions.SignalingPortfolios.Length + 1 ]; // one is added for the constant independentVariablesValues[ 0 ] = 0; // regressors include the constant and the constant's return is zero ReturnsManager returnsManager = new ReturnsManager( new ReturnIntervals( returnInterval ) , historicalMarketValueProvider ); for( int j = 0 ; j < linearRegressionTestingPositions.SignalingPortfolios.Length ; j++ ) { WeightedPositions portfolioForCurrentIndependentVariable = linearRegressionTestingPositions.SignalingPortfolios[ j ]; independentVariablesValues[ j + 1 ] = portfolioForCurrentIndependentVariable.GetReturn( 0 , returnsManager ); } return independentVariablesValues; } /// <summary> /// returns an array with the values for the independent variables. This is /// going to be used out of sample and it should be coherent with how /// the regressors are built in sample. If /// </summary> public virtual double[] GetIndependentVariablesValues( LinearRegressionTestingPositions linearRegressionTestingPositions , ReturnInterval outOfSampleReturnIntervalForSignaling , HistoricalMarketValueProvider historicalMarketValueProvider ) { double[] independentVariablesValues = null; if ( this.wereAllSignalingTickersExchanged ( linearRegressionTestingPositions , outOfSampleReturnIntervalForSignaling , historicalMarketValueProvider ) ) independentVariablesValues = this.getIndependentVariablesValuesOnValidReturnedInterval( linearRegressionTestingPositions , outOfSampleReturnIntervalForSignaling , historicalMarketValueProvider ); return independentVariablesValues; } #endregion GetIndependentVariablesValues } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:03:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28405/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: ILinearRegressionValues.cs Log Message: Interface to be implemented by those classes that compute values for a linear regression --- NEW FILE: ILinearRegressionValues.cs --- /* QuantProject - Quantitative Finance Library IILinearRegressionValues.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Interface to be implemented by those classes that compute values /// for a linear regression /// </summary> public interface ILinearRegressionValues { double[] Regressand { get; } double[,] Regressors { get; } double[] RegressorWeights { get; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:03:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28250/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: ILinearRegressionSetupManager.cs Log Message: Interface to be implemented by those classes that build up a linear regression, ready to be run --- NEW FILE: ILinearRegressionSetupManager.cs --- /* QuantProject - Quantitative Finance Library ILinearRegressionSetupManager.cs Copyright (C) 2010 Glauco Siliprandi This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Interface to be implemented by those classes that build up /// a linear regression, ready to be run /// </summary> public interface ILinearRegressionSetupManager { ILinearRegressionValues SetUpTheLinearRegressionValues( IReturnsCalculator returnsCalculatorForTheRegressand , IReturnsCalculator[] returnCalculatorForTheRegressors , IReturnsManager returnsManagerForTheRegressand , IReturnsManager returnsManagerForTheRegressor ); } } |