[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOs
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-04-09 18:14:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO
In directory sc8-pr-cvs16:/tmp/cvs-serv9486/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO
Modified Files:
EndOfDayTimerHandlerBiasedPVO.cs
Log Message:
Minor changes
Index: EndOfDayTimerHandlerBiasedPVO.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/EndOfDayTimerHandlerBiasedPVO.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EndOfDayTimerHandlerBiasedPVO.cs 27 Feb 2007 22:52:41 -0000 1.1
--- EndOfDayTimerHandlerBiasedPVO.cs 9 Apr 2007 18:14:09 -0000 1.2
***************
*** 56,62 ****
protected Hashtable genomesCollector;
protected bool takeProfitConditionReached;
- new protected string[,] chosenTickers;
- new protected double[,] chosenTickersPortfolioWeights;
new protected double[] currentOversoldThreshold;
new protected double[] currentOverboughtThreshold;
--- 56,62 ----
protected Hashtable genomesCollector;
protected bool takeProfitConditionReached;
+ protected string[,] bestGenomesChosenTickers;
+ protected double[,] bestGenomesChosenTickersPortfolioWeights;
new protected double[] currentOversoldThreshold;
new protected double[] currentOverboughtThreshold;
***************
*** 101,106 ****
this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample;
this.minimumAcceptableGain = minimumAcceptableGain;
! this.chosenTickers = new string[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen];
! this.chosenTickersPortfolioWeights = new double[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen];
this.currentOversoldThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample];
this.currentOverboughtThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample];
--- 101,106 ----
this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample;
this.minimumAcceptableGain = minimumAcceptableGain;
! this.bestGenomesChosenTickers = new string[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen];
! this.bestGenomesChosenTickersPortfolioWeights = new double[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen];
this.currentOversoldThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample];
this.currentOverboughtThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample];
***************
*** 127,132 ****
for(int i = 0; i < this.numberOfTickersToBeChosen; i++)
{
! tickers[i] = this.chosenTickers[indexForChosenTickers,i];
! tickerWeights[i] = this.chosenTickersPortfolioWeights[indexForChosenTickers,i];
}
returnValue =
--- 127,132 ----
for(int i = 0; i < this.numberOfTickersToBeChosen; i++)
{
! tickers[i] = this.bestGenomesChosenTickers[indexForChosenTickers,i];
! tickerWeights[i] = this.bestGenomesChosenTickersPortfolioWeights[indexForChosenTickers,i];
}
returnValue =
***************
*** 190,196 ****
this.takeProfitConditionReached ||
this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization )
- //reversal conditions have not been reached but
//stop loss or take profit conditions yes
! //or after the close it is necessary to run
//another optimization
{
--- 190,195 ----
this.takeProfitConditionReached ||
this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization )
//stop loss or take profit conditions yes
! //or after the next close it is necessary to run
//another optimization
{
***************
*** 251,261 ****
{
string[] tickers = new string[this.numberOfTickersToBeChosen];
for(int i = 0; i < this.numberOfTickersToBeChosen; i++)
! tickers[i] = this.chosenTickers[this.currentGenomeIndex,i];
! if(this.currentTickersGainOrLoss >= 1.0 + currentOverboughtThreshold[this.currentGenomeIndex] &&
this.portfolioType == PortfolioType.ShortAndLong)
{
SignedTicker.ChangeSignOfEachTicker(tickers);
! base.openPositions(tickers);
this.portfolioHasBeenOverbought = true;
this.portfolioHasBeenOversold = false;
--- 250,264 ----
{
string[] tickers = new string[this.numberOfTickersToBeChosen];
+ double[] tickersWeights = new double[this.numberOfTickersToBeChosen];
for(int i = 0; i < this.numberOfTickersToBeChosen; i++)
! {
! tickers[i] = this.bestGenomesChosenTickers[this.currentGenomeIndex,i];
! tickersWeights[i] = this.bestGenomesChosenTickersPortfolioWeights[this.currentGenomeIndex,i];
! }
! if(this.currentTickersGainOrLoss >= 1.0 + currentOverboughtThreshold[this.currentGenomeIndex] &&
this.portfolioType == PortfolioType.ShortAndLong)
{
SignedTicker.ChangeSignOfEachTicker(tickers);
! base.openPositions(tickers, tickersWeights);
this.portfolioHasBeenOverbought = true;
this.portfolioHasBeenOversold = false;
***************
*** 263,267 ****
else if (this.currentTickersGainOrLoss <= 1.0 - currentOversoldThreshold[this.currentGenomeIndex])
{
! base.openPositions(tickers);
this.portfolioHasBeenOverbought = false;
this.portfolioHasBeenOversold = true;
--- 266,270 ----
else if (this.currentTickersGainOrLoss <= 1.0 - currentOversoldThreshold[this.currentGenomeIndex])
{
! base.openPositions(tickers, tickersWeights);
this.portfolioHasBeenOverbought = false;
this.portfolioHasBeenOversold = true;
***************
*** 303,307 ****
this.marketCloseEventHandler_closeIfItIsTimeToClose();
else if ( this.account.Portfolio.Count == 0 &&
! this.chosenTickers[0,0] != null )
//portfolio is empty and optimization has been already launched
this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender);
--- 306,310 ----
this.marketCloseEventHandler_closeIfItIsTimeToClose();
else if ( this.account.Portfolio.Count == 0 &&
! this.bestGenomesChosenTickers[0,0] != null )
//portfolio is empty and optimization has been already launched
this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender);
***************
*** 324,337 ****
{
currentGenome = (Genome)GO.CurrentGeneration[GO.PopulationSize - 1 - counter];
! if(counter == 0 ||
! !this.genomesCollector.ContainsKey(currentGenome.Fitness) )
! //it is the first genome to be added or no genome with the current
// fitness has been added to the hashtable yet
{
for(int i = 0; i<this.numberOfTickersToBeChosen; i++)
{
! this.chosenTickers[addedGenomes,i] =
((GenomeMeaningPVO)currentGenome.Meaning).Tickers[i];
! this.chosenTickersPortfolioWeights[addedGenomes,i] =
((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights[i];
}
--- 327,342 ----
{
currentGenome = (Genome)GO.CurrentGeneration[GO.PopulationSize - 1 - counter];
! if( counter == 0 ||
! !this.genomesCollector.ContainsKey(
! ( (GenomeMeaning)currentGenome.Meaning ).HashCodeForTickerComposition ) )
! // currentGenome.Fitness) )
! //it is the first genome to be added or no genome with the current
// fitness has been added to the hashtable yet
{
for(int i = 0; i<this.numberOfTickersToBeChosen; i++)
{
! this.bestGenomesChosenTickers[addedGenomes,i] =
((GenomeMeaningPVO)currentGenome.Meaning).Tickers[i];
! this.bestGenomesChosenTickersPortfolioWeights[addedGenomes,i] =
((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights[i];
}
***************
*** 341,346 ****
((GenomeMeaningPVO)currentGenome.Meaning).OverboughtThreshold;
! this.genomesCollector.Add(currentGenome.Fitness, null);
!
this.addPVOGenomeToBestGenomes(currentGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate,
((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, eligibleTickersForGO,
--- 346,352 ----
((GenomeMeaningPVO)currentGenome.Meaning).OverboughtThreshold;
! this.genomesCollector.Add(
! ( (GenomeMeaning)currentGenome.Meaning ).HashCodeForTickerComposition, null);
! // currentGenome.Fitness,null);
this.addPVOGenomeToBestGenomes(currentGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate,
((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, eligibleTickersForGO,
***************
*** 358,362 ****
DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate);
this.iGenomeManager =
! new GenomeManagerPVO(setOfTickersToBeOptimized,
currentDate.AddDays(-this.numDaysForOptimizationPeriod),
currentDate, this.numberOfTickersToBeChosen,
--- 364,368 ----
DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate);
this.iGenomeManager =
! new GenomeManagerWeightedBalancedPVO(setOfTickersToBeOptimized,
currentDate.AddDays(-this.numDaysForOptimizationPeriod),
currentDate, this.numberOfTickersToBeChosen,
***************
*** 376,380 ****
if(setGenomeCounter)
this.genomeCounter = new GenomeCounter(GO);
! GO.MutationRate = 0.4;
GO.Run(false);
--- 382,388 ----
if(setGenomeCounter)
this.genomeCounter = new GenomeCounter(GO);
!
! GO.MutationRate = 0.1;
! GO.CrossoverRate = 0.85;
GO.Run(false);
|