quantproject-developers Mailing List for QuantProject (Page 5)
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...> - 2011-08-21 09:54:24
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing
In directory vz-cvs-3.sog:/tmp/cvs-serv25815
Added Files:
DayOfMonth.cs
Log Message:
Added struct DayOfMonth, representing a specific day in a specific month (for any possible year)
--- NEW FILE: DayOfMonth.cs ---
/*
QuantProject - Quantitative Finance Library
DayOfMonth.cs
Copyright (C) 2011
Marco Milletti
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
namespace QuantProject.ADT.Timing
{
/// <summary>
/// Represents a specific day in a specific month (for any possible year)
/// </summary>
[Serializable]
public struct DayOfMonth : IEquatable<DayOfMonth>
{
DateTime standardDateTime;
public int Month
{
get { return this.standardDateTime.Month; }
}
public int Day
{
get { return this.standardDateTime.Day; }
}
//Represents a specific day in a specific month (for any possible year)
public DayOfMonth( DateTime dateTime )
{
this.standardDateTime =
new DateTime(
2000 , dateTime.Month , dateTime.Day , 0 , 0 , 0 );
}
//Represents a specific day in a specific month (for any possible year)
public DayOfMonth( int month , int day )
{
this.standardDateTime =
new DateTime( 2000 , month , day , 0 , 0 , 0 );
}
public DayOfMonth AddDays( int days )
{
DateTime standardDateTimeForResult = this.standardDateTime.AddDays( days );
DayOfMonth dayOfMonth = new DayOfMonth( standardDateTimeForResult );
return dayOfMonth;
}
#region Equals and GetHashCode implementation
// The code in this region is useful if you want to use this structure in collections.
// If you don't need it, you can just remove the region and the ": IEquatable<DayOfMonth>" declaration.
public override bool Equals(object obj)
{
if (obj is Date)
return Equals((Date)obj); // use Equals method below
else
return false;
}
public bool Equals(DayOfMonth other)
{
// add comparisions for all members here
return ( (this.standardDateTime.Month == other.standardDateTime.Month) &&
(this.standardDateTime.Day == other.standardDateTime.Day) );
}
public override int GetHashCode()
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
return standardDateTime.GetHashCode();
}
public static bool operator ==(DayOfMonth lhs, DayOfMonth rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(DayOfMonth lhs, DayOfMonth rhs)
{
return !(lhs.Equals(rhs)); // use operator == and negate result
}
public static bool operator <=(DayOfMonth lhs, DayOfMonth rhs)
{
bool isLessThanOrEqual =
( lhs.standardDateTime <= rhs.standardDateTime );
return isLessThanOrEqual;
}
public static bool operator >=(DayOfMonth lhs, DayOfMonth rhs)
{
bool isGreaterThanOrEqual =
( lhs.standardDateTime >= rhs.standardDateTime );
return isGreaterThanOrEqual;
}
public static bool operator <(DayOfMonth lhs, DayOfMonth rhs)
{
bool isLessThan =
( lhs.standardDateTime < rhs.standardDateTime );
return isLessThan;
}
public static bool operator >(DayOfMonth lhs, DayOfMonth rhs)
{
bool isGreaterThan =
( lhs.standardDateTime > rhs.standardDateTime );
return isGreaterThan;
}
#endregion
}
}
|
|
From: Marco M. <mi...@us...> - 2011-08-21 09:52:42
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic
In directory vz-cvs-3.sog:/tmp/cvs-serv25736/Genetic
Modified Files:
GeneticOptimizer.cs Genome.cs NewGenerationEventArgs.cs
Log Message:
Some minor bugs have been fixed, in order to have more (and more correct) information in log files
Index: Genome.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Genome.cs 27 Mar 2010 17:15:54 -0000 1.21
--- Genome.cs 21 Aug 2011 09:52:40 -0000 1.22
***************
*** 164,167 ****
--- 164,172 ----
}
+ private void clone_copyValuesInGenes(int[] valuesToBeCopied)
+ {
+ for (int i = 0 ; i < this.size ; i++)
+ this.genes[i] = valuesToBeCopied[i];
+ }
/// <summary>
***************
*** 171,175 ****
{
Genome returnValue = new Genome(this.genomeManager, this.geneticOptimizer);
! returnValue.CopyValuesInGenes(this.genes);
returnValue.setFitnessValue(this.fitness);
returnValue.meaning = this.meaning;
--- 176,180 ----
{
Genome returnValue = new Genome(this.genomeManager, this.geneticOptimizer);
! returnValue.clone_copyValuesInGenes(this.genes);
returnValue.setFitnessValue(this.fitness);
returnValue.meaning = this.meaning;
***************
*** 185,196 ****
}
! public void CopyValuesInGenes(int[] valuesToBeCopied)
! {
! for (int i = 0 ; i < this.size ; i++)
! this.genes[i] = valuesToBeCopied[i];
! //whenever at least one gene has been written,
! //the current generation number is stored
! this.generation = this.geneticOptimizer.GenerationCounter;
! }
public void SetGeneValue(int geneValue, int genePosition)
--- 190,223 ----
}
! // //old implementation
! // public void CopyValuesInGenes(int[] valuesToBeCopied)
! // {
! // for (int i = 0 ; i < this.size ; i++)
! // this.genes[i] = valuesToBeCopied[i];
! // //whenever at least one gene has been written,
! // //the current generation number is stored
! // this.generation = this.geneticOptimizer.GenerationCounter;
! // }
!
! // //old implementation
! // public void SetGeneValue(int geneValue, int genePosition)
! // {
! // if(geneValue < this.GetMinValueForGenes(genePosition) ||
! // geneValue > this.GetMaxValueForGenes(genePosition) )
! // throw new IndexOutOfRangeException("Gene value not valid for the gene at" +
! // " the given position!");
! // if( geneValue != this.GetGeneValue(genePosition) )
! // // if a new value is stored in the given position, then
! // // fitness has to be calculated again, and so meaning
! // {
! // this.hasFitnessBeenAssigned = false;
! // this.meaning = null;
! // }
! //
! // this.genes[genePosition] = geneValue;
! // //whenever at least one gene has been written,
! // //the current generation number is stored
! // this.generation = this.geneticOptimizer.GenerationCounter;
! // }
public void SetGeneValue(int geneValue, int genePosition)
***************
*** 206,215 ****
this.hasFitnessBeenAssigned = false;
this.meaning = null;
}
-
this.genes[genePosition] = geneValue;
- //whenever at least one gene has been written,
- //the current generation number is stored
- this.generation = this.geneticOptimizer.GenerationCounter;
}
--- 233,241 ----
this.hasFitnessBeenAssigned = false;
this.meaning = null;
+ //only if a new gene value is written,
+ //the current generation number is stored
+ this.generation = this.geneticOptimizer.GenerationCounter;
}
this.genes[genePosition] = geneValue;
}
***************
*** 304,308 ****
return returnValue;
}
-
}
}
--- 330,333 ----
Index: GeneticOptimizer.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** GeneticOptimizer.cs 13 Feb 2011 19:33:37 -0000 1.29
--- GeneticOptimizer.cs 21 Aug 2011 09:52:40 -0000 1.30
***************
*** 305,309 ****
this.currentGeneration.Sort(this.genomeComparer);
if(this.NewGeneration != null)
! this.NewGeneration( this , new NewGenerationEventArgs(
this.currentGeneration , this.generationCounter , this.generationNumber ) );
}
--- 305,309 ----
this.currentGeneration.Sort(this.genomeComparer);
if(this.NewGeneration != null)
! this.NewGeneration( this , new NewGenerationEventArgs( this,
this.currentGeneration , this.generationCounter , this.generationNumber ) );
}
Index: NewGenerationEventArgs.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/NewGenerationEventArgs.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NewGenerationEventArgs.cs 23 Jul 2005 18:01:02 -0000 1.2
--- NewGenerationEventArgs.cs 21 Aug 2011 09:52:40 -0000 1.3
***************
*** 35,38 ****
--- 35,39 ----
private int generationNumber;
private int generationCounter;
+ private GeneticOptimizer currentGeneticOptimizer;
/// <summary>
***************
*** 57,68 ****
get { return this.generationCounter; }
}
!
public NewGenerationEventArgs( ArrayList generation )
{
this.generation = generation;
}
! public NewGenerationEventArgs( ArrayList generation ,
! int generationCounter , int generationNumber )
{
this.generation = generation;
this.generationCounter = generationCounter;
--- 58,80 ----
get { return this.generationCounter; }
}
! /// <summary>
! /// Genetic optimizer that
! /// has created the current generation
! /// </summary>
! public GeneticOptimizer CurrentGeneticOptimizer
! {
! get { return this.currentGeneticOptimizer; }
! }
!
public NewGenerationEventArgs( ArrayList generation )
{
this.generation = generation;
}
! public NewGenerationEventArgs( GeneticOptimizer currentGeneticOptimizer,
! ArrayList generation ,
! int generationCounter ,
! int generationNumber )
{
+ this.currentGeneticOptimizer = currentGeneticOptimizer;
this.generation = generation;
this.generationCounter = generationCounter;
|
|
From: Marco M. <mi...@us...> - 2011-08-21 09:38:41
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Collections
In directory vz-cvs-3.sog:/tmp/cvs-serv24113
Added Files:
DoubleArrayManager.cs
Log Message:
Added class for managing arrays of double
--- NEW FILE: DoubleArrayManager.cs ---
/*
QuantProject - Quantitative Finance Library
DoubleArrayManager.cs
Copyright (C) 2011
Marco Milletti
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
namespace QuantProject.ADT.Collections
{
/// <summary>
/// This class provides functions to manage array of doubles
/// </summary>
public class DoubleArrayManager
{
public DoubleArrayManager()
{
//
// TODO: Add constructor logic here
//
}
#region GetRatios_commented
// private static double getRatio( double[] values , int i )
// {
// return ( values[ i + 1 ] / values[ i ] );
// }
// /// <summary>
// /// If values contains n elements (V0, V1, ... Vn-1),
// /// GetRatios returns n-1 elements (E0, E1, ... En-2) where
// /// Ei = Vi+1 / Vi, for all i=0,1,...n-2
// /// </summary>
// /// <param name="values"></param>
// /// <returns></returns>
// public static double[] GetRatios( double[] values )
// {
// double[] ratios = new double[ values.Length - 1 ];
// for ( int i=0 ; i < values.Length ; i++ )
// ratios[ i ] = getRatio( values , i );
// return ratios;
// }
#endregion
private static int extractPositive_countPositive( double[] srcArray )
{
int returnValue = 0;
for(int i = 0; i < srcArray.Length; i++)
if(srcArray[i] > 0.0)
returnValue++;
return returnValue;
}
private static int extractNegative_countNegative( double[] srcArray )
{
int returnValue = 0;
for(int i = 0; i < srcArray.Length; i++)
if(srcArray[i] < 0.0)
returnValue++;
return returnValue;
}
/// <summary>
/// Returns a double array containing only the positive double
/// values in the given double array
/// </summary>
public static double[] ExtractPositive( double[] srcArray )
{
double[] returnValue;
int numOfPositiveDouble =
DoubleArrayManager.extractPositive_countPositive(srcArray);
returnValue = new double[numOfPositiveDouble];
int idx = 0;
for(int i = 0; i < numOfPositiveDouble; i++)
{
if(srcArray[i] > 0.0)
{
returnValue[idx] = srcArray[i];
idx++;
}
}
return returnValue;
}
/// <summary>
/// Returns a double array containing only the negative double
/// values in the given double array
/// </summary>
public static double[] ExtractNegative( double[] srcArray )
{
double[] returnValue;
int numOfNegativeDouble =
DoubleArrayManager.extractNegative_countNegative(srcArray);
returnValue = new double[numOfNegativeDouble];
int idx = 0;
for(int i = 0; i < numOfNegativeDouble; i++)
{
if(srcArray[i] < 0.0)
{
returnValue[idx] = srcArray[i];
idx++;
}
}
return returnValue;
}
}
}
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:38:25
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression
In directory vz-cvs-3.sog:/tmp/cvs-serv9981/t5_Testing/b7_scripts/linearRegression
Modified Files:
TestLinearRegressionFitnessEvaluator.cs
Log Message:
the test has been changed to thest the new GetIndependentVariablesValues() implementation
Index: TestLinearRegressionFitnessEvaluator.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression/TestLinearRegressionFitnessEvaluator.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestLinearRegressionFitnessEvaluator.cs 28 Mar 2010 17:06:48 -0000 1.1
--- TestLinearRegressionFitnessEvaluator.cs 3 Aug 2011 22:38:23 -0000 1.2
***************
*** 47,51 ****
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(
--- 47,51 ----
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(
***************
*** 120,126 ****
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 =
--- 120,127 ----
linearRegressionTestingPositions , returnInterval ,
fakeHistoricalMarketValueProvider );
! // Assert.AreEqual( 0 , independentVariableValues[ 0 ] );
! Assert.AreEqual( 0.005 , independentVariableValues[ 0 ] , 0.0000001 );
! Assert.AreEqual( -0.019 , independentVariableValues[ 1 ] , 0.0000001 );
! Assert.AreEqual( 2 , independentVariableValues.Length );
LinearRegressionTestingPositions linearRegressionTestingPositionsToTestNull =
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:37:48
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression
In directory vz-cvs-3.sog:/tmp/cvs-serv9868/t5_Testing/b7_scripts/linearRegression
Modified Files:
TestEntryStrategyBasedOnForecastedReturn.cs
Log Message:
the test has been changed to thest the new GetIndependentVariablesValues() implementation
Index: TestEntryStrategyBasedOnForecastedReturn.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression/TestEntryStrategyBasedOnForecastedReturn.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestEntryStrategyBasedOnForecastedReturn.cs 28 Mar 2010 17:05:24 -0000 1.1
--- TestEntryStrategyBasedOnForecastedReturn.cs 3 Aug 2011 22:37:46 -0000 1.2
***************
*** 100,104 ****
LinearRegressionTestingPositions mockLinearRegressionTestingPositions2 =
this.getMockLinearRegressionTestingPositions(
! new double[] { 1 , 0 , 2 } ,
new WeightedPositions(
new double[] { 0.4 , -0.6 } , new string[] { "TA2" , "TB2" } ) );
--- 100,104 ----
LinearRegressionTestingPositions mockLinearRegressionTestingPositions2 =
this.getMockLinearRegressionTestingPositions(
! new double[] { 0.3 , 0 , -2 } ,
new WeightedPositions(
new double[] { 0.4 , -0.6 } , new string[] { "TA2" , "TB2" } ) );
***************
*** 120,125 ****
dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn(
! "GetIndependentVariablesValues" , new double[] { 2 , 1 , 2 } , // forecasted
! // return should be 1*2+2*1-3*2=-2 (not selected)
new object[] {
mockLinearRegressionTestingPositions1 ,
--- 120,125 ----
dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn(
! "GetIndependentVariablesValues" , new double[] { 1 , 2 } , // forecasted
! // return should be 1+2*1-3*2=-3 (not selected)
new object[] {
mockLinearRegressionTestingPositions1 ,
***************
*** 127,132 ****
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 ,
--- 127,132 ----
historicalMarketValueProvider } );
dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn(
! "GetIndependentVariablesValues" , new double[] { 3 , -0.1 } , // forecasted
! // return should be 0.3+0*3-2*(-0.1)=0.5 (selected!!)
new object[] {
mockLinearRegressionTestingPositions2 ,
***************
*** 134,139 ****
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 ,
--- 134,139 ----
historicalMarketValueProvider } );
dynamicMockLinearRegressionFitnessEvaluator.ExpectAndReturn(
! "GetIndependentVariablesValues" , new double[] { 2 , 1 } , // forecasted
! // return should be 0.5-1*2+3*1=1.5 (not selected, because the previous one is selected)
new object[] {
mockLinearRegressionTestingPositions3 ,
***************
*** 158,162 ****
--- 158,164 ----
Assert.AreEqual( "TA2" , positionsToBeOpened[ 0 ].Ticker );
+ Assert.AreEqual( 0.4 , positionsToBeOpened[ 0 ].Weight );
Assert.AreEqual( "TB2" , positionsToBeOpened[ 1 ].Ticker );
+ Assert.AreEqual( -0.6 , positionsToBeOpened[ 1 ].Weight );
}
#endregion Test_GetPositionsToBeOpened
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:36:45
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory vz-cvs-3.sog:/tmp/cvs-serv9388/b7_Scripts/WalkForwardTesting/LinearRegression/Logging Modified Files: AnalyzerForLinearRegressionTestingPositions.cs Log Message: bug fixed: now the private method getReturnIntervals() is computed properly Index: AnalyzerForLinearRegressionTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging/AnalyzerForLinearRegressionTestingPositions.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnalyzerForLinearRegressionTestingPositions.cs 13 Feb 2011 19:42:11 -0000 1.3 --- AnalyzerForLinearRegressionTestingPositions.cs 3 Aug 2011 22:36:42 -0000 1.4 *************** *** 145,148 **** --- 145,149 ---- returnIntervals.Add( nextInterval ); } + returnIntervals.RemoveAt( returnIntervals.Count - 1 ); return returnIntervals; } |
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:35:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic In directory vz-cvs-3.sog:/tmp/cvs-serv8117/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic Modified Files: GenomeManagerForLinearRegression.cs Log Message: bug fixed: now the private member genomeSize is computed properly Index: GenomeManagerForLinearRegression.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic/GenomeManagerForLinearRegression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenomeManagerForLinearRegression.cs 6 Jan 2011 19:27:06 -0000 1.2 --- GenomeManagerForLinearRegression.cs 3 Aug 2011 22:35:22 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- using QuantProject.ADT.Optimizing.Genetic; + using QuantProject.ADT.Statistics; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; *************** *** 103,107 **** this.genomeSize = decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading + ! decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios; } --- 104,110 ---- this.genomeSize = decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading + ! Convert.ToInt32( BasicFunctions.GetSum( ! decoderForLinearRegressionTestingPositions.NumberOfTickersInEachSignalingPortfolio ) ); ! // decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios; } |
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:33:29
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory vz-cvs-3.sog:/tmp/cvs-serv7734/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Modified Files: LinearRegressionFitnessEvaluator.cs Log Message: bug fixed: now the method GetIndependentVariablesValues() is computed properly Index: LinearRegressionFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation/LinearRegressionFitnessEvaluator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LinearRegressionFitnessEvaluator.cs 13 Feb 2011 19:39:47 -0000 1.4 --- LinearRegressionFitnessEvaluator.cs 3 Aug 2011 22:33:27 -0000 1.5 *************** *** 187,192 **** double[] independentVariablesValues = // new double[ weightedPositions.Count - 2 + 1 ]; // one is added for the constant ! new double[ linearRegressionTestingPositions.SignalingPortfolios.Length + 1 ]; // one is added for the constant ! independentVariablesValues[ 0 ] = 0; // regressors include the constant and the constant's return is zero ReturnsManager returnsManager = new ReturnsManager( new ReturnIntervals( returnInterval ) , historicalMarketValueProvider ); --- 187,193 ---- double[] independentVariablesValues = // new double[ weightedPositions.Count - 2 + 1 ]; // one is added for the constant ! // new double[ linearRegressionTestingPositions.SignalingPortfolios.Length + 1 ]; // one is added for the constant ! new double[ linearRegressionTestingPositions.SignalingPortfolios.Length ]; ! // independentVariablesValues[ 0 ] = 0; // regressors include the constant and the constant's return is zero ReturnsManager returnsManager = new ReturnsManager( new ReturnIntervals( returnInterval ) , historicalMarketValueProvider ); *************** *** 195,199 **** WeightedPositions portfolioForCurrentIndependentVariable = linearRegressionTestingPositions.SignalingPortfolios[ j ]; ! independentVariablesValues[ j + 1 ] = portfolioForCurrentIndependentVariable.GetReturn( 0 , returnsManager ); } --- 196,201 ---- WeightedPositions portfolioForCurrentIndependentVariable = linearRegressionTestingPositions.SignalingPortfolios[ j ]; ! // independentVariablesValues[ j + 1 ] = ! independentVariablesValues[ j ] = portfolioForCurrentIndependentVariable.GetReturn( 0 , returnsManager ); } |
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:31:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding
In directory vz-cvs-3.sog:/tmp/cvs-serv7279/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding
Modified Files:
DecoderForLinearRegressionTestingPositions.cs
Log Message:
the read only property NumberOfTickersInEachSignalingPortfolio has been added
Index: DecoderForLinearRegressionTestingPositions.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding/DecoderForLinearRegressionTestingPositions.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DecoderForLinearRegressionTestingPositions.cs 6 Jan 2011 18:56:26 -0000 1.2
--- DecoderForLinearRegressionTestingPositions.cs 3 Aug 2011 22:31:11 -0000 1.3
***************
*** 60,63 ****
--- 60,67 ----
}
+ public int[] NumberOfTickersInEachSignalingPortfolio{
+ get { return this.numberOfTickersInEachSignalingPortfolio; }
+ }
+
private BasicDecoderForTestingPositions basicDecoderForTestingPositions;
protected int expectedNumberOfGeneValues;
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:30:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies
In directory vz-cvs-3.sog:/tmp/cvs-serv6100/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies
Modified Files:
EntryStrategyBasedOnForecastedReturn.cs
Log Message:
bug fixed: now the forecasted return is computed properly
Index: EntryStrategyBasedOnForecastedReturn.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies/EntryStrategyBasedOnForecastedReturn.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EntryStrategyBasedOnForecastedReturn.cs 28 Mar 2010 15:51:40 -0000 1.1
--- EntryStrategyBasedOnForecastedReturn.cs 3 Aug 2011 22:30:32 -0000 1.2
***************
*** 109,114 ****
double[] outOfSampleValuesForSignalingPortfolios )
{
! double forecastedReturn = 0; // the first coefficient is for the constant regressor
! // and it has no return
for ( int i = 1;
i < candidate.LinearRegression.EstimatedCoefficients.Length ;
--- 109,115 ----
double[] outOfSampleValuesForSignalingPortfolios )
{
! // the first coefficient is for the constant regressor
! double forecastedReturn = candidate.LinearRegression.EstimatedCoefficients[ 0 ];
!
for ( int i = 1;
i < candidate.LinearRegression.EstimatedCoefficients.Length ;
***************
*** 116,120 ****
forecastedReturn +=
candidate.LinearRegression.EstimatedCoefficients[ i ] *
! outOfSampleValuesForSignalingPortfolios[ i ];
return forecastedReturn;
}
--- 117,121 ----
forecastedReturn +=
candidate.LinearRegression.EstimatedCoefficients[ i ] *
! outOfSampleValuesForSignalingPortfolios[ i - 1 ];
return forecastedReturn;
}
***************
*** 123,127 ****
ReturnInterval outOfSampleReturnIntervalForSignaling )
{
! double forecastedReturn = double.MinValue;;
double[] outOfSampleValuesForSignalingPortfolios =
this.getOutOfSampleValuesForSignalingPortfolios(
--- 124,128 ----
ReturnInterval outOfSampleReturnIntervalForSignaling )
{
! double forecastedReturn = double.MinValue;
double[] outOfSampleValuesForSignalingPortfolios =
this.getOutOfSampleValuesForSignalingPortfolios(
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:29:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression
In directory vz-cvs-3.sog:/tmp/cvs-serv5950/b7_Scripts/WalkForwardTesting/LinearRegression
Modified Files:
LinearRegressionMain.cs
Log Message:
some code has been added to validate the strategy, using a perfect predictor; using a perfect predictor it can be checked that a) the strategy finds it in sample and b) out of sample the portfolio is opened in the right direction (in other words, using a perfect predictor, draw down must be zero!)
Index: LinearRegressionMain.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/LinearRegressionMain.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LinearRegressionMain.cs 19 Feb 2011 20:23:21 -0000 1.4
--- LinearRegressionMain.cs 3 Aug 2011 22:29:23 -0000 1.5
***************
*** 65,68 ****
--- 65,73 ----
this.historicalMarketValueProviderForInSample =
new HistoricalAdjustedQuoteProvider();
+ // uncomment the following instruction in order to test the strategy
+ // using CSCO as a perfect predictor for MSFT
+ this.historicalMarketValueProviderForInSample =
+ new LookingAtTheFutureQuoteProvider(
+ this.historicalMarketValueProviderForInSample , "MSFT" , "CSCO" );
this.historicalMarketValueProviderForChosingPositionsOutOfSample =
this.historicalMarketValueProviderForInSample;
***************
*** 104,111 ****
int maxNumberOfEligiblesForTrading = 150;
! // uncomment the followings lines for a faster script
! // groupIdForTradingTickers = "fastTest";
! // groupIdForAdditionalSignalingTickers = "fastTest";
! // maxNumberOfEligiblesForTrading = 8;
IEligiblesSelector eligiblesSelector =
--- 109,119 ----
int maxNumberOfEligiblesForTrading = 150;
! // uncomment the followings three lines for a faster script
! groupIdForTradingTickers = "fastTest";
! groupIdForAdditionalSignalingTickers = "fastTest";
! maxNumberOfEligiblesForTrading = 13;
! // groupIdForTradingTickers = "win_leg";
! // groupIdForAdditionalSignalingTickers = "win_leg";
! // maxNumberOfEligiblesForTrading = 2;
IEligiblesSelector eligiblesSelector =
***************
*** 135,145 ****
// uncomment the following line for a faster script
// numberOfBestTestingPositionsToBeReturned = 20;
! // numberOfBestTestingPositionsToBeReturned = 3;
! // int numberOfTickersForTrading = 1;
! int numberOfTickersForTrading = 4;
int[] numberOfTickersInEachSignalingPortfolio =
// new int[] { 1 , 1 , 1 };
! new int[] { 4 };
DecoderForLinearRegressionTestingPositions decoderForWeightedPositions =
--- 143,154 ----
// uncomment the following line for a faster script
// numberOfBestTestingPositionsToBeReturned = 20;
! // numberOfBestTestingPositionsToBeReturned = 6;
! numberOfBestTestingPositionsToBeReturned = 1;
!
! int numberOfTickersForTrading = 1;
int[] numberOfTickersInEachSignalingPortfolio =
// new int[] { 1 , 1 , 1 };
! new int[] { 1 };
DecoderForLinearRegressionTestingPositions decoderForWeightedPositions =
***************
*** 171,181 ****
double mutationRate = 0.02;
// double elitismRate = 0.00001;
! double elitismRate = 0.2;
int populationSizeForGeneticOptimizer = 60000;
int generationNumberForGeneticOptimizer = 15;
// uncomment the followings line for a faster script
! // populationSizeForGeneticOptimizer = 300;
! // generationNumberForGeneticOptimizer = 2;
int seedForRandomGeneratorForTheGeneticOptimizer =
--- 180,193 ----
double mutationRate = 0.02;
// double elitismRate = 0.00001;
! double elitismRate = 0.01;
int populationSizeForGeneticOptimizer = 60000;
int generationNumberForGeneticOptimizer = 15;
// uncomment the followings line for a faster script
! populationSizeForGeneticOptimizer = 300;
! generationNumberForGeneticOptimizer = 2;
! populationSizeForGeneticOptimizer = 1000;
! generationNumberForGeneticOptimizer = 3;
!
int seedForRandomGeneratorForTheGeneticOptimizer =
***************
*** 236,240 ****
// uncomment the following line for a faster script
// inSampleDays = 20;
! // inSampleDays = 60;
// IIntervalsSelector intervalsSelectorForOutOfSample =
--- 248,252 ----
// uncomment the following line for a faster script
// inSampleDays = 20;
! inSampleDays = 60;
// IIntervalsSelector intervalsSelectorForOutOfSample =
***************
*** 314,319 ****
// firstDateTime = new DateTime( 2006 , 2 , 26 );
// lastDateTime = new DateTime( 2006 , 4 , 5 );
! double maxRunningHours = 12;
EndOfDayStrategyBackTester endOfDayStrategyBackTester =
--- 326,333 ----
// firstDateTime = new DateTime( 2006 , 2 , 26 );
// lastDateTime = new DateTime( 2006 , 4 , 5 );
+ firstDateTime = new DateTime( 2004 , 5 , 1 );
+ lastDateTime = new DateTime( 2004 , 6 , 30 );
! double maxRunningHours = 1.5;
EndOfDayStrategyBackTester endOfDayStrategyBackTester =
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:27:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts
In directory vz-cvs-3.sog:/tmp/cvs-serv5380/b7_Scripts
Modified Files:
Scripts_SD.csproj
Log Message:
WalkForwardTesting\LinearRegression\MarketValueProviders\LookingAtTheFutureQuoteProvider.cs has been added
Index: Scripts_SD.csproj
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** Scripts_SD.csproj 13 Feb 2011 18:56:17 -0000 1.46
--- Scripts_SD.csproj 3 Aug 2011 22:27:02 -0000 1.47
***************
*** 181,184 ****
--- 181,185 ----
<Compile Include="WalkForwardTesting\LinearRegression\Logging\VirtualReturns\ReturnPredictor.cs" />
<Compile Include="WalkForwardTesting\LinearRegression\Logging\VirtualReturns\PortfolioReturnComputer.cs" />
+ <Compile Include="WalkForwardTesting\LinearRegression\MarketValueProviders\LookingAtTheFutureQuoteProvider.cs" />
<Compile Include="WalkForwardTesting\LinearRegression\ReturnIntervals\ShiftedTimeIntervalSelectorForSignaling.cs" />
<Compile Include="WalkForwardTesting\LinearRegression\ReturnIntervals\SingleDayIntervalsSelector.cs" />
***************
*** 403,406 ****
--- 404,408 ----
<Folder Include="WalkForwardTesting\LinearRegression\Logging" />
<Folder Include="WalkForwardTesting\LinearRegression\Logging\VirtualReturns" />
+ <Folder Include="WalkForwardTesting\LinearRegression\MarketValueProviders" />
<Folder Include="WalkForwardTesting\LinearRegression\ReturnIntervals" />
<Folder Include="WalkForwardTesting\LinearRegression\Strategies" />
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:25:59
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/MarketValueProviders
In directory vz-cvs-3.sog:/tmp/cvs-serv4056
Added Files:
LookingAtTheFutureQuoteProvider.cs
Log Message:
tickerWithFutureQuotes will have the same quote as tickerWithRealQuotes
will have tomorrow; then tickerWithFutureQuotes can be used as a perfect predictor
--- NEW FILE: LookingAtTheFutureQuoteProvider.cs ---
/*
QuantProject - Quantitative Finance Library
LookingAtTheFutureQuoteProvider.cs
Copyright (C) 2011
Glauco Siliprandi
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using QuantProject.Business.DataProviders;
namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression
{
/// <summary>
/// tickerWithFutureQuotes will have the same quote as tickerWithRealQuotes
/// will have tomorrow; then tickerWithFutureQuotes can be used as a perfect predictor
/// </summary>
[Serializable]
public class LookingAtTheFutureQuoteProvider : HistoricalQuoteProvider
{
private HistoricalMarketValueProvider historicalMarketValueProvider;
private string tickerWithRealQuotes;
private string tickerWithFutureQuotes;
/// <summary>
/// tickerWithFutureQuotes will have the same quote as tickerWithRealQuotes
/// will have tomorrow; then tickerWithFutureQuotes can be used as a perfect predictor
/// </summary>
/// <param name="tickerWithRealQuotes"></param>
/// <param name="tickerWithFutureQuotes"></param>
public LookingAtTheFutureQuoteProvider(
HistoricalMarketValueProvider historicalMarketValueProvider ,
string tickerWithRealQuotes , string tickerWithFutureQuotes )
{
this.historicalMarketValueProvider = historicalMarketValueProvider;
this.tickerWithRealQuotes = tickerWithRealQuotes;
this.tickerWithFutureQuotes = tickerWithFutureQuotes;
}
protected override string getDescription()
{
return "lookingAtTheFuture";
}
#region GetMarketValue
private double getFutureMarketValue( DateTime dateTime )
{
double futureMarketValue = double.MinValue;
DateTime futureDateTime = dateTime.AddDays( 1 );
while ( ( futureMarketValue == double.MinValue ) && ( futureDateTime < dateTime.AddDays( 10 ) ) )
{
if ( this.historicalMarketValueProvider.WasExchanged(
this.tickerWithRealQuotes , futureDateTime ) )
// the ticker with real quotes was exchanged in the future DateTime
futureMarketValue = this.historicalMarketValueProvider.GetMarketValue(
this.tickerWithRealQuotes , futureDateTime );
futureDateTime = futureDateTime.AddDays( 1 );
}
return futureMarketValue;
}
public override double GetMarketValue( string ticker , DateTime dateTime )
{
double marketValue = double.MinValue;
if ( ticker != this.tickerWithFutureQuotes )
marketValue = this.historicalMarketValueProvider.GetMarketValue( ticker , dateTime );
else
marketValue = this.getFutureMarketValue( dateTime );
return marketValue;
}
#endregion GetMarketValue
}
}
|
|
From: Glauco S. <gla...@us...> - 2011-08-03 22:25:08
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/MarketValueProviders In directory vz-cvs-3.sog:/tmp/cvs-serv3958/MarketValueProviders Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/MarketValueProviders added to the repository |
|
From: Glauco S. <gla...@us...> - 2011-02-26 16:40:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory vz-cvs-2.sog:/tmp/cvs-serv25674/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: ChosenTickers.cs Log Message: Test to see if email notification is working, now Index: ChosenTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/ChosenTickers.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ChosenTickers.cs 29 Sep 2008 21:18:25 -0000 1.8 --- ChosenTickers.cs 26 Feb 2011 16:40:14 -0000 1.9 *************** *** 27,31 **** using QuantProject.Business.Timing; using QuantProject.Data; ! using QuantProject.Data.DataProviders; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank --- 27,31 ---- using QuantProject.Business.Timing; using QuantProject.Data; ! using QuantProject.Data.DataProviders; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank |
|
From: Glauco S. <gla...@us...> - 2011-01-25 21:05:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5057/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Modified Files: LinearRegressionSetUpManager.cs Log Message: Bug fixed when setting up the constant regressor Index: LinearRegressionSetUpManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation/LinearRegressionSetUpManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearRegressionSetUpManager.cs 28 Mar 2010 16:08:28 -0000 1.1 --- LinearRegressionSetUpManager.cs 25 Jan 2011 21:05:17 -0000 1.2 *************** *** 61,65 **** private void addConstantRegressor( double[,] regressors ) { ! for( int j = 0 ; j < regressors.GetLength( 1 ) ; j++ ) regressors[ j , 0 ] = 1; } --- 61,65 ---- private void addConstantRegressor( double[,] regressors ) { ! for( int j = 0 ; j < regressors.GetLength( 0 ) ; j++ ) regressors[ j , 0 ] = 1; } |
|
From: Marco M. <mi...@us...> - 2011-01-17 23:06:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/InSampleChoosers/BruteForce In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv360 Added Files: OTCEndOfDayBruteForceChooser.cs OTCEndOfDayBruteForceOptimizableParametersManager.cs OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager.cs OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager.cs Log Message: Added missing files --- NEW FILE: OTCEndOfDayBruteForceOptimizableParametersManager.cs --- /* QuantProject - Quantitative Finance Library OTCEndOfDayBruteForceOptimizableParametersManager.cs Copyright (C) 2009 Marco Milletti 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.BruteForce; using QuantProject.ADT.Statistics.Combinatorial; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.BruteForce; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.BruteForce { /// <summary> /// BruteForceOptimizableParametersManager to be used by the OTC intraday strategy. /// </summary> [Serializable] public class OTCEndOfDayBruteForceOptimizableParametersManager : CombinationBasedBruteForceOptimizableParametersManager { private EligibleTickers eligibleTickers; private int numberOfPositions; private IDecoderForTestingPositions decoderForTestingPositions; private IFitnessEvaluator fitnessEvaluator; private ReturnsManager returnsManager; public OTCEndOfDayBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , int numberOfPositions , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , ReturnsManager returnsManager ) : base( new Combination( - eligibleTickers.Count , eligibleTickers.Count - 1 , numberOfPositions ) ) { this.eligibleTickers = eligibleTickers; this.numberOfPositions = numberOfPositions; this.decoderForTestingPositions = decoderForTestingPositions; this.fitnessEvaluator = fitnessEvaluator; this.returnsManager = returnsManager; } public override object Decode( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { return this.decoderForTestingPositions.Decode( bruteForceOptimizableParameters.GetValues() , this.eligibleTickers , this.returnsManager ); } public override double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { object meaning = this.Decode( bruteForceOptimizableParameters ); double fitnessValue = this.fitnessEvaluator.GetFitnessValue( meaning , this.returnsManager ); return fitnessValue; } #region AreEquivalentAsTopBestParameters private void areEquivalentAsTopBestParameters_checkParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { if ( !(bruteForceOptimizableParameters1.Meaning is TestingPositions) ) throw new Exception( "The first parameter is expected " + "to represent a TestingPositions!" ); if ( !(bruteForceOptimizableParameters2.Meaning is TestingPositions) ) throw new Exception( "The second parameter is expected " + "to represent a TestingPositions!" ); } public override bool AreEquivalentAsTopBestParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { this.areEquivalentAsTopBestParameters_checkParameters( bruteForceOptimizableParameters1 , bruteForceOptimizableParameters2 ); bool areEquivalentAsTopBestParameters = ((TestingPositions)bruteForceOptimizableParameters1.Meaning ).HashCode == ((TestingPositions)bruteForceOptimizableParameters2.Meaning ).HashCode; return areEquivalentAsTopBestParameters; } #endregion AreEquivalentAsTopBestParameters } } --- NEW FILE: OTCEndOfDayBruteForceChooser.cs --- /* QuantProject - Quantitative Finance Library OTCEndOfDayBruteForceChooser.cs Copyright (C) 2009 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.Optimizing.BruteForce; using QuantProject.Business.Strategies; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.BruteForce { /// <summary> /// brute force IInSampleChooser with End Of Day data for the OTC strategy /// </summary> [Serializable] public class OTCEndOfDayBruteForceChooser : BruteForceChooser { private int numberOfPortfolioPositions; private PortfolioType portfolioType; public OTCEndOfDayBruteForceChooser( PortfolioType portfolioType, int numberOfPortfolioPositions , int numberOfBestTestingPositionsToBeReturned , Benchmark benchmark , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , HistoricalMarketValueProvider historicalMarketValueProvider) : base ( numberOfBestTestingPositionsToBeReturned , decoderForTestingPositions , fitnessEvaluator ) { this.portfolioType = portfolioType; this.numberOfPortfolioPositions = numberOfPortfolioPositions; } protected override IBruteForceOptimizableParametersManager getBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { IBruteForceOptimizableParametersManager parametersManager; if(this.portfolioType == PortfolioType.OnlyLong) parametersManager = new OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager( eligibleTickers , this.numberOfPortfolioPositions , this.decoderForTestingPositions , this.fitnessEvaluator , returnsManager ); else if(this.portfolioType == PortfolioType.OnlyShort) parametersManager = new OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager( eligibleTickers , this.numberOfPortfolioPositions , this.decoderForTestingPositions , this.fitnessEvaluator , returnsManager ); else//short and long or only mixed portfolio types parametersManager = new OTCEndOfDayBruteForceOptimizableParametersManager( eligibleTickers , this.numberOfPortfolioPositions , this.decoderForTestingPositions , this.fitnessEvaluator , returnsManager ); return parametersManager; } } } --- NEW FILE: OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager.cs --- /* QuantProject - Quantitative Finance Library OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager.cs Copyright (C) 2009 Marco Milletti 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.BruteForce; using QuantProject.ADT.Statistics.Combinatorial; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.BruteForce; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.BruteForce { /// <summary> /// BruteForceOptimizableParametersManager to be used by the OTC intraday strategy. /// </summary> [Serializable] public class OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager : CombinationBasedBruteForceOptimizableParametersManager { private EligibleTickers eligibleTickers; private int numberOfPositions; private IDecoderForTestingPositions decoderForTestingPositions; private IFitnessEvaluator fitnessEvaluator; private ReturnsManager returnsManager; public OTCOnlyLongEndOfDayBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , int numberOfPositions , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , ReturnsManager returnsManager ) : base( new Combination( 0 , eligibleTickers.Count - 1 , numberOfPositions ) ) { this.eligibleTickers = eligibleTickers; this.numberOfPositions = numberOfPositions; this.decoderForTestingPositions = decoderForTestingPositions; this.fitnessEvaluator = fitnessEvaluator; this.returnsManager = returnsManager; } public override object Decode( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { return this.decoderForTestingPositions.Decode( bruteForceOptimizableParameters.GetValues() , this.eligibleTickers , this.returnsManager ); } public override double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { object meaning = this.Decode( bruteForceOptimizableParameters ); double fitnessValue = this.fitnessEvaluator.GetFitnessValue( meaning , this.returnsManager ); return fitnessValue; } #region AreEquivalentAsTopBestParameters private void areEquivalentAsTopBestParameters_checkParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { if ( !(bruteForceOptimizableParameters1.Meaning is TestingPositions) ) throw new Exception( "The first parameter is expected " + "to represent a TestingPositions!" ); if ( !(bruteForceOptimizableParameters2.Meaning is TestingPositions) ) throw new Exception( "The second parameter is expected " + "to represent a TestingPositions!" ); } public override bool AreEquivalentAsTopBestParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { this.areEquivalentAsTopBestParameters_checkParameters( bruteForceOptimizableParameters1 , bruteForceOptimizableParameters2 ); bool areEquivalentAsTopBestParameters = ((TestingPositions)bruteForceOptimizableParameters1.Meaning ).HashCode == ((TestingPositions)bruteForceOptimizableParameters2.Meaning ).HashCode; return areEquivalentAsTopBestParameters; } #endregion AreEquivalentAsTopBestParameters } } --- NEW FILE: OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager.cs --- /* QuantProject - Quantitative Finance Library OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager.cs Copyright (C) 2009 Marco Milletti 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.BruteForce; using QuantProject.ADT.Statistics.Combinatorial; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.BruteForce; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.BruteForce { /// <summary> /// BruteForceOptimizableParametersManager to be used by the OTC intraday strategy. /// </summary> [Serializable] public class OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager : CombinationBasedBruteForceOptimizableParametersManager { private EligibleTickers eligibleTickers; private int numberOfPositions; private IDecoderForTestingPositions decoderForTestingPositions; private IFitnessEvaluator fitnessEvaluator; private ReturnsManager returnsManager; public OTCOnlyShortEndOfDayBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , int numberOfPositions , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , ReturnsManager returnsManager ) : base( new Combination( - eligibleTickers.Count, - 1 , numberOfPositions ) ) { this.eligibleTickers = eligibleTickers; this.numberOfPositions = numberOfPositions; this.decoderForTestingPositions = decoderForTestingPositions; this.fitnessEvaluator = fitnessEvaluator; this.returnsManager = returnsManager; } public override object Decode( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { return this.decoderForTestingPositions.Decode( bruteForceOptimizableParameters.GetValues() , this.eligibleTickers , this.returnsManager ); } public override double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { object meaning = this.Decode( bruteForceOptimizableParameters ); double fitnessValue = this.fitnessEvaluator.GetFitnessValue( meaning , this.returnsManager ); return fitnessValue; } #region AreEquivalentAsTopBestParameters private void areEquivalentAsTopBestParameters_checkParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { if ( !(bruteForceOptimizableParameters1.Meaning is TestingPositions) ) throw new Exception( "The first parameter is expected " + "to represent a TestingPositions!" ); if ( !(bruteForceOptimizableParameters2.Meaning is TestingPositions) ) throw new Exception( "The second parameter is expected " + "to represent a TestingPositions!" ); } public override bool AreEquivalentAsTopBestParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , BruteForceOptimizableParameters bruteForceOptimizableParameters2 ) { this.areEquivalentAsTopBestParameters_checkParameters( bruteForceOptimizableParameters1 , bruteForceOptimizableParameters2 ); bool areEquivalentAsTopBestParameters = ((TestingPositions)bruteForceOptimizableParameters1.Meaning ).HashCode == ((TestingPositions)bruteForceOptimizableParameters2.Meaning ).HashCode; return areEquivalentAsTopBestParameters; } #endregion AreEquivalentAsTopBestParameters } } |
|
From: Marco M. <mi...@us...> - 2011-01-17 23:05:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv32684 Added Files: BasicDecoderForOTCPositions.cs DecoderForOTCPositionsWithWeights.cs Log Message: Added missing files --- NEW FILE: DecoderForOTCPositionsWithWeights.cs --- /* QuantProject - Quantitative Finance Library DecoderForOTCPositionsWithWeights.cs Copyright (C) 2009 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Collections; using QuantProject.ADT.Optimizing.Decoding; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Optimizing.Decoding; namespace QuantProject.Scripts.TickerSelectionTesting.OTC { /// <summary> /// Decodes optimization candidates to a /// OTCPositions with weights /// </summary> [Serializable] public class DecoderForOTCPositionsWithWeights : DecoderForTestingPositionsWithWeights { public DecoderForOTCPositionsWithWeights() : base() { } protected override TestingPositions getMeaningForUndecodable() { return new OTCPositions(); } protected override TestingPositions decodeDecodable() { SignedTickers signedTickers = this.decodeSignedTickers(); OTCPositions otcPositions = new OTCPositions( new WeightedPositions( this.getUnsignedWeights(signedTickers), signedTickers) ); return otcPositions; } protected override string getDescription() { return "OTC_Dcdr_WithWghts"; } } } --- NEW FILE: BasicDecoderForOTCPositions.cs --- /* QuantProject - Quantitative Finance Library BasicDecoderForOTCPositions.cs Copyright (C) 2009 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Collections; using QuantProject.ADT.Optimizing.Decoding; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Optimizing.Decoding; namespace QuantProject.Scripts.TickerSelectionTesting.OTC { /// <summary> /// Decodes optimization candidates to a /// OTCPositions /// </summary> [Serializable] public class BasicDecoderForOTCPositions : BasicDecoderForTestingPositions { public BasicDecoderForOTCPositions() : base() { } protected override TestingPositions getMeaningForUndecodable() { return new OTCPositions(); } protected override TestingPositions decodeDecodable() { SignedTickers signedTickers = this.decodeSignedTickers(); OTCPositions otcPositions = new OTCPositions( new WeightedPositions( this.getUnsignedWeights(signedTickers), signedTickers) ); return otcPositions; } protected override string getDescription() { return "OTC_Dcdr_NoWghts"; } } } |
|
From: Marco M. <mi...@us...> - 2011-01-17 23:03:59
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv32115 Modified Files: DrivenByFVProviderMain.cs Log Message: Updated script files Index: DrivenByFVProviderMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/DrivenByFVProviderMain.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DrivenByFVProviderMain.cs 16 Jan 2011 19:35:50 -0000 1.1 --- DrivenByFVProviderMain.cs 17 Jan 2011 23:03:51 -0000 1.2 *************** *** 189,192 **** --- 189,195 ---- new BuyAndHoldFitnessEvaluator( new SharpeRatio() ); + bool mixPastReturnsEvaluationWithFundamentalEvaluation = + false; + BasicDecoderForGeneticallyOptimizableTestingPositions basicGenOptDecoder = new BasicDecoderForGeneticallyOptimizableTestingPositions(); *************** *** 196,200 **** numberOfBestTestingPositionsToBeReturned, benchmark, basicGenOptDecoder, this.genomeManagerType , ! fitnessEvaluator , historicalMarketValueProviderForInSample, crossoverRate, mutationRate, elitismRate , populationSizeForGeneticOptimizer, generationNumberForGeneticOptimizer, --- 199,204 ---- numberOfBestTestingPositionsToBeReturned, benchmark, basicGenOptDecoder, this.genomeManagerType , ! fitnessEvaluator , mixPastReturnsEvaluationWithFundamentalEvaluation, ! historicalMarketValueProviderForInSample, this.timerForBackTester, crossoverRate, mutationRate, elitismRate , populationSizeForGeneticOptimizer, generationNumberForGeneticOptimizer, |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv31898 Added Files: DrivenByFVProviderInSampleChooser.cs GenomeManagerForDrivenByFVProvider.cs Log Message: Added missing files for the DrivenByFairValueProvider strategy --- NEW FILE: DrivenByFVProviderInSampleChooser.cs --- /* QuantProject - Quantitative Finance Library DrivenByFVProviderInSampleChooser.cs Copyright (C) 2010 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Timing; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider.InSampleChoosers.Genetic { /// <summary> /// In sample genetic analyzer for the /// Driven by Fair Value Provider strategy /// </summary> [Serializable] public class DrivenByFVProviderInSampleChooser : GeneticChooser { protected GenomeManagerType genomeManagerType; protected Timer timer; protected bool mixPastReturnsEvaluationWithFundamentalEvaluation; public DrivenByFVProviderInSampleChooser( int numberOfPortfolioPositions , int numberOfBestTestingPositionsToBeReturned , Benchmark benchmark , IDecoderForTestingPositions decoderForTestingPositions , GenomeManagerType genomeManagerType , IFitnessEvaluator fitnessEvaluator , bool mixPastReturnsEvaluationWithFundamentalEvaluation, HistoricalMarketValueProvider historicalMarketValueProvider , Timer timer, double crossoverRate , double mutationRate , double elitismRate , int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , int seedForRandomGenerator) : base(numberOfPortfolioPositions, numberOfBestTestingPositionsToBeReturned, benchmark , decoderForTestingPositions , fitnessEvaluator , historicalMarketValueProvider , crossoverRate , mutationRate , elitismRate , populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , seedForRandomGenerator ) { this.genomeManagerType = genomeManagerType; this.mixPastReturnsEvaluationWithFundamentalEvaluation = mixPastReturnsEvaluationWithFundamentalEvaluation; this.timer = timer; } protected override string getHashCodeForGenome(QuantProject.ADT.Optimizing.Genetic.Genome genome) { string returnValue = ((TestingPositions)genome.Meaning).HashCodeForTickerComposition; return returnValue; } public override IGenomeManager GetGenomeManager(EligibleTickers eligibleTickers , ReturnsManager returnsManager) { return new GenomeManagerForDrivenByFVProvider(eligibleTickers, this.numberOfPortfolioPositions, this.decoderForTestingPositions, this.fitnessEvaluator, this.genomeManagerType , returnsManager, this.historicalMarketValueProvider, this.timer, this.mixPastReturnsEvaluationWithFundamentalEvaluation, this.seedForRandomGeneratorForTheGeneticOptimizer); } } } --- NEW FILE: GenomeManagerForDrivenByFVProvider.cs --- /* QuantProject - Quantitative Finance Library GenomeManagerForDrivenByFVProvider.cs Copyright (C) 2010 Marco Milletti 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 System.Collections; using QuantProject.ADT; using QuantProject.ADT.Statistics; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Data; using QuantProject.Data.DataTables; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider.InSampleChoosers.Genetic { /// <summary> /// Implements what we need to use the Genetic Optimizer /// for finding the portfolio that fits /// the strategy driven by a particular IFairValueProvider object /// The optimazion that uses this genomeManager just seeks /// the portfolio with the highest evaluation provided /// by the given IFitnessEvaluator, just using past returns OR /// the portfolio with the highest level of a combined fitness /// (evaluation of past returns provided by the given IFitnessEvaluator /// mixed with an evaluation based on fundamentals) /// </summary> [Serializable] public class GenomeManagerForDrivenByFVProvider : BasicGenomeManager { private HistoricalMarketValueProvider historicalMarketValueProvider; private bool mixPastReturnsEvaluationWithFundamentalEvaluation; private Timer timer; public GenomeManagerForDrivenByFVProvider(EligibleTickers eligibleTickers, int numberOfTickersInPortfolio, IDecoderForTestingPositions decoderForTestingPositions, IFitnessEvaluator fitnessEvaluator, GenomeManagerType genomeManagerType, ReturnsManager returnsManager, HistoricalMarketValueProvider historicalMarketValueProvider, Timer timer, bool mixPastReturnsEvaluationWithFundamentalEvaluation, int seedForRandomGenerator) : base(eligibleTickers, numberOfTickersInPortfolio, decoderForTestingPositions, fitnessEvaluator, genomeManagerType, returnsManager, seedForRandomGenerator) { this.historicalMarketValueProvider = historicalMarketValueProvider; this.timer = timer; this.mixPastReturnsEvaluationWithFundamentalEvaluation = mixPastReturnsEvaluationWithFundamentalEvaluation; } #region getFitnessByFundamentals private double getFitnessValue_getFundamentalFitness_getBuyPrice(WeightedPosition position) { double returnValue; returnValue = this.historicalMarketValueProvider.GetMarketValue(position.Ticker, this.timer.GetCurrentDateTime() ); return returnValue; } private double getFitnessValue_getFundamentalFitness_getFairPrice(WeightedPosition position) { double returnValue; object[] keys = new object[1]; keys[0] = position.Ticker; DataRow foundRow = this.eligibleTickers.SourceDataTable.Rows.Find(keys); returnValue = (double)foundRow["FairPrice"]; return returnValue; } private double getFitnessValue_getFundamentalFitness(Genome genome) { double theoreticalProfit = 0.0; double buyPriceOfCurrentPosition, fairPriceOfCurrentPosition, weightOfCurrentPosition; WeightedPositions weightedPositionFromGenome = ((TestingPositions)genome.Meaning).WeightedPositions; foreach( WeightedPosition position in weightedPositionFromGenome ) { buyPriceOfCurrentPosition = getFitnessValue_getFundamentalFitness_getBuyPrice(position); fairPriceOfCurrentPosition = getFitnessValue_getFundamentalFitness_getFairPrice(position); weightOfCurrentPosition = position.Weight; theoreticalProfit += weightOfCurrentPosition*(fairPriceOfCurrentPosition-buyPriceOfCurrentPosition)/ buyPriceOfCurrentPosition; } return theoreticalProfit; } #endregion getFitnessByFundamentals public override double GetFitnessValue(Genome genome) { double fitnessValue = double.MinValue; double fitnessValueFromPastReturns = this.fitnessEvaluator.GetFitnessValue(genome.Meaning, this.returnsManager); double fitnessGivenByFundamentals = 1.0; if( this.mixPastReturnsEvaluationWithFundamentalEvaluation ) fitnessGivenByFundamentals = this.getFitnessValue_getFundamentalFitness(genome); fitnessValue = fitnessValueFromPastReturns * fitnessGivenByFundamentals; return fitnessValue; } public override Genome[] GetChilds(Genome parent1, Genome parent2) { return GenomeManipulator.MixGenesWithoutDuplicates(parent1, parent2); } public override int GetNewGeneValue(Genome genome, int genePosition) { // in this implementation new gene values must be different from // the others already stored in the given genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); while( GenomeManipulator.IsTickerContainedInGenome(returnValue,genome) ) //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); } return returnValue; } public override void Mutate(Genome genome) { // in this implementation only one gene is mutated // the new value has to be different from all the other genes of the genome int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next(genome.Size); int newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); while( GenomeManipulator.IsTickerContainedInGenome(newValueForGene,genome) ) //the portfolio can't have a long position and a short one for the same ticker { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); } GenomeManagement.MutateOneGene(genome, genePositionToBeMutated, newValueForGene); } } } |
|
From: Marco M. <mi...@us...> - 2011-01-17 23:01:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv31673/Genetic Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/InSampleChoosers/Genetic added to the repository |
|
From: Marco M. <mi...@us...> - 2011-01-17 23:01:27
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/InSampleChoosers In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv31563/InSampleChoosers Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/InSampleChoosers added to the repository |
|
From: Marco M. <mi...@us...> - 2011-01-16 19:52:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv2823/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: Updated sharp develop project files Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Scripts_SD.csproj 6 Jan 2011 18:37:26 -0000 1.44 --- Scripts_SD.csproj 16 Jan 2011 19:52:32 -0000 1.45 *************** *** 112,115 **** --- 112,125 ---- <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\WeightedPVO\WeightedBalancedPVO\GenomeManagerWeightedBalancedPVO.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\WeightedPVO\WeightedBalancedPVO\RunWeightedBalancedPVO.cs" /> + <Compile Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\DrivenByFVProviderLogItem.cs" /> + <Compile Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\DrivenByFVProviderMain.cs" /> + <Compile Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\DrivenByFVProviderStrategy.cs" /> + <Compile Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\InSampleChoosers\Genetic\DrivenByFVProviderInSampleChooser.cs" /> + <Compile Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\InSampleChoosers\Genetic\GenomeManagerForDrivenByFVProvider.cs" /> + <Compile Include="TickerSelectionTesting\DrivenBySharpeRatio\DrivenBySharpeRatioLogItem.cs" /> + <Compile Include="TickerSelectionTesting\DrivenBySharpeRatio\DrivenBySharpeRatioMain.cs" /> + <Compile Include="TickerSelectionTesting\DrivenBySharpeRatio\DrivenBySharpeRatioStrategy.cs" /> + <Compile Include="TickerSelectionTesting\DrivenBySharpeRatio\InSampleChoosers\Genetic\DrivenBySharpeRatioInSampleChooser.cs" /> + <Compile Include="TickerSelectionTesting\DrivenBySharpeRatio\InSampleChoosers\Genetic\GenomeManagerForDrivenBySharpeRatio.cs" /> <Compile Include="TickerSelectionTesting\EndOfDayTimerHandlerCTC.cs" /> <Compile Include="TickerSelectionTesting\EndOfDayTimerHandlerCTO.cs" /> *************** *** 133,136 **** --- 143,148 ---- <Compile Include="TickerSelectionTesting\OTC\OTC_Intraday\OTCIntradayStrategy.cs" /> <Compile Include="TickerSelectionTesting\OTC\OTC_Intraday\OTCIntradayLogItem.cs" /> + <Compile Include="TickerSelectionTesting\OTC_CTO\OTC_CTO_EOD\OTC_CTO_EODMain.cs" /> + <Compile Include="TickerSelectionTesting\OTC_CTO\OTC_CTO_EOD\OTC_CTO_EODStrategy.cs" /> <Compile Include="TickerSelectionTesting\RunEfficientCTCPortfolio.cs" /> <Compile Include="TickerSelectionTesting\RunEfficientCTOPortfolio.cs" /> *************** *** 359,362 **** --- 371,381 ---- <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\WeightedPVO" /> <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\WeightedPVO\WeightedBalancedPVO" /> + <Folder Include="TickerSelectionTesting\DrivenByFundamentals" /> + <Folder Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider" /> + <Folder Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\InSampleChoosers" /> + <Folder Include="TickerSelectionTesting\DrivenByFundamentals\DrivenByFairValueProvider\InSampleChoosers\Genetic" /> + <Folder Include="TickerSelectionTesting\DrivenBySharpeRatio" /> + <Folder Include="TickerSelectionTesting\DrivenBySharpeRatio\InSampleChoosers" /> + <Folder Include="TickerSelectionTesting\DrivenBySharpeRatio\InSampleChoosers\Genetic" /> <Folder Include="TickerSelectionTesting\OTC" /> <Folder Include="TickerSelectionTesting\OTC\Decoding" /> *************** *** 365,368 **** --- 384,389 ---- <Folder Include="TickerSelectionTesting\OTC\InSampleChoosers" /> <Folder Include="TickerSelectionTesting\OTC\InSampleChoosers\Genetic" /> + <Folder Include="TickerSelectionTesting\OTC_CTO" /> + <Folder Include="TickerSelectionTesting\OTC_CTO\OTC_CTO_EOD" /> <Folder Include="TickerSelectionTesting\SimpleSelection\" /> <Folder Include="WalkForwardTesting\FixedLengthTwoPhases" /> |
|
From: Marco M. <mi...@us...> - 2011-01-16 19:52:39
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv2823/b2_DataAccess Modified Files: DataAccess_SD.csproj Log Message: Updated sharp develop project files Index: DataAccess_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataAccess_SD.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DataAccess_SD.csproj 8 Feb 2009 16:41:27 -0000 1.7 --- DataAccess_SD.csproj 16 Jan 2011 19:52:32 -0000 1.8 *************** *** 71,74 **** --- 71,75 ---- <Compile Include="SqlExecutor.cs" /> <Compile Include="Tables\Bars.cs" /> + <Compile Include="Tables\FinancialValues.cs" /> <Compile Include="ValidationTypes.cs" /> <Compile Include="Tables\FaultyTickers.cs" /> |
|
From: Marco M. <mi...@us...> - 2011-01-16 19:52:39
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv2823/b3_Data Modified Files: Data_SD.csproj Log Message: Updated sharp develop project files Index: Data_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Data_SD.csproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Data_SD.csproj 27 Mar 2010 17:30:10 -0000 1.9 --- Data_SD.csproj 16 Jan 2011 19:52:31 -0000 1.10 *************** *** 78,81 **** --- 78,82 ---- <Compile Include="Selectors\SelectorByIntradayQuotationAtEachMarketDay.cs" /> <Compile Include="Selectors\SelectorByLiquidity.cs" /> + <Compile Include="Selectors\SelectorByNumOfMinGrowingIncomesInARow.cs" /> <Compile Include="Selectors\SelectorByOpenToCloseLinearCorrelation.cs" /> <Compile Include="Selectors\SelectorByOpenToCloseVolatility.cs" /> |