quantproject-developers Mailing List for QuantProject (Page 9)
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: Marco M. <mi...@us...> - 2010-11-20 18:40:22
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24598/a4_Fundamentals Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:23:14
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19488/t5_Testing Modified Files: QPTesting.csproj Log Message: The reference to nunit.mocks.dll has been changed so that now, the .dll has to be placed in the same folder as the other .dlls Index: QPTesting.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/QPTesting.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QPTesting.csproj 28 Mar 2010 17:14:23 -0000 1.2 --- QPTesting.csproj 28 Mar 2010 17:23:06 -0000 1.3 *************** *** 28,32 **** <Reference Include="nunit.framework" /> <Reference Include="nunit.mocks"> ! <HintPath>nunit.mocks.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference> --- 28,32 ---- <Reference Include="nunit.framework" /> <Reference Include="nunit.mocks"> ! <HintPath>..\..\nunit.mocks.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference> |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:15:42
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv17500/b91_QuantProject Modified Files: Main.cs Log Message: The code to run a linear regression based backtest has been added Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Main.cs 1 Oct 2009 19:16:23 -0000 1.24 --- Main.cs 28 Mar 2010 17:15:34 -0000 1.25 *************** *** 36,39 **** --- 36,40 ---- using QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; + using QuantProject.Scripts.WalkForwardTesting.LinearRegression; using QuantProject.Scripts.WalkForwardTesting.PairsTrading; using QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank; *************** *** 478,482 **** // new PairsTradingMain().Run(); ! new RunOneRank().Run(); //new RunEfficientCTCPorfolio("Test",400,5,90,10,10000, // "^SPX", --- 479,484 ---- // new PairsTradingMain().Run(); ! new LinearRegressionMain().Run(); ! // new RunOneRank().Run(); //new RunEfficientCTCPorfolio("Test",400,5,90,10,10000, // "^SPX", |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:14:31
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv17278 Modified Files: QPTesting.csproj Log Message: A reference to nunit.mocks.dll has been added A reference to System.Data has been added a5_FakeImplementations\FakeGenomeManager.cs has been added a5_FakeImplementations\FakeHistoricalMarketValueProvider.cs has been added b1_ADT\Econometrics\TestLinearRegression.cs has been added b1_ADT\LinearAlgebra\TestLinearSystemSolver.cs has been added b3_data\Selectors\TestTickerSelector.cs has been added b4_Business\a2_Strategies\Eligibles\TestOftenExchanged.cs has been added b4_Business\a2_Strategies\Optimizing\Decoding\TestBasicDecoderForTestingPositions.cs has been added b4_Business\a2_Strategies\ReturnsManagment\Time\TestReturnIntervals.cs has been added b7_scripts\linearRegression\TestDecoderForLinearRegressionTestingPositions.cs has been added b7_scripts\linearRegression\TestLinearRegressionFitnessEvaluator.cs has been added b7_scripts\linearRegression\TestLinearRegressionSetUpManager.cs has been added b7_scripts\linearRegression\TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs has been added b7_scripts\linearRegression\TestGenomeManagerForLinearRegression.cs has been added b7_scripts\linearRegression\TestEntryStrategyBasedOnForecastedReturn.cs has been added b7_scripts\linearRegression\TestReturnIntervalsBuilderForTradingAndForSignaling.cs has been added b7_scripts\linearRegression\TestSingleDayIntervalsSelector.cs has been added A reference to "..\b3_Data\Data_SD.csproj" has been added A reference to "..\b4_Business\Business_SD.csproj" has been added A reference to "..\b7_Scripts\Scripts_SD.csproj" has been added Index: QPTesting.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/QPTesting.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QPTesting.csproj 31 Jan 2010 18:57:44 -0000 1.1 --- QPTesting.csproj 28 Mar 2010 17:14:23 -0000 1.2 *************** *** 27,36 **** --- 27,57 ---- <ItemGroup> <Reference Include="nunit.framework" /> + <Reference Include="nunit.mocks"> + <HintPath>nunit.mocks.dll</HintPath> + <SpecificVersion>False</SpecificVersion> + </Reference> <Reference Include="System" /> + <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="a5_FakeImplementations\FakeGenomeManager.cs" /> + <Compile Include="a5_FakeImplementations\FakeHistoricalMarketValueProvider.cs" /> <Compile Include="AssemblyInfo.cs" /> + <Compile Include="b1_ADT\Econometrics\TestLinearRegression.cs" /> + <Compile Include="b1_ADT\LinearAlgebra\TestLinearSystemSolver.cs" /> <Compile Include="b1_ADT\Sum.cs" /> + <Compile Include="b3_data\Selectors\TestTickerSelector.cs" /> + <Compile Include="b4_Business\a2_Strategies\Eligibles\TestOftenExchanged.cs" /> + <Compile Include="b4_Business\a2_Strategies\Optimizing\Decoding\TestBasicDecoderForTestingPositions.cs" /> + <Compile Include="b4_Business\a2_Strategies\ReturnsManagment\Time\TestReturnIntervals.cs" /> + <Compile Include="b7_scripts\linearRegression\TestDecoderForLinearRegressionTestingPositions.cs" /> + <Compile Include="b7_scripts\linearRegression\TestLinearRegressionFitnessEvaluator.cs" /> + <Compile Include="b7_scripts\linearRegression\TestLinearRegressionSetUpManager.cs" /> + <Compile Include="b7_scripts\linearRegression\TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs" /> + <Compile Include="b7_scripts\linearRegression\TestGenomeManagerForLinearRegression.cs" /> + <Compile Include="b7_scripts\linearRegression\TestEntryStrategyBasedOnForecastedReturn.cs" /> + <Compile Include="b7_scripts\linearRegression\TestReturnIntervalsBuilderForTradingAndForSignaling.cs" /> + <Compile Include="b7_scripts\linearRegression\TestSingleDayIntervalsSelector.cs" /> </ItemGroup> <ItemGroup> *************** *** 39,43 **** --- 60,90 ---- <Name>ADT_SD</Name> </ProjectReference> + <ProjectReference Include="..\b3_Data\Data_SD.csproj"> + <Project>{1A0B0C1A-DBC5-4AE6-BE2E-2298135DD60C}</Project> + <Name>Data_SD</Name> + </ProjectReference> + <ProjectReference Include="..\b4_Business\Business_SD.csproj"> + <Project>{91CAD8B7-D505-40BE-8FAF-0597E62FF71D}</Project> + <Name>Business_SD</Name> + </ProjectReference> + <ProjectReference Include="..\b7_Scripts\Scripts_SD.csproj"> + <Project>{B5AAC5AA-DCC1-4698-A362-D399AB9A90C4}</Project> + <Name>Scripts_SD</Name> + </ProjectReference> <Folder Include="b1_ADT" /> + <Folder Include="b1_ADT\LinearAlgebra" /> + <Folder Include="b1_ADT\Econometrics" /> + <Folder Include="b3_data\Selectors" /> + <Folder Include="b4_Business\a2_Strategies" /> + <Folder Include="b4_Business\a2_Strategies\Eligibles" /> + <Folder Include="b4_Business\a2_Strategies\Optimizing" /> + <Folder Include="b4_Business\a2_Strategies\Optimizing\Decoding" /> + <Folder Include="b4_Business\a2_Strategies\ReturnsManagment" /> + <Folder Include="b4_Business\a2_Strategies\ReturnsManagment\Time" /> + <Folder Include="b7_scripts" /> + <Folder Include="b7_scripts\linearRegression" /> + <Folder Include="b4_Business" /> + <Folder Include="b3_data" /> + <Folder Include="a5_FakeImplementations" /> </ItemGroup> </Project> \ No newline at end of file |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:10:04
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15744/b7_scripts/linearRegression Added Files: TestSingleDayIntervalsSelector.cs Log Message: Test for the SingleDayIntervalsSelector class --- NEW FILE: TestSingleDayIntervalsSelector.cs --- /* QuantProject - Quantitative Finance Library TestSingleDayIntervalsSelector.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 NUnit.Framework; using QuantProject.ADT.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { public class BenchmarkToTestSingleDayIntervalsSelector : Benchmark { private List<DateTime> dateTimes; // private int indexForTheNextDateTimeToBeChosen; public BenchmarkToTestSingleDayIntervalsSelector( List<DateTime> dateTimes ) : base( "dummyTicker" ) { this.dateTimes = dateTimes; // this.indexForTheNextDateTimeToBeChosen = 0; } public override DateTime GetThisOrNextDateTimeWhenTraded( DateTime startingDateTime , Time dailyTime , DateTime lastAcceptableDateTime ) { DateTime thisOrNextDateTimeWhenTraded = DateTime.MinValue; int currentIndex = 0; while ( ( currentIndex < this.dateTimes.Count ) && ( this.dateTimes[ currentIndex ] < startingDateTime ) ) currentIndex++; if ( currentIndex < this.dateTimes.Count ) // at least a DateTime greater or equal than startingDateTime has been found thisOrNextDateTimeWhenTraded = this.dateTimes[ currentIndex ]; // thisOrNextDateTimeWhenTraded = this.dateTimes[ currentIndex ]; return thisOrNextDateTimeWhenTraded; } } [TestFixture] /// <summary> /// Test for the SingleDayIntervalsSelector class /// </summary> public class TestSingleDayIntervalsSelector { #region TestMethod private BenchmarkToTestSingleDayIntervalsSelector getBenchmark() { List<DateTime> dateTimesForBenchmark = new List<DateTime>(); dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 10 , 16 , 0 , 0 ) ); // wednesday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 11 , 16 , 0 , 0 ) ); // thursday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 12 , 16 , 0 , 0 ) ); // friday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 15 , 16 , 0 , 0 ) ); // monday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 16 , 16 , 0 , 0 ) ); // tuesday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 17 , 16 , 0 , 0 ) ); // wednesday dateTimesForBenchmark.Add( new DateTime( 2010 , 2 , 18 , 16 , 0 , 0 ) ); // thursday BenchmarkToTestSingleDayIntervalsSelector benchmark = new BenchmarkToTestSingleDayIntervalsSelector( dateTimesForBenchmark ); return benchmark; } [Test] public void TestMethod() { BenchmarkToTestSingleDayIntervalsSelector benchmark = this.getBenchmark(); List<DayOfWeek> acceptableDaysOfTheWeekForTheEndOfEachInterval = new List<DayOfWeek>( new DayOfWeek[] { DayOfWeek.Monday , DayOfWeek.Tuesday , // wednesday is not acceptable! DayOfWeek.Thursday , DayOfWeek.Friday } ); SingleDayIntervalsSelector singleDayIntervalsSelector = new SingleDayIntervalsSelector( benchmark , new Time( 16 , 0 , 0 ) , acceptableDaysOfTheWeekForTheEndOfEachInterval , TimeSpan.FromDays( 20 ) ); ReturnInterval firstReturnInterval = singleDayIntervalsSelector.GetFirstInterval( new DateTime( 2010 , 2 , 10 , 16 , 0 , 0 ) ); Assert.AreEqual( firstReturnInterval.Begin , new DateTime( 2010 , 2 , 10 , 16 , 0 , 0 ) ); // wednesday Assert.AreEqual( firstReturnInterval.End , new DateTime( 2010 , 2 , 11 , 16 , 0 , 0 ) ); // thursday ReturnIntervals returnIntervals = new ReturnIntervals( firstReturnInterval ); ReturnInterval secondReturnInterval = singleDayIntervalsSelector.GetNextInterval( returnIntervals ); Assert.AreEqual( secondReturnInterval.Begin , new DateTime( 2010 , 2 , 11 , 16 , 0 , 0 ) ); // thursday Assert.AreEqual( secondReturnInterval.End , new DateTime( 2010 , 2 , 12 , 16 , 0 , 0 ) ); // friday returnIntervals.Add( secondReturnInterval ); ReturnInterval thirdReturnInterval = singleDayIntervalsSelector.GetNextInterval( returnIntervals ); Assert.AreEqual( thirdReturnInterval.Begin , new DateTime( 2010 , 2 , 15 , 16 , 0 , 0 ) ); // monday Assert.AreEqual( thirdReturnInterval.End , new DateTime( 2010 , 2 , 16 , 16 , 0 , 0 ) ); // tuesday returnIntervals.Add( thirdReturnInterval ); ReturnInterval fourthReturnInterval = singleDayIntervalsSelector.GetNextInterval( returnIntervals ); Assert.AreEqual( fourthReturnInterval.Begin , new DateTime( 2010 , 2 , 17 , 16 , 0 , 0 ) ); // wednesday Assert.AreEqual( fourthReturnInterval.End , new DateTime( 2010 , 2 , 18 , 16 , 0 , 0 ) ); // thursday returnIntervals.Add( fourthReturnInterval ); ReturnInterval fifthReturnInterval = singleDayIntervalsSelector.GetNextInterval( returnIntervals ); Assert.IsNull( fifthReturnInterval ); // no more intervals are available } #endregion TestMethod } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:08:59
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15515/b7_scripts/linearRegression Added Files: TestReturnIntervalsBuilderForTradingAndForSignaling.cs Log Message: Test for the class TestReturnIntervalsBuilderForTradingAndForSignaling --- NEW FILE: TestReturnIntervalsBuilderForTradingAndForSignaling.cs --- /* QuantProject - Quantitative Finance Library TestReturnIntervalsBuilderForTradingAndForSignaling.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 NUnit.Framework; using NUnit.Mocks; using QuantProject.ADT.Histories; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { public class FakeHistMarkValueProvForTestReturnIntervalsBuilderForTradingAndForSignaling : HistoricalMarketValueProvider { // public override History GetMarketValues( string ticker , History history ) // { // return null; // } public override double GetMarketValue( string ticker , DateTime dateTime ) { return double.MinValue;; } protected override string getDescription() { return "fake"; } public override bool WasExchanged( string ticker , DateTime dateTime ) { bool wasExchanged = true; if ( ( ticker == "TB" ) && ( dateTime == new DateTime( 2000 , 1 , 4 ) ) ) wasExchanged = false; if ( ( ticker == "SA" ) && ( dateTime == new DateTime( 2000 , 1 , 9 ) ) ) wasExchanged = false; return wasExchanged; } } /// <summary> /// Test for the class TestReturnIntervalsBuilderForTradingAndForSignaling /// </summary> [TestFixture] public class TestReturnIntervalsBuilderForTradingAndForSignaling { #region TestMethod [Test] public void TestMethod() { // // valid for signaling and for trading (in signaling - out trading) // ReturnInterval firstReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 1 ) , new DateTime( 2000 , 1 , 2 ) ); // // valid for signaling and for trading (out signaling - in trading) // ReturnInterval secondReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 3 ) , new DateTime( 2000 , 1 , 4 ) ); // // valid for signaling but NOT for trading (out signaling - out trading) // ReturnInterval thirdReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 5 ) , new DateTime( 2000 , 1 , 6 ) ); // // valid for signaling and for trading, but lacks a quote for trading // // (in signaling - out trading) // ReturnInterval fourthReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 7 ) , new DateTime( 2000 , 1 , 8 ) ); // // valid for trading but NOT for signaling (out signaling - in trading) // ReturnInterval fifthReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 9 ) , new DateTime( 2000 , 1 , 10 ) ); // // valid for signaling and for trading (in signaling - out trading) // ReturnInterval sixthReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 11 ) , new DateTime( 2000 , 1 , 12 ) ); // // valid for signaling and for trading (in signaling - in trading) // ReturnInterval seventhReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 13 ) , new DateTime( 2000 , 1 , 14 ) ); // // valid for signaling and for trading, but lacks a quote for signaling // // (out signaling - in trading) // ReturnInterval eighthReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 15 ) , new DateTime( 2000 , 1 , 16 ) ); // // valid for signaling and for trading (in signaling - out trading) // ReturnInterval ninethReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 17 ) , new DateTime( 2000 , 1 , 18 ) ); // // valid for signaling and for trading (out signaling - in trading) // ReturnInterval tenthReturnInterval = new ReturnInterval( // new DateTime( 2000 , 1 , 19 ) , new DateTime( 2000 , 1 , 20 ) ); // in ReturnInterval firstReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 2 ) , new DateTime( 2000 , 1 , 3 ) ); // lacks a quote for trading - out ReturnInterval secondReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 4 ) , new DateTime( 2000 , 1 , 5 ) ); // in ReturnInterval thirdReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 6 ) , new DateTime( 2000 , 1 , 7 ) ); // in ReturnInterval fourthReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 8 ) , new DateTime( 2000 , 1 , 9 ) ); // lacks a quote for signaling - out ReturnInterval fifthReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 10 ) , new DateTime( 2000 , 1 , 11 ) ); // in ReturnInterval sixthReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 12 ) , new DateTime( 2000 , 1 , 13 ) ); ReturnIntervals returnIntervals = new ReturnIntervals(); returnIntervals.Add( firstReturnIntervalForTrading ); returnIntervals.Add( secondReturnIntervalForTrading ); returnIntervals.Add( thirdReturnIntervalForTrading ); returnIntervals.Add( fourthReturnIntervalForTrading ); returnIntervals.Add( fifthReturnIntervalForTrading ); returnIntervals.Add( sixthReturnIntervalForTrading ); // returnIntervals.Add( seventhReturnInterval ); // returnIntervals.Add( eighthReturnInterval ); // returnIntervals.Add( ninethReturnInterval ); // returnIntervals.Add( tenthReturnInterval ); FakeHistMarkValueProvForTestReturnIntervalsBuilderForTradingAndForSignaling fakeHistoricalMarketValueProvider = new FakeHistMarkValueProvForTestReturnIntervalsBuilderForTradingAndForSignaling(); DynamicMock dynamicMockReturnsManager = new DynamicMock( typeof( IReturnsManager ) ); dynamicMockReturnsManager.SetReturnValue( "get_ReturnIntervals" , returnIntervals ); dynamicMockReturnsManager.SetReturnValue( "get_HistoricalMarketValueProvider" , fakeHistoricalMarketValueProvider ); IReturnsManager mockReturnsManager = (IReturnsManager)dynamicMockReturnsManager.MockInstance; string[] eligibleTickersForTrading = new string[] { "TA" , "TB" }; string[] eligibleTickersForSignaling = new string[] { "SA" , "SB" }; // DynamicMock dinamicMockReturnIntervalFilterForTrading = // new DynamicMock( typeof( IReturnIntervalFilter ) ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , firstReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , secondReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , thirdReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , fourthReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , fifthReturnInterval , false ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , sixthReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , seventhReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , eighthReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , ninethReturnInterval , true ); // dinamicMockReturnIntervalFilterForTrading.ExpectAndReturn( // "IsValid" , tenthReturnInterval , true ); // IReturnIntervalFilter mockReturnIntervalFilterForTrading = // (IReturnIntervalFilter) // dinamicMockReturnIntervalFilterForTrading.MockInstance; // DynamicMock dinamicMockReturnIntervalFilterForSignaling = // new DynamicMock( typeof( IReturnIntervalFilter ) ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , firstReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , secondReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , thirdReturnInterval , false ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , fourthReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , fifthReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , sixthReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , seventhReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , eighthReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , ninethReturnInterval , true ); // dinamicMockReturnIntervalFilterForSignaling.ExpectAndReturn( // "IsValid" , tenthReturnInterval , true ); // IReturnIntervalFilter mockReturnIntervalFilterForSignaling = // (IReturnIntervalFilter) // dinamicMockReturnIntervalFilterForSignaling.MockInstance; // in ReturnInterval firstReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 1 ) , new DateTime( 2000 , 1 , 2 ) ); // lacks a quote for trading - out ReturnInterval secondReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 3 ) , new DateTime( 2000 , 1 , 4 ) ); // in ReturnInterval thirdReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 5 ) , new DateTime( 2000 , 1 , 6 ) ); // in ReturnInterval fourthReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 7 ) , new DateTime( 2000 , 1 , 8 ) ); // lacks a quote for signaling - out ReturnInterval fifthReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 9 ) , new DateTime( 2000 , 1 , 10 ) ); // in ReturnInterval sixthReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 11 ) , new DateTime( 2000 , 1 , 12 ) ); DynamicMock dynamicMockReturnIntervalSelectorForSignaling = new DynamicMock( typeof( IReturnIntervalSelectorForSignaling ) ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , firstReturnIntervalForSignaling , new object[] { firstReturnIntervalForTrading } ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , secondReturnIntervalForSignaling , new object[] { secondReturnIntervalForTrading } ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , thirdReturnIntervalForSignaling , new object[] { thirdReturnIntervalForTrading } ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , fourthReturnIntervalForSignaling , new object[] { fourthReturnIntervalForTrading } ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , fifthReturnIntervalForSignaling , new object[] { fifthReturnIntervalForTrading } ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , sixthReturnIntervalForSignaling , new object[] { sixthReturnIntervalForTrading } ); IReturnIntervalSelectorForSignaling mockReturnIntervalSelectorForSignaling = (IReturnIntervalSelectorForSignaling)dynamicMockReturnIntervalSelectorForSignaling.MockInstance; ReturnIntervalsBuilderForTradingAndForSignaling returnIntervalsBuilderForTradingAndForSignaling = new ReturnIntervalsBuilderForTradingAndForSignaling(); // mockReturnIntervalFilterForTrading , // mockReturnIntervalFilterForSignaling ); ReturnIntervals returnIntervalsForTrading; ReturnIntervals returnIntervalsForSignaling; returnIntervalsBuilderForTradingAndForSignaling.BuildIntervals( mockReturnsManager , mockReturnIntervalSelectorForSignaling , eligibleTickersForTrading , eligibleTickersForSignaling , out returnIntervalsForTrading , out returnIntervalsForSignaling ); Assert.AreEqual( 4 , returnIntervalsForTrading.Count , "for trading" ); Assert.AreEqual( 4 , returnIntervalsForSignaling.Count , "for signaling" ); Assert.AreEqual( returnIntervalsForTrading.Count , returnIntervalsForSignaling.Count , "same length" ); Assert.Contains( firstReturnIntervalForTrading , returnIntervalsForTrading ); Assert.Contains( thirdReturnIntervalForTrading , returnIntervalsForTrading ); Assert.Contains( fourthReturnIntervalForTrading , returnIntervalsForTrading ); Assert.Contains( sixthReturnIntervalForTrading , returnIntervalsForTrading ); Assert.IsFalse( returnIntervalsForTrading.BordersHistory.ContainsKey( secondReturnIntervalForTrading.Begin ) ); Assert.Contains( firstReturnIntervalForSignaling , returnIntervalsForSignaling ); Assert.Contains( thirdReturnIntervalForSignaling , returnIntervalsForSignaling ); Assert.Contains( fourthReturnIntervalForSignaling , returnIntervalsForSignaling ); Assert.Contains( sixthReturnIntervalForSignaling , returnIntervalsForSignaling ); Assert.IsFalse( returnIntervalsForTrading.BordersHistory.ContainsKey( fifthReturnIntervalForSignaling.End ) ); // void BuildIntervals( // IReturnsManager returnsManager , // string[] eligibleTickersForTrading , // string[] eligibleTickersForSignaling , // out ReturnIntervals returnIntervalsForTrading , // out ReturnIntervals returnIntervalsForSignaling ); } #endregion TestMethod } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:08:39
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15442/b7_scripts/linearRegression Added Files: TestLinearRegressionSetUpManager.cs Log Message: Test for the LinearRegressionSetUpManager class --- NEW FILE: TestLinearRegressionSetUpManager.cs --- /* * Created by SharpDevelop. * User: Glauco * Date: 3/6/2010 * Time: 3:34 AM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using NUnit.Framework; using NUnit.Mocks; using QuantProject.ADT.Optimizing.Decoding; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { [TestFixture] /// <summary> /// Test for the LinearRegressionSetUpManager class /// </summary> public class TestLinearRegressionSetUpManager { private ReturnIntervals getReturnIntervals() { ReturnIntervals returnIntervals = new ReturnIntervals(); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 1 ) ,new DateTime( 2000 , 1 , 2 ) ) ); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 3 ) ,new DateTime( 2000 , 1 , 4 ) ) ); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 5 ) ,new DateTime( 2000 , 1 , 6 ) ) ); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 7 ) ,new DateTime( 2000 , 1 , 8 ) ) ); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 9 ) ,new DateTime( 2000 , 1 , 10 ) ) ); returnIntervals.Add( new ReturnInterval( new DateTime( 2000 , 1 , 11 ) ,new DateTime( 2000 , 1 , 12 ) ) ); return returnIntervals; } [Test] public void TestMethod() { // TODO: Add your test. // DynamicMock mock = new DynamicMock(typeof(ReturnsManager)); // ReturnsManager mockReturnsManager = (ReturnsManager)mock.MockInstance; DynamicMock dynamicMockReturnsCalculatorForTheRegressand = new DynamicMock( typeof(IReturnsCalculator) ); dynamicMockReturnsCalculatorForTheRegressand.SetReturnValue( "GetReturns" , new float[] { 0.013F , -0.02F , 0.014F , 0.017F , 0.025F , -0.02F} ); IReturnsCalculator mockReturnsCalculatorForTheRegressand = (IReturnsCalculator)dynamicMockReturnsCalculatorForTheRegressand.MockInstance; IReturnsManager mockReturnsManager = new ReturnsManager( this.getReturnIntervals() , new HistoricalRawQuoteProvider() ); float[] floatTest = mockReturnsCalculatorForTheRegressand.GetReturns( mockReturnsManager , 0 , 1 ); // DynamicMock dynamicMockReturnsManager = new DynamicMock( typeof( IReturnsManager ) ); // dynamicMockReturnsManager.SetReturnValue( "get_NumberOfReturns" , 6 ); // mockReturnsManager = // (IReturnsManager)dynamicMockReturnsManager.MockInstance; DynamicMock dynamicMockReturnsCalculatorForTheFirstRegressor = new DynamicMock( typeof(IReturnsCalculator) ); // dynamicMockReturnsCalculatorForTheFirstRegressor.SetReturnValue( // "GetReturns" , new float[] // { 0.015F , -0.07F , 0.034F , -0.002F , 0.011F } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , 0.015F , new object[] { 0 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , -0.07F , new object[] { 1 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , 0.034F , new object[] { 2 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , -0.002F , new object[] { 3 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , 0.015F , new object[] { 4 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheFirstRegressor.ExpectAndReturn( "GetReturn" , 0.018F , new object[] { 5 , mockReturnsManager } ); IReturnsCalculator mockReturnsCalculatorForTheFirstRegressor= (IReturnsCalculator)dynamicMockReturnsCalculatorForTheFirstRegressor.MockInstance; DynamicMock dynamicMockReturnsCalculatorForTheSecondRegressor = new DynamicMock( typeof(IReturnsCalculator) ); // dynamicMockReturnsCalculatorForTheSecondRegressor.SetReturnValue( // "GetReturns" , new float[] // { 0.025F , -0.02F , 0.13F , 0.004F , -0.024F , -0.013F } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , 0.025F , new object[] { 0 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , -0.02F , new object[] { 1 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , 0.13F , new object[] { 2 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , 0.004F , new object[] { 3 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , -0.024F , new object[] { 4 , mockReturnsManager } ); dynamicMockReturnsCalculatorForTheSecondRegressor.ExpectAndReturn( "GetReturn" , -0.013F , new object[] { 5 , mockReturnsManager } ); IReturnsCalculator mockReturnsCalculatorForTheSecondRegressor= (IReturnsCalculator)dynamicMockReturnsCalculatorForTheSecondRegressor.MockInstance; IReturnsCalculator[] mockReturnsCalculatorForTheRegressors = (IReturnsCalculator[])new IReturnsCalculator[ 2 ] { mockReturnsCalculatorForTheFirstRegressor , mockReturnsCalculatorForTheSecondRegressor }; LinearRegressionSetupManager linearRegressionSetupManager = new LinearRegressionSetupManager(); ILinearRegressionValues linearRegressionValues = linearRegressionSetupManager.SetUpTheLinearRegressionValues( mockReturnsCalculatorForTheRegressand , mockReturnsCalculatorForTheRegressors , mockReturnsManager , mockReturnsManager ); Assert.AreEqual( 6 , linearRegressionValues.Regressand.Length ); Assert.AreEqual( -0.02F , linearRegressionValues.Regressand[ 1 ] , "-0.02F" ); Assert.AreEqual( 6 , linearRegressionValues.Regressors.GetLength( 0 ) , "GetLength( 0 )" ); Assert.AreEqual( 3 , linearRegressionValues.Regressors.GetLength( 1 ), "GetLength( 1 )" ); Assert.AreEqual( 1 , linearRegressionValues.Regressors[ 2 , 0 ] , "1=...[ 2 , 0 ]" ); Assert.AreEqual( -0.002F , linearRegressionValues.Regressors[ 3 , 1 ] , "-0.002F" ); Assert.AreEqual( 0.025F , linearRegressionValues.Regressors[ 0 , 2 ] , "0.025F" ); // mock.ExpectAndReturn( "Decode" , 6 , new int[] { 3 , 5 } ); // mock.ExpectAndReturn( "Decode" , 17 , new int[] { 11 , 12 } ); // IDecoder mockDecoder = (IDecoder)mock.MockInstance; // // object decoded; // decoded = mockDecoder.Decode( new int[] { 3 , 5 } ); // decoded = mockDecoder.Decode( new int[] { 11 , 12 } ); //// decoded = mockDecoder.Decode( new int[] { 11 , 12 } ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:06:56
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv14921/b7_scripts/linearRegression Added Files: TestLinearRegressionFitnessEvaluator.cs Log Message: Test for the LinearRegressionFitnessEvaluator class --- NEW FILE: TestLinearRegressionFitnessEvaluator.cs --- /* QuantProject - Quantitative Finance Library TestLinearRegressionFitnessEvaluator.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 NUnit.Framework; using NUnit.Mocks; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; using QuantTesting.Business.DataProviders; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { [TestFixture] /// <summary> /// Test for the LinearRegressionFitnessEvaluator class /// </summary> public class TestLinearRegressionFitnessEvaluator { #region Test_GetIndependentVariablesValues private LinearRegressionTestingPositions getLinearRegressionTestingPositions() { WeightedPositions[] signalingPortfolios = new WeightedPositions[ 2 ]; signalingPortfolios[ 0 ] = new WeightedPositions( new double[] { 0.5 , 0.5 } , new string[] { "SA1" , "SB1" } ); signalingPortfolios[ 1 ] = new WeightedPositions( new double[] { 0.75 , 0.25 } , new string[] { "SA2" , "SB2" } ); LinearRegressionTestingPositions linearRegressionTestingPositions = new LinearRegressionTestingPositions( signalingPortfolios , new WeightedPositions( new double[] { 0.5 , 0.5 } , new string[] { "NOTUSEDA" , "NOTUSEDB" } ) ); return linearRegressionTestingPositions; } private LinearRegressionTestingPositions getLinearRegressionTestingPositionsToTestNull() { WeightedPositions[] signalingPortfolios = new WeightedPositions[ 2 ]; signalingPortfolios[ 0 ] = new WeightedPositions( new double[] { 0.5 , 0.5 } , new string[] { "SA1" , "SB1" } ); signalingPortfolios[ 1 ] = new WeightedPositions( new double[] { 0.75 , 0.25 } , new string[] { "SA3" , "SB2" } ); // SA3 lacks a quote LinearRegressionTestingPositions linearRegressionTestingPositions = new LinearRegressionTestingPositions( signalingPortfolios , new WeightedPositions( new double[] { 0.5 , 0.5 } , new string[] { "NOTUSEDA" , "NOTUSEDB" } ) ); return linearRegressionTestingPositions; } private FakeHistoricalMarketValueProvider getFakeHistoricalMarketValueProvider( ReturnInterval returnInterval ) { FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProviderValuesBased = new FakeHistoricalMarketValueProvider(); // "SA1" return is 2% fakeHistoricalMarketValueProviderValuesBased.Add( "SA1" , returnInterval.Begin , 1000 ); fakeHistoricalMarketValueProviderValuesBased.Add( "SA1" , returnInterval.End , 1020 ); // "SB1" return is -1% fakeHistoricalMarketValueProviderValuesBased.Add( "SB1" , returnInterval.Begin , 100 ); fakeHistoricalMarketValueProviderValuesBased.Add( "SB1" , returnInterval.End , 99 ); // "SA2" return is -2.4% fakeHistoricalMarketValueProviderValuesBased.Add( "SA2" , returnInterval.Begin , 1000 ); fakeHistoricalMarketValueProviderValuesBased.Add( "SA2" , returnInterval.End , 976 ); // "SA3" lacks a quote // fakeHistoricalMarketValueProviderValuesBased.Add( "SA3" , returnInterval.Begin , 1000 ); fakeHistoricalMarketValueProviderValuesBased.Add( "SA3" , returnInterval.End , 976 ); // "SB2" return is .4% fakeHistoricalMarketValueProviderValuesBased.Add( "SB2" , returnInterval.Begin , 50 ); fakeHistoricalMarketValueProviderValuesBased.Add( "SB2" , returnInterval.End , 50.2 ); return fakeHistoricalMarketValueProviderValuesBased; } [Test] public void Test_GetIndependentVariablesValues() { LinearRegressionTestingPositions linearRegressionTestingPositions = this.getLinearRegressionTestingPositions(); ReturnInterval returnInterval = new ReturnInterval( new DateTime( 2000 , 1 , 1 ) , new DateTime( 2000 , 1 , 2 ) ); FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = this.getFakeHistoricalMarketValueProvider( returnInterval ); DynamicMock dynamicMockLinearRegressionSetupManager = new DynamicMock( typeof( ILinearRegressionSetupManager ) ); ILinearRegressionSetupManager fakeLinearRegressionSetupManager = (ILinearRegressionSetupManager)dynamicMockLinearRegressionSetupManager.MockInstance; LinearRegressionFitnessEvaluator linearRegressionFitnessEvaluator = new LinearRegressionFitnessEvaluator( fakeLinearRegressionSetupManager ); double[] independentVariableValues = linearRegressionFitnessEvaluator.GetIndependentVariablesValues( linearRegressionTestingPositions , returnInterval , fakeHistoricalMarketValueProvider ); Assert.AreEqual( 0 , independentVariableValues[ 0 ] ); Assert.AreEqual( 0.005 , independentVariableValues[ 1 ] , 0.0000001 ); Assert.AreEqual( -0.017 , independentVariableValues[ 2 ] , 0.0000001 ); LinearRegressionTestingPositions linearRegressionTestingPositionsToTestNull = this.getLinearRegressionTestingPositionsToTestNull(); double[] independentVariableValuesToTestNull = linearRegressionFitnessEvaluator.GetIndependentVariablesValues( linearRegressionTestingPositionsToTestNull , returnInterval , fakeHistoricalMarketValueProvider ); Assert.AreEqual( null , independentVariableValuesToTestNull ); } #endregion Test_GetIndependentVariablesValues } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:06:17
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv14777/b7_scripts/linearRegression Added Files: TestGenomeManagerForLinearRegression.cs Log Message: Test for the class GenomeManagerForLinearRegression --- NEW FILE: TestGenomeManagerForLinearRegression.cs --- /* QuantProject - Quantitative Finance Library TestGenomeManagerForLinearRegression.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 NUnit.Framework; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; using QuantTesting.Business.DataProviders; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { [TestFixture] /// <summary> /// Test for the class GenomeManagerForLinearRegression /// </summary> public class TestGenomeManagerForLinearRegression { [Test] public void TestMethod() { EligibleTickers eligibleTickersForTrading = new EligibleTickers( new string[] { "AAAA" , "BBBB" , "CCCC" } ); EligibleTickers eligibleTickersForSignaling = new EligibleTickers( new string[] { "AAAA" , "BBBB" , "CCCC" , "DDDD" , "EEEE" } ); ReturnsManager returnsManager = new ReturnsManager( new ReturnIntervals( new ReturnInterval( new DateTime( 2008 , 1 , 1 ) , new DateTime( 2008 , 1 , 2 ) ) ) , new FakeHistoricalMarketValueProvider() ); DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = new DecoderForLinearRegressionTestingPositions( 4 ); LinearRegressionFitnessEvaluator fitnessEvaluator = new LinearRegressionFitnessEvaluator( new LinearRegressionSetupManager() ); GenomeManagerForLinearRegression genomeManagerForLinearRegression = new GenomeManagerForLinearRegression( eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager , decoderForLinearRegressionTestingPositions , fitnessEvaluator , GenomeManagerType.ShortAndLong , 1 , 2 ); // EligibleTickers eligibleTickersForTrading , // EligibleTickers eligibleTickersForSignaling , //// ReturnsManager returnsManager , // IReturnsManager returnsManagerForTradingTickers , // IReturnsManager returnsManagerForSignalingTickers , // DecoderForLinearRegressionTestingPositions // decoderForLinearRegressionTestingPositions , // ILinearRegressionFitnessEvaluator fitnessEvaluator , // GenomeManagerType genomeManagerType , // int seedForRandomGeneratorForTradingTickers , // int seedForRandomGeneratorForSignalingTickers ) : int minValueForTradingGene = genomeManagerForLinearRegression.GetMinValueForGenes( 1 ); Assert.AreEqual( -3 , minValueForTradingGene ); int maxValueForTradingGene = genomeManagerForLinearRegression.GetMaxValueForGenes( 1 ); Assert.AreEqual( 2 , maxValueForTradingGene ); int minValueForSignalingGene = genomeManagerForLinearRegression.GetMinValueForGenes( 2 ); Assert.AreEqual( -5 , minValueForSignalingGene ); int maxValueForSignalingGene = genomeManagerForLinearRegression.GetMaxValueForGenes( 2 ); Assert.AreEqual( 4 , maxValueForSignalingGene ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 17:05:32
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv14576/b7_scripts/linearRegression Added Files: TestEntryStrategyBasedOnForecastedReturn.cs Log Message: Test for the EntryStrategyBasedOnForecastedReturn class --- NEW FILE: TestEntryStrategyBasedOnForecastedReturn.cs --- /* QuantProject - Quantitative Finance Library TestEntryStrategyBasedOnForecastedReturn.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 NUnit.Framework; using NUnit.Mocks; using QuantProject.ADT.Econometrics; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; using QuantTesting.Business.DataProviders; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { internal class FakeLnrRgrssnTstngPstns : LinearRegressionTestingPositions { private ILinearRegression linearRegression; public override ILinearRegression LinearRegression { get { return this.linearRegression; } } internal FakeLnrRgrssnTstngPstns( ILinearRegression linearRegression , WeightedPositions tradingPortfolio ) : base( new WeightedPositions[ 0 ] , tradingPortfolio ) { this.linearRegression = linearRegression; } } [TestFixture] public class TestEntryStrategyBasedOnForecastedReturn { #region Test_GetPositionsToBeOpened private LinearRegressionTestingPositions getMockLinearRegressionTestingPositions( double[] linearRegressionCoefficients , WeightedPositions tradingPortfolio ) { DynamicMock dynamicMockLinearRegression = new DynamicMock( typeof( ILinearRegression ) ); dynamicMockLinearRegression.SetReturnValue( "get_EstimatedCoefficients" , linearRegressionCoefficients ); ILinearRegression mockLinearRegression = (ILinearRegression)dynamicMockLinearRegression.MockInstance; FakeLnrRgrssnTstngPstns mockLinearRegressionTestingPositions = new FakeLnrRgrssnTstngPstns( mockLinearRegression , tradingPortfolio ); return mockLinearRegressionTestingPositions; } [Test] public void Test_GetPositionsToBeOpened() { ReturnInterval outOfSampleReturnIntervalForTrading = new ReturnInterval( new DateTime( 2000 , 1 , 5 ) , new DateTime( 2000 , 1 , 6 ) ); HistoricalMarketValueProvider historicalMarketValueProvider = new FakeHistoricalMarketValueProvider(); DynamicMock dynamicMockReturnIntervalSelectorForSignaling = new DynamicMock( typeof( IReturnIntervalSelectorForSignaling ) ); ReturnInterval outOfSampleReturnIntervalForSignaling = new ReturnInterval( new DateTime( 2000 , 1 , 3 ) , new DateTime( 2000 , 1 , 4 ) ); dynamicMockReturnIntervalSelectorForSignaling.ExpectAndReturn( "GetReturnIntervalUsedForSignaling" , outOfSampleReturnIntervalForSignaling , new object[] { outOfSampleReturnIntervalForTrading } ); IReturnIntervalSelectorForSignaling fakeReturnIntervalSelectorForSignaling = (IReturnIntervalSelectorForSignaling) dynamicMockReturnIntervalSelectorForSignaling.MockInstance; LinearRegressionTestingPositions mockLinearRegressionTestingPositions1 = this.getMockLinearRegressionTestingPositions( new double[] { 1 , 2 , -3 } , new WeightedPositions( new double[] { 0.3 , -0.7 } , new string[] { "TA1" , "TB1" } ) ); LinearRegressionTestingPositions mockLinearRegressionTestingPositions2 = this.getMockLinearRegressionTestingPositions( new double[] { 1 , 0 , 2 } , new WeightedPositions( new double[] { 0.4 , -0.6 } , new string[] { "TA2" , "TB2" } ) ); LinearRegressionTestingPositions mockLinearRegressionTestingPositions3 = this.getMockLinearRegressionTestingPositions( new double[] { 0.5 , -1 , 3 } , new WeightedPositions( new double[] { 0.5 , 0.5 } , new string[] { "TA3" , "TB3" } ) ); TestingPositions[] mockBestTestingPositionsInSample = new LinearRegressionTestingPositions[ 3 ]; mockBestTestingPositionsInSample[ 0 ] = mockLinearRegressionTestingPositions1; mockBestTestingPositionsInSample[ 1 ] = mockLinearRegressionTestingPositions2; mockBestTestingPositionsInSample[ 2 ] = mockLinearRegressionTestingPositions3; DynamicMock dynamicMockLinearRegressionFitnessEvaluator = new DynamicMock( typeof( ILinearRegressionFitnessEvaluator ) ); dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn( "GetIndependentVariablesValues" , new double[] { 2 , 1 , 2 } , // forecasted // return should be 1*2+2*1-3*2=-2 (not selected) new object[] { mockLinearRegressionTestingPositions1 , outOfSampleReturnIntervalForSignaling , historicalMarketValueProvider } ); dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn( "GetIndependentVariablesValues" , new double[] { 0.1 , 3 , 0.2 } , // forecasted // return should be 1*0.1+0*3+2*0.2=0.5 (selected!!) new object[] { mockLinearRegressionTestingPositions2 , outOfSampleReturnIntervalForSignaling , historicalMarketValueProvider } ); dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn( "GetIndependentVariablesValues" , new double[] { 2 , 1 , 2 } , // forecasted // return should be 0.5*2-1*2+3*2=5 (not selected, because the previous one is selected) new object[] { mockLinearRegressionTestingPositions3 , outOfSampleReturnIntervalForSignaling , historicalMarketValueProvider } ); ILinearRegressionFitnessEvaluator mockLinearRegressionFitnessEvaluator= (ILinearRegressionFitnessEvaluator)dynamicMockLinearRegressionFitnessEvaluator.MockInstance; EntryStrategyBasedOnForecastedReturn longAndShortBasedOnForecastedReturn = new EntryStrategyBasedOnForecastedReturn( 0.3 , mockLinearRegressionFitnessEvaluator , fakeReturnIntervalSelectorForSignaling , historicalMarketValueProvider ); ReturnIntervals fakeOutOfSampleReturnIntervals = new ReturnIntervals( outOfSampleReturnIntervalForTrading ); WeightedPositions positionsToBeOpened = longAndShortBasedOnForecastedReturn.GetPositionsToBeOpened( mockBestTestingPositionsInSample , fakeOutOfSampleReturnIntervals ); Assert.AreEqual( "TA2" , positionsToBeOpened[ 0 ].Ticker ); Assert.AreEqual( "TB2" , positionsToBeOpened[ 1 ].Ticker ); } #endregion Test_GetPositionsToBeOpened } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:57:06
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12065/b7_scripts/linearRegression Added Files: TestDecoderForLinearRegressionTestingPositions.cs Log Message: Test for the class DecoderForLinearRegressionTestingPositions --- NEW FILE: TestDecoderForLinearRegressionTestingPositions.cs --- /* QuantProject - Quantitative Finance Library TestDecoderForLinearRegressionTestingPositions.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 NUnit.Framework; using NUnit.Mocks; using QuantTesting.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Test for the class DecoderForLinearRegressionTestingPositions /// </summary> [TestFixture] public class TestDecoderForLinearRegressionTestingPositions { #region TestDecode #region getReturnsManager #region getFakeHistoricalMarketValueProviderValueBased #region addMarketValue private double getMarketValue( int day ) { double marketValue = 0; switch ( day ) { case 1: marketValue = 31; break; case 2: marketValue = 32; break; case 3: marketValue = 33; break; } return marketValue; } private void addMarketValue( string ticker , DateTime dateTime , FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider ) { if ( !fakeHistoricalMarketValueProvider.WasExchanged( ticker , dateTime ) ) { // this market values has not been added yet double marketValue = this.getMarketValue( dateTime.Day ); fakeHistoricalMarketValueProvider.Add( ticker , dateTime , marketValue ); } } #endregion addMarketValue private void addMarketValues( string[] tickers , ReturnInterval returnInterval1 , ReturnInterval returnInterval2 , FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider ) { foreach( string ticker in tickers ) { this.addMarketValue( ticker , returnInterval1.Begin , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval1.End , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval2.Begin , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval2.End , fakeHistoricalMarketValueProvider ); } } private FakeHistoricalMarketValueProvider getFakeHistoricalMarketValueProviderValueBased( string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling , ReturnInterval returnInterval1 , ReturnInterval returnInterval2 ) { FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = new FakeHistoricalMarketValueProvider(); this.addMarketValues( eligibleTickersForTrading , returnInterval1 , returnInterval2 , fakeHistoricalMarketValueProvider ); this.addMarketValues( eligibleTickersForSignaling , returnInterval1 , returnInterval2 , fakeHistoricalMarketValueProvider ); return fakeHistoricalMarketValueProvider; } #endregion getFakeHistoricalMarketValueProviderValueBased private ReturnsManager getReturnsManager( string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling ) { ReturnInterval returnInterval1 = new ReturnInterval( new DateTime( 2008 , 2 , 1 , 16 , 0 , 0 ) , new DateTime( 2008 , 2 , 2 , 16 , 0 , 0 ) ); ReturnInterval returnInterval2 = new ReturnInterval( new DateTime( 2008 , 2 , 2 , 16 , 0 , 0 ) , new DateTime( 2008 , 2 , 3 , 16 , 0 , 0 ) ); ReturnIntervals returnIntervals = new ReturnIntervals( returnInterval1 ); returnIntervals.Add( returnInterval2 ); FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = this.getFakeHistoricalMarketValueProviderValueBased( eligibleTickersForTrading , eligibleTickersForSignaling , returnInterval1 , returnInterval2 ); ReturnsManager returnsManager = new ReturnsManager( returnIntervals , fakeHistoricalMarketValueProvider ); return returnsManager; } #endregion getReturnsManager [Test] public void TestDecode() { DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = new DecoderForLinearRegressionTestingPositions( 3 ); Assert.AreEqual( 2 , decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading ); Assert.AreEqual( 3 , decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios ); EligibleTickers eligibleTickersForTrading = new EligibleTickers( new string[] { "TA" , "TB" , "TC" } ); EligibleTickers eligibleTickersForSignaling = new EligibleTickers( new string[] { "SA" , "SB" , "SC" , "SD" , "SE" } ); // Genome genome = this.getGenome(); // eligibleTickersForTrading , // eligibleTickersForSignaling , // decoderForLinearRegressionTestingPositions ); ReturnsManager returnsManager = this.getReturnsManager( eligibleTickersForTrading.Tickers , eligibleTickersForSignaling.Tickers ); LinearRegressionTestingPositions meaning = (LinearRegressionTestingPositions) decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , -5 , 2 , 0 } , eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); // returnsManagerForTradingTickers , returnsManagerForSignalingTickers ); // the genome corresponds to { "TA" , "-TC" , "-SE" , "SC" , "SA" } // then weighted positions for trading are { "TA" , "-TC" } // and weighted positions for signaling are { "-SE" , "SC" , "SA" } // test trading portfolio Assert.AreEqual( 2 , meaning.TradingPortfolio.Count ); Assert.AreEqual( "TA" , meaning.TradingPortfolio[ 0 ].Ticker ); Assert.IsTrue( meaning.TradingPortfolio[ 0 ].Weight > 0 , "meaning.TradingPortfolio[ 0 ].Weight > 0" ); Assert.AreEqual( "TC" , meaning.TradingPortfolio[ 1 ].Ticker ); Assert.IsTrue( meaning.TradingPortfolio[ 1 ].Weight < 0 , "meaning.TradingPortfolio[ 1 ].Weight < 0" ); // test signaling portfolio Assert.AreEqual( 3 , meaning.SignalingPortfolios.Length ); WeightedPositions signalingPortfolio0 = meaning.SignalingPortfolios[ 0 ]; Assert.AreEqual( 1 , signalingPortfolio0.Count , "signalingPortfolio0.Count" ); Assert.AreEqual( "SE" , signalingPortfolio0[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio0[ 0 ].Weight < 0 , "signalingPortfolio0[ 0 ].Weight < 0" ); WeightedPositions signalingPortfolio1 = meaning.SignalingPortfolios[ 1 ]; Assert.AreEqual( 1 , signalingPortfolio1.Count , "signalingPortfolio1.Count" ); Assert.AreEqual( "SC" , signalingPortfolio1[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio1[ 0 ].Weight > 0 , "signalingPortfolio1[ 1 ].Weight > 0" ); WeightedPositions signalingPortfolio2 = meaning.SignalingPortfolios[ 2 ]; Assert.AreEqual( 1 , signalingPortfolio2.Count , "signalingPortfolio2.Count" ); Assert.AreEqual( "SA" , signalingPortfolio2[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio2[ 0 ].Weight > 0 , "signalingPortfolio2[ 1 ].Weight > 0" ); } #endregion TestDecode [Test] public void TestDuplicatedTickers() { EligibleTickers eligibleTickersForTrading = new EligibleTickers( new string[] { "TA" , "TB" , "TC" } ); EligibleTickers eligibleTickersForSignaling = new EligibleTickers( new string[] { "SA" , "SB" , "SC" , "SD" , "TA" } ); DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = new DecoderForLinearRegressionTestingPositions( 3 ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); IReturnsManager returnsManager = (IReturnsManager)dynamicMockForReturnsManager.MockInstance; TestingPositions testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , 0 , 1 , -3 , 3 } , // same ticker for trading (first and second) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , -4 , -4 , 0 } , // same ticker for signaling (third and fourth) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded , "same ticker for signaling (third and fourth)" ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 0 , 1 , -2 } , // same ticker for signaling (fourth and fifth) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded , "same ticker for signaling (fourth and fifth)" ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 1 , -3 , -5 } , // same ticker for the first trading ticker and for the third signaling portfolio eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsFalse( testingPositions is TestingPositionsForUndecodableEncoded , "same ticker for the first trading ticker and for the third signaling portfolio" ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 1 , -3 , 3 } , // no conflict eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsFalse( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { -3 , 0 , 1 , -3 , -5 } , // no conflict even if the second ticker is the same as the fifth one eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsFalse( testingPositions is TestingPositionsForUndecodableEncoded ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:56:45
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11987/b7_scripts/linearRegression Added Files: TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs Log Message: Test for the class DecoderFirstTradingTickerInEachSignalingPortfolio --- NEW FILE: TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs --- /* QuantProject - Quantitative Finance Library TestDecoderFirstTradingTickerInEachSignalingPortfolio.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 NUnit.Framework; using NUnit.Mocks; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; //using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Scripts.WalkForwardTesting.LinearRegression; using QuantTesting.ADT.Optimizing.Genetic; using QuantTesting.Business.DataProviders; namespace QuantTesting.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Test for the class DecoderFirstTradingTickerInEachSignalingPortfolio /// </summary> [TestFixture] public class TestDecoderFirstTradingTickerInEachSignalingPortfolio { #region TestDecode #region getReturnsManager #region getFakeHistoricalMarketValueProviderValueBased #region addMarketValue private double getMarketValue( int day ) { double marketValue = 0; switch ( day ) { case 1: marketValue = 31; break; case 2: marketValue = 32; break; case 3: marketValue = 33; break; } return marketValue; } private void addMarketValue( string ticker , DateTime dateTime , FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider ) { if ( !fakeHistoricalMarketValueProvider.WasExchanged( ticker , dateTime ) ) { // this market values has not been added yet double marketValue = this.getMarketValue( dateTime.Day ); fakeHistoricalMarketValueProvider.Add( ticker , dateTime , marketValue ); } } #endregion addMarketValue private void addMarketValues( string[] tickers , ReturnInterval returnInterval1 , ReturnInterval returnInterval2 , FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider ) { foreach( string ticker in tickers ) { this.addMarketValue( ticker , returnInterval1.Begin , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval1.End , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval2.Begin , fakeHistoricalMarketValueProvider ); this.addMarketValue( ticker , returnInterval2.End , fakeHistoricalMarketValueProvider ); } } private FakeHistoricalMarketValueProvider getFakeHistoricalMarketValueProviderValueBased( string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling , ReturnInterval returnInterval1 , ReturnInterval returnInterval2 ) { FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = new FakeHistoricalMarketValueProvider(); this.addMarketValues( eligibleTickersForTrading , returnInterval1 , returnInterval2 , fakeHistoricalMarketValueProvider ); this.addMarketValues( eligibleTickersForSignaling , returnInterval1 , returnInterval2 , fakeHistoricalMarketValueProvider ); return fakeHistoricalMarketValueProvider; } #endregion getFakeHistoricalMarketValueProviderValueBased private ReturnsManager getReturnsManager( string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling ) { ReturnInterval returnInterval1 = new ReturnInterval( new DateTime( 2008 , 2 , 1 , 16 , 0 , 0 ) , new DateTime( 2008 , 2 , 2 , 16 , 0 , 0 ) ); ReturnInterval returnInterval2 = new ReturnInterval( new DateTime( 2008 , 2 , 2 , 16 , 0 , 0 ) , new DateTime( 2008 , 2 , 3 , 16 , 0 , 0 ) ); ReturnIntervals returnIntervals = new ReturnIntervals( returnInterval1 ); returnIntervals.Add( returnInterval2 ); FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = this.getFakeHistoricalMarketValueProviderValueBased( eligibleTickersForTrading , eligibleTickersForSignaling , returnInterval1 , returnInterval2 ); ReturnsManager returnsManager = new ReturnsManager( returnIntervals , fakeHistoricalMarketValueProvider ); return returnsManager; } #endregion getReturnsManager [Test] public void TestDecode() { DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = new DecoderFirstTradingTickerInEachSignalingPortfolio( 3 ); Assert.AreEqual( 2 , decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading ); Assert.AreEqual( 3 , decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios ); EligibleTickers eligibleTickersForTrading = new EligibleTickers( new string[] { "TA" , "TB" , "TC" } ); EligibleTickers eligibleTickersForSignaling = new EligibleTickers( new string[] { "SA" , "SB" , "SC" , "SD" , "SE" } ); // Genome genome = this.getGenome(); // eligibleTickersForTrading , // eligibleTickersForSignaling , // decoderForLinearRegressionTestingPositions ); ReturnsManager returnsManager = this.getReturnsManager( eligibleTickersForTrading.Tickers , eligibleTickersForSignaling.Tickers ); LinearRegressionTestingPositions meaning = (LinearRegressionTestingPositions) decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , -5 , 2 , 0 } , eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); // returnsManagerForTradingTickers , returnsManagerForSignalingTickers ); // the genome corresponds to { "TA" , "-TC" , "-SE" , "SC" , "SA" } // then weighted positions for trading are { "TA" , "-TC" } // and weighted positions for signaling are { "-SE" , "SC" , "SA" } // test trading portfolio Assert.AreEqual( 2 , meaning.TradingPortfolio.Count ); Assert.AreEqual( "TC" , meaning.TradingPortfolio[ 1 ].Ticker ); Assert.IsTrue( meaning.TradingPortfolio[ 1 ].Weight < 0 , "meaning.TradingPortfolio[ 1 ].Weight < 0" ); // test signaling portfolio Assert.AreEqual( 3 , meaning.SignalingPortfolios.Length ); WeightedPositions signalingPortfolio0 = meaning.SignalingPortfolios[ 0 ]; Assert.AreEqual( "TA" , signalingPortfolio0[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio0[ 0 ].Weight > 0 , "signalingPortfolio0[ 0 ].Weight > 0" ); Assert.AreEqual( "SE" , signalingPortfolio0[ 1 ].Ticker ); Assert.IsTrue( signalingPortfolio0[ 1 ].Weight < 0 , "signalingPortfolio0[ 1 ].Weight < 0" ); WeightedPositions signalingPortfolio1 = meaning.SignalingPortfolios[ 1 ]; Assert.AreEqual( "TA" , signalingPortfolio1[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio1[ 0 ].Weight > 0 , "signalingPortfolio1[ 1 ].Weight > 0" ); Assert.AreEqual( "SC" , signalingPortfolio1[ 1 ].Ticker ); Assert.IsTrue( signalingPortfolio1[ 1 ].Weight > 0 , "signalingPortfolio1[ 1 ].Weight > 0" ); WeightedPositions signalingPortfolio2 = meaning.SignalingPortfolios[ 2 ]; Assert.AreEqual( "TA" , signalingPortfolio2[ 0 ].Ticker ); Assert.IsTrue( signalingPortfolio2[ 0 ].Weight > 0 , "signalingPortfolio2[ 1 ].Weight > 0" ); Assert.AreEqual( "SA" , signalingPortfolio2[ 1 ].Ticker ); Assert.IsTrue( signalingPortfolio2[ 1 ].Weight > 0 , "signalingPortfolio2[ 1 ].Weight > 0" ); } #endregion TestDecode [Test] public void TestDuplicatedTickers() { EligibleTickers eligibleTickersForTrading = new EligibleTickers( new string[] { "TA" , "TB" , "TC" } ); EligibleTickers eligibleTickersForSignaling = new EligibleTickers( new string[] { "SA" , "SB" , "SC" , "SD" , "TA" } ); DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = new DecoderFirstTradingTickerInEachSignalingPortfolio( 3 ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); IReturnsManager returnsManager = (IReturnsManager)dynamicMockForReturnsManager.MockInstance; TestingPositions testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , 0 , 1 , -3 , 3 } , // same ticker for trading (first and second) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , -4 , -4 , 0 } , // same ticker for signaling (third and fourth) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 0 , 1 , -2 } , // same ticker for signaling (fourth and fifth) eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 1 , -3 , -5 } , // same ticker for the first trading ticker and for the third signaling portfolio eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsTrue( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { 0 , -3 , 1 , -3 , 3 } , // no conflict eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsFalse( testingPositions is TestingPositionsForUndecodableEncoded ); testingPositions = decoderForLinearRegressionTestingPositions.Decode( new int[] { -3 , 0 , 1 , -3 , -5 } , // no conflict even if the second ticker is the same as the fifth one eligibleTickersForTrading , eligibleTickersForSignaling , returnsManager , returnsManager ); Assert.IsFalse( testingPositions is TestingPositionsForUndecodableEncoded ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:56:27
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/ReturnsManagment/Time In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11907/b4_Business/a2_Strategies/ReturnsManagment/Time Added Files: TestReturnIntervals.cs Log Message: Unit test for the QuantProject.Business.Strategies.ReturnsManagement.Time.ReturnIntervals class --- NEW FILE: TestReturnIntervals.cs --- /* QuantProject - Quantitative Finance Library TestReturnIntervals.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 NUnit.Framework; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantTesting.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Unit test for the QuantProject.Business.Strategies.ReturnsManagement.Time.ReturnIntervals /// class /// </summary> [TestFixture] public class TestReturnIntervals { #region TestMethod private ReturnIntervals getReturnIntervals() { ReturnInterval firstReturnInterval = new ReturnInterval( new DateTime( 2010 , 1 , 1 , 9 , 30 , 0 ) , new DateTime( 2010 , 1 , 1 , 16 , 0 , 0 ) ); ReturnInterval secondReturnInterval = new ReturnInterval( new DateTime( 2010 , 1 , 1 , 16 , 0 , 0 ) , new DateTime( 2010 , 1 , 2 , 9 , 30 , 0 ) ); ReturnIntervals returnIntervals = new ReturnIntervals(); returnIntervals.Add( firstReturnInterval); returnIntervals.Add( secondReturnInterval ); return returnIntervals; } [Test] public void TestMethod() { ReturnIntervals returnIntervals = this.getReturnIntervals(); ReturnInterval secondLastInterval = returnIntervals.SeconLastInterval; Assert.AreEqual( new DateTime( 2010 , 1 , 1 , 16 , 0 , 0 ) , secondLastInterval.End ); } #endregion TestMethod } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:56:07
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Optimizing/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11732/b4_Business/a2_Strategies/Optimizing/Decoding Added Files: TestBasicDecoderForTestingPositions.cs Log Message: Test for the QuantProject.Business.Strategies.Optimizing.Decoding.BasicDecoderForTestingPositions class --- NEW FILE: TestBasicDecoderForTestingPositions.cs --- /* QuantProject - Quantitative Finance Library TestBasicDecoderForTestingPositions.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 NUnit.Framework; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantTesting.Business.DataProviders; namespace QuantTesting.Business.Strategies.Optimizing.Decoding { [TestFixture] /// <summary> /// Test for the QuantProject.Business.Strategies.Optimizing.Decoding.BasicDecoderForTestingPositions /// class /// </summary> public class TestBasicDecoderForTestingPositions { #region TestMethod private ReturnsManager getReturnsManager() { ReturnInterval returnInterval = new ReturnInterval( new DateTime( 2008 , 2 , 1 , 16 , 0 , 0 ) , new DateTime( 2008 , 2 , 3 , 16 , 0 , 0 ) ); ReturnIntervals returnIntervals = new ReturnIntervals( returnInterval ); FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProvider = new FakeHistoricalMarketValueProvider(); ReturnsManager returnsManager = new ReturnsManager( returnIntervals , fakeHistoricalMarketValueProvider ); return returnsManager; } [Test] public void TestMethod() { EligibleTickers eligibleTickers = new EligibleTickers( new string[] { "AAAA" , "BBBB" , "CCCC" , "DDDD" } ); int[] encoded = { -4 , 0 , 1 }; BasicDecoderForTestingPositions basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); ReturnsManager returnsManager = this.getReturnsManager(); WeightedPositions weightedPositions = basicDecoderForTestingPositions.Decode( encoded , eligibleTickers , returnsManager ).WeightedPositions; Assert.AreEqual( "DDDD" , weightedPositions[ 0 ].Ticker ); Assert.AreEqual( -0.333333 , weightedPositions[ 0 ].Weight , 0.001 ); Assert.AreEqual( "BBBB" , weightedPositions[ 2 ].Ticker , "weightedPositions[ 2 ].Ticker" ); Assert.AreEqual( 0.333333 , weightedPositions[ 2 ].Weight , 0.001 ); Assert.AreEqual( "DDDD" , weightedPositions.SignedTickers[ 0 ].Ticker , "weightedPositions.SignedTickers[ 0 ].Ticker" ); Assert.AreEqual( "AAAA" , weightedPositions.SignedTickers[ 1 ].Ticker , "weightedPositions.SignedTickers[ 1 ].Ticker" ); } #endregion TestMethod } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:54:45
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11493/b4_Business/a2_Strategies/Eligibles Added Files: TestOftenExchanged.cs Log Message: Test for the QuantProject.Business.Strategies.Eligibles.OftenExchanged class --- NEW FILE: TestOftenExchanged.cs --- /* QuantProject - Quantitative Finance Library TestOftenExchanged.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 NUnit.Framework; using NUnit.Mocks; using QuantProject.ADT.Histories; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Data.Selectors; using QuantTesting.Business.DataProviders; namespace QuantTesting.Business.Strategies.Eligibles { [TestFixture] /// <summary> /// Test for the QuantProject.Business.Strategies.Eligibles.OftenExchanged class /// </summary> public class TestOftenExchanged { #region Test_GetEligibleTickers private History getHistory() { History history = new History(); history.Add( new DateTime( 2010 , 1 , 1 ) , null ); history.Add( new DateTime( 2010 , 1 , 2 ) , null ); history.Add( new DateTime( 2010 , 1 , 3 ) , null ); return history; } private IHistoricalMarketValueProvider getHistoricalMarketValueProvider( History history ) { FakeHistoricalMarketValueProvider fakeHistoricalMarketValueProviderValueBased = new FakeHistoricalMarketValueProvider(); fakeHistoricalMarketValueProviderValueBased.Add( "A" , (DateTime)history.GetKey( 0 ) , 1 ); fakeHistoricalMarketValueProviderValueBased.Add( "A" , (DateTime)history.GetKey( 1 ) , 1 ); fakeHistoricalMarketValueProviderValueBased.Add( "A" , (DateTime)history.GetKey( 2 ) , 1 ); fakeHistoricalMarketValueProviderValueBased.Add( "B" , (DateTime)history.GetKey( 0 ) , 1 ); // fakeHistoricalMarketValueProviderValueBased.Add( // "B" , (DateTime)history.GetKey( 1 ) , 1 ); // fakeHistoricalMarketValueProviderValueBased.Add( // "B" , (DateTime)history.GetKey( 2 ) , 1 ); fakeHistoricalMarketValueProviderValueBased.Add( "C" , (DateTime)history.GetKey( 0 ) , 1 ); // fakeHistoricalMarketValueProviderValueBased.Add( // "C" , (DateTime)history.GetKey( 1 ) , 1 ); fakeHistoricalMarketValueProviderValueBased.Add( "C" , (DateTime)history.GetKey( 2 ) , 1 ); return fakeHistoricalMarketValueProviderValueBased; } [Test] public void Test_GetEligibleTickers() { // the ticker "A" has 100% of the quotes // the ticker "B" has 33.3333% of the quotes // the ticker "C" has 66.6666% of the quotes DynamicMock dynamicMockTickerSelectorByGroup = new DynamicMock( typeof( ITickerSelectorByGroup ) ); dynamicMockTickerSelectorByGroup.SetReturnValue( "GetSelectedTickers" , new List<string>( new string[] { "A" , "B" , "C" } ) ); ITickerSelectorByGroup mockTickerSelectorByGroup = (ITickerSelectorByGroup)dynamicMockTickerSelectorByGroup.MockInstance; History history = this.getHistory(); IHistoricalMarketValueProvider historicalMarketValueProvider = this.getHistoricalMarketValueProvider( history ); OftenExchanged oftenExchangedFor100Percent = new OftenExchanged( "dummy" , // the mock tickerSelectorByGroup doesn't use this group id mockTickerSelectorByGroup , historicalMarketValueProvider , 1 ); EligibleTickers eligibleTickers = oftenExchangedFor100Percent.GetEligibleTickers( history ); Assert.AreEqual( 1 , eligibleTickers.Count ); Assert.IsTrue( eligibleTickers.Tickers[ 0 ] == "A" ); OftenExchanged oftenExchangedFor70Percent = new OftenExchanged( "dummy" , // the mock tickerSelectorByGroup doesn't use this group id mockTickerSelectorByGroup , historicalMarketValueProvider , 0.7 ); eligibleTickers = oftenExchangedFor70Percent.GetEligibleTickers( history ); Assert.AreEqual( 1 , eligibleTickers.Count ); Assert.IsTrue( eligibleTickers.Tickers[ 0 ] == "A" ); OftenExchanged oftenExchangedFor50Percent = new OftenExchanged( "dummy" , // the mock tickerSelectorByGroup doesn't use this group id mockTickerSelectorByGroup , historicalMarketValueProvider , 0.5 ); eligibleTickers = oftenExchangedFor50Percent.GetEligibleTickers( history ); Assert.AreEqual( 2 , eligibleTickers.Count ); Assert.IsTrue( eligibleTickers.Tickers[ 0 ] == "A" ); Assert.IsTrue( eligibleTickers.Tickers[ 1 ] == "C" ); OftenExchanged oftenExchangedFor30Percent = new OftenExchanged( "dummy" , // the mock tickerSelectorByGroup doesn't use this group id mockTickerSelectorByGroup , historicalMarketValueProvider , 0.3 ); eligibleTickers = oftenExchangedFor30Percent.GetEligibleTickers( history ); Assert.AreEqual( 3 , eligibleTickers.Count ); Assert.IsTrue( eligibleTickers.Tickers[ 0 ] == "A" ); Assert.IsTrue( eligibleTickers.Tickers[ 1 ] == "B" ); Assert.IsTrue( eligibleTickers.Tickers[ 2 ] == "C" ); } #endregion Test_GetEligibleTickers } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:53:08
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b3_data/Selectors In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11006/b3_data/Selectors Added Files: TestTickerSelector.cs Log Message: Unit test for the QuantProject.Data.Selectors.TickerSelector class --- NEW FILE: TestTickerSelector.cs --- /* QuantProject - Quantitative Finance Library TestTickerSelector.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.Data; using NUnit.Framework; using QuantProject.Data.Selectors; namespace QuantTesting.Data.Selectors { [TestFixture] public class TestTickerSelector { /// <summary> /// Unit test for the QuantProject.Data.Selectors.TickerSelector class /// </summary> [Test] public void TestMethod() { string[] tickers = { "AAAA" , "BBBB" , "CCCC" }; DataTable dataTableForTickerSelectors = TickerSelector.GetDataTableForTickerSelectors( tickers ); DataRow dataRow = dataTableForTickerSelectors.Rows[ 1 ]; Assert.AreEqual( "BBBB" , dataRow[ 0 ] ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:52:43
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/LinearAlgebra In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv10901/b1_ADT/LinearAlgebra Added Files: TestLinearSystemSolver.cs Log Message: Test for the class QuantProject.ADT.LinearAlgebra.LinearSystemSolver --- NEW FILE: TestLinearSystemSolver.cs --- /* * Created by SharpDevelop. * User: Glauco * Date: 3/21/2010 * Time: 8:10 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using NUnit.Framework; using QuantProject.ADT.LinearAlgebra; namespace QuantTesting.ADT.LinearAlgebra { [TestFixture] /// <summary> /// Test for the class QuantProject.ADT.LinearAlgebra.LinearSystemSolver /// </summary> public class TestLinearSystemSolver { [Test] public void TestMethod() { double[,] A = new double[ 3 , 3 ] { { 0 , 1 , 1 } , { 2 , 0 , 3 } , { 1 , 1 , 1 } }; double[] b = new double[ 3 ] { 2 , 5 , 3 }; double[] solution = LinearSystemSolver.FindSolution( A , b ); Assert.AreEqual( 1 , solution[ 0 ] ); Assert.AreEqual( 1 , solution[ 1 ] ); Assert.AreEqual( 1 , solution[ 2 ] ); } [Test] public void TestMethod1() { double[,] A = new double[ 3 , 3 ] { { 2 , 1 , -1 } , { -3 , -1 , 2 } , { -2 , 1 , 2 } }; double[] b = new double[ 3 ] { 8 , -11 , -3 }; double[] solution = LinearSystemSolver.FindSolution( A , b ); Assert.AreEqual( 2 , solution[ 0 ] ); Assert.AreEqual( 3 , solution[ 1 ] ); Assert.AreEqual( -1 , solution[ 2 ] , 0.0000001 ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:40:43
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/Econometrics In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8141/b1_ADT/Econometrics Added Files: TestLinearRegression.cs Log Message: Test for the class QuantProject.ADT.Econometrics.LinearRegression --- NEW FILE: TestLinearRegression.cs --- /* QuantProject - Quantitative Finance Library TestLinearRegression.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 NUnit.Framework; using QuantProject.ADT.Econometrics; namespace QuantTesting.ADT.Econometrics { [TestFixture] /// <summary> /// Test for the class QuantProject.ADT.Econometrics.LinearRegression /// </summary> public class TestLinearRegression { [Test] public void TestMethod() { double[] y = new double[] { 20.10 , 13.30 , 24.40 , 24.95 }; double[,] X = new double[,] { { 1 , 1 , 4 } , { 1 , 3 , 1 } , { 1 , 5 , 3 } , { 1 , 7 , 2 } }; // double[,] X = new double[,] { // { 1 , 1 , 1 , 1 } , // { 1 , 3 , 5 , 7 } , // { 4 , 1 , 3 , 2 } }; // double[] weights = new double[] { 1 , 1 , 1 , 1 }; LinearRegression linearRegression = new LinearRegression(); linearRegression.RunRegression( y , X ); Assert.AreEqual( 3.728571429 , linearRegression.EstimatedCoefficients[ 0 ] , 0.00000001 ); Assert.AreEqual( 1.999404762 , linearRegression.EstimatedCoefficients[ 1 ] , 0.00000001 ); Assert.AreEqual( 3.58452381 , linearRegression.EstimatedCoefficients[ 2 ] , 0.00000001 ); Assert.AreEqual( 0.999876323 , linearRegression.CenteredRSquare , 0.0000000001 ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:37:49
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/a5_FakeImplementations In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv7364/a5_FakeImplementations Added Files: FakeHistoricalMarketValueProvider.cs Log Message: Implements a fake HistoricalMarketValueProvider, where market values are given by the Add method --- NEW FILE: FakeHistoricalMarketValueProvider.cs --- /* QuantProject - Quantitative Finance Library FakeHistoricalMarketValueProvider.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; using QuantProject.Business.DataProviders; namespace QuantTesting.Business.DataProviders { /// <summary> /// Implements a fake HistoricalMarketValueProvider, where /// market values are given by the Add method /// </summary> public class FakeHistoricalMarketValueProvider : HistoricalMarketValueProvider { private Hashtable marketValues; public FakeHistoricalMarketValueProvider() { this.marketValues = new Hashtable(); } protected override string getDescription() { return "fake"; } public override bool WasExchanged(string ticker, DateTime dateTime) { bool containsDateTime = this.marketValues.ContainsKey( dateTime ); Hashtable marketValues = (Hashtable)this.marketValues[ dateTime ] ; bool wasExchanged = ( this.marketValues.ContainsKey( dateTime ) && ( (Hashtable)this.marketValues[ dateTime ] ).ContainsKey( ticker ) ); return wasExchanged; } #region GetMarketValue public override double GetMarketValue( string ticker , DateTime dateTime ) { if ( !this.marketValues.ContainsKey( dateTime ) ) throw new Exception( "There are no quotes for DateTime " + dateTime.ToString() ); if ( !( (Hashtable)this.marketValues[ dateTime ] ).ContainsKey( ticker ) ) throw new Exception( "There are no quotes for the ticker " + ticker + "at the DateTime " + dateTime.ToString() ); // quote is not present double marketValue = (double)( ( (Hashtable)this.marketValues[ dateTime ] )[ ticker ] ); return marketValue; } #endregion GetMarketValue // // public History GetMarketValues( string ticker , History history ) // { // eaer // } public void Add( string ticker , DateTime dateTime , double marketValue ) { if ( !this.marketValues.ContainsKey( dateTime ) ) this.marketValues.Add( dateTime , new Hashtable() ); ( (Hashtable)this.marketValues[ dateTime ] ).Add( ticker , marketValue ); } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:37:28
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/a5_FakeImplementations In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv7289/a5_FakeImplementations Added Files: FakeGenomeManager.cs Log Message: Fake genome manager --- NEW FILE: FakeGenomeManager.cs --- /* QuantProject - Quantitative Finance Library FakeGenomeManager.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; namespace QuantTesting.ADT.Optimizing.Genetic { /// <summary> /// Fake genome manager /// </summary> public class FakeGenomeManager : IGenomeManager { private int genomeSize; public int GenomeSize{ get { return this.genomeSize; }} public FakeGenomeManager( int genomeSize ) { this.genomeSize = genomeSize; } public int GetMaxValueForGenes(int genePosition) { return 10000; } public int GetMinValueForGenes(int genePosition) { return -10000; } public int GetNewGeneValue(Genome genome, int genePosition) { return 3; } public object Decode(Genome genome) { return null; } public double GetFitnessValue(Genome genome) { return 0; } public Genome[] GetChilds(Genome parent1, Genome parent2) { return null; } public void Mutate(Genome genome) { ; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:33:10
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv6359/linearRegression Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:32:37
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv6278/b7_scripts Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:29:36
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/ReturnsManagment/Time In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5503/Time Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/ReturnsManagment/Time added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:29:28
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/ReturnsManagment In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5473/ReturnsManagment Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/ReturnsManagment added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:29:07
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Optimizing/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5335/Decoding Log Message: Directory /cvsroot/quantproject/QuantProject/t5_Testing/b4_Business/a2_Strategies/Optimizing/Decoding added to the repository |