Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv32724/b7_Scripts/TickerSelectionTesting
Modified Files:
GenomeManagerForEfficientPortfolio.cs
Log Message:
Added the OTC - CTO strategy using a brute force optimizer:
Decode method has been overloaded with a BruteForceOptimizableParameter parameter.
Index: GenomeManagerForEfficientPortfolio.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** GenomeManagerForEfficientPortfolio.cs 7 Aug 2006 21:03:24 -0000 1.24
--- GenomeManagerForEfficientPortfolio.cs 17 Sep 2006 21:41:37 -0000 1.25
***************
*** 26,29 ****
--- 26,30 ----
using QuantProject.ADT.Statistics;
using QuantProject.ADT.Optimizing.Genetic;
+ using QuantProject.ADT.Optimizing.BruteForce;
using QuantProject.Data;
using QuantProject.Data.DataTables;
***************
*** 68,82 ****
//IGenomeManager implementation for properties
! public int GenomeSize
{
get{return this.genomeSize;}
}
! public int GetMinValueForGenes(int genePosition)
{
return this.minValueForGenes;
}
! public int GetMaxValueForGenes(int genePosition)
{
return this.maxValueForGenes;
--- 69,83 ----
//IGenomeManager implementation for properties
! public virtual int GenomeSize
{
get{return this.genomeSize;}
}
! public virtual int GetMinValueForGenes(int genePosition)
{
return this.minValueForGenes;
}
! public virtual int GetMaxValueForGenes(int genePosition)
{
return this.maxValueForGenes;
***************
*** 239,242 ****
--- 240,271 ----
}
+ public virtual double GetFitnessValue(BruteForceOptimizableParameters bruteForceOptimizableParameters)
+ {
+ double returnValue = 0;
+ this.portfolioRatesOfReturn =
+ this.getPortfolioRatesOfReturn(bruteForceOptimizableParameters.GetValues());
+ double averagePortfolioRateOfReturn =
+ BasicFunctions.SimpleAverage(this.portfolioRatesOfReturn);
+
+ double portfolioVariance =
+ BasicFunctions.Variance(this.portfolioRatesOfReturn);
+
+ if(!Double.IsInfinity(portfolioVariance) &&
+ !Double.IsInfinity(averagePortfolioRateOfReturn) &&
+ !Double.IsNaN(portfolioVariance) &&
+ !Double.IsNaN(averagePortfolioRateOfReturn) &&
+ portfolioVariance > 0.0)
+ //both variance and rate of return are
+ //double values computed in the right way:
+ // so it's possible to assign fitness
+ {
+ this.variance = portfolioVariance;
+ this.rateOfReturn = averagePortfolioRateOfReturn;
+ returnValue = this.getFitnessValue_calculate();
+ }
+
+ return returnValue;
+ }
+
#endregion
***************
*** 301,304 ****
--- 330,347 ----
}
+ public virtual object Decode(BruteForceOptimizableParameters bruteForceOptimizableParameters)
+ {
+ string[] arrayOfTickers =
+ new string[bruteForceOptimizableParameters.GetValues().Length];
+ int indexOfTicker;
+ for(int index = 0; index < bruteForceOptimizableParameters.GetValues().Length; index++)
+ {
+ indexOfTicker = bruteForceOptimizableParameters.GetValues()[index];
+ arrayOfTickers[index] = this.decode_getTickerCodeForLongOrShortTrade(indexOfTicker);
+ }
+ GenomeMeaning meaning = new GenomeMeaning(arrayOfTickers);
+ return meaning;
+ }
+
public virtual object Decode(Genome genome)
{
***************
*** 388,392 ****
#region getPortfolioRatesOfReturn
! protected int getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInArray(int geneValueForTickerIdx)
{
int position = geneValueForTickerIdx;
--- 431,435 ----
#region getPortfolioRatesOfReturn
! protected int getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInSetOfCandidates(int geneValueForTickerIdx)
{
int position = geneValueForTickerIdx;
***************
*** 404,408 ****
//genes[tickerPositionInGenes], the code for ticker, points to a ticker for which long returns are to be examined
longReturns = true;
! int position = this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInArray(genes[tickerPositionInGenes]);
this.setOfCandidates[position].LongRatesOfReturn = longReturns;
float[] arrayOfRatesOfReturn = this.setOfCandidates[position].ArrayOfRatesOfReturn;
--- 447,451 ----
//genes[tickerPositionInGenes], the code for ticker, points to a ticker for which long returns are to be examined
longReturns = true;
! int position = this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInSetOfCandidates(genes[tickerPositionInGenes]);
this.setOfCandidates[position].LongRatesOfReturn = longReturns;
float[] arrayOfRatesOfReturn = this.setOfCandidates[position].ArrayOfRatesOfReturn;
|