quantproject-developers Mailing List for QuantProject (Page 81)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:48:20
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27076/b1_ADT Modified Files: b1_ADT.csproj Log Message: - Optimizing\BruteForce\BruteForceOptimizableParameters.cs has been added - Optimizing\BruteForce\BruteForceOptimizer.cs has been added - Optimizing\BruteForce\IBruteForceOptimizableParametersManager.cs has been added - Statistics\Combinatorial\Combination.cs has been added Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** b1_ADT.csproj 29 Jun 2006 17:55:26 -0000 1.22 --- b1_ADT.csproj 21 Aug 2006 19:48:17 -0000 1.23 *************** *** 188,191 **** --- 188,206 ---- /> <File + RelPath = "Optimizing\BruteForce\BruteForceOptimizableParameters.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Optimizing\BruteForce\BruteForceOptimizer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Optimizing\BruteForce\IBruteForceOptimizableParametersManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Optimizing\Genetic\GeneticOptimizer.cs" SubType = "Code" *************** *** 257,260 **** --- 272,280 ---- BuildAction = "Compile" /> + <File + RelPath = "Statistics\Combinatorial\Combination.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:46:44
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26085/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: - WalkForwardTesting\WalkForwardLag\GeneticOptimizerTesting\WFLagGOTester.cs has been added - WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagBruteForceOptimizableParametersManager.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** b7_Scripts.csproj 3 Aug 2006 21:33:16 -0000 1.60 --- b7_Scripts.csproj 21 Aug 2006 19:46:41 -0000 1.61 *************** *** 664,667 **** --- 664,677 ---- /> <File + RelPath = "WalkForwardTesting\WalkForwardLag\GeneticOptimizerTesting\WFLagGOTester.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagBruteForceOptimizableParametersManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagChosenPositions.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:45:08
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/Combinatorial In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25350 Added Files: Combination.cs Log Message: Enumerates all combinations of integer values within a given range of integers --- NEW FILE: Combination.cs --- using System; using System.Collections; namespace QuantProject.ADT.Statistics.Combinatorial { /// <summary> /// Enumerates all combinations of integer values within a given /// range of integers /// </summary> public class Combination : IEnumerator { private int[] currentCombinationValues; private int minValue; private int maxValue; private int length; public int Length { get { return this.length; } } /// <summary> /// Enumerates all combinations of integer values within a given /// range of integers /// </summary> /// <param name="minValue">min value for combination elements</param> /// <param name="maxValue">max value for combination elements</param> /// <param name="length">combination length</param> public Combination( int minValue , int maxValue , int length ) { this.checkParameters( minValue , maxValue , length ); this.minValue = minValue; this.maxValue = maxValue; this.length = length; this.currentCombinationValues = new int[ length ]; } private void checkParameters( int minValue , int maxValue , int length ) { if ( minValue >= maxValue ) throw new Exception( "minValue is not less then maxValue!" ); if ( length <= 0 ) throw new Exception( "length is not greater than zero!" ); } #region Current public object Current { get { return this.getCurrent(); } } private int[] getCurrent() { return this.currentCombinationValues; } #endregion public void Reset() { for ( int currentComponentIndex = 0 ; currentComponentIndex < this.length ; currentComponentIndex ++ ) this.currentCombinationValues[ currentComponentIndex ] = this.minValue + currentComponentIndex; } #region MoveNext private int getMaxValueForElement( int elementIndex ) { int maxValueForElement = this.maxValue - ( this.length - 1 - elementIndex ); return maxValueForElement; } private bool hasNotReachedItsMaxValue( int indexToCheck ) { int maxValueToReach = this.getMaxValueForElement( indexToCheck ); return ( this.currentCombinationValues[ indexToCheck ] < maxValueToReach ); } private int getIndexOfTheFirstItemThatHasNotReachedItsMaxValue() { int indexOfTheFirstItemThatHasNotReachedItsMaxValue = -1 ; bool isIndexFound = false; int indexToCheck = this.length - 1; while ( ( !isIndexFound ) && ( indexToCheck >= 0 ) ) { if ( this.hasNotReachedItsMaxValue( indexToCheck ) ) { indexOfTheFirstItemThatHasNotReachedItsMaxValue = indexToCheck; isIndexFound = true; } else indexToCheck -- ; } return indexOfTheFirstItemThatHasNotReachedItsMaxValue; } private void moveNextActually( int indexOfTheFirstItemThatHasNotReachedItsMaxValue ) { this.currentCombinationValues[ indexOfTheFirstItemThatHasNotReachedItsMaxValue ] ++ ; for ( int i = indexOfTheFirstItemThatHasNotReachedItsMaxValue + 1 ; i < this.currentCombinationValues.Length; i++ ) { this.currentCombinationValues[ i ] = this.currentCombinationValues[ i - 1 ] + 1; } } public bool MoveNext() { bool isNotLastCombination = true; int indexOfTheFirstItemThatHasNotReachedItsMaxValue = this.getIndexOfTheFirstItemThatHasNotReachedItsMaxValue(); if ( indexOfTheFirstItemThatHasNotReachedItsMaxValue == -1 ) // no more combinations to be generated: every item has // reached its max value isNotLastCombination = false; else this.moveNextActually( indexOfTheFirstItemThatHasNotReachedItsMaxValue ); return isNotLastCombination; } #endregion public int GetValue( int elementIndex ) { return this.currentCombinationValues[ elementIndex ]; } } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:44:26
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/Combinatorial In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24919/Combinatorial Log Message: Directory /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/Combinatorial added to the repository |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:43:55
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24468 Added Files: BruteForceOptimizableParameters.cs Log Message: Parameters to be optimized by a Brute Force optimizer --- NEW FILE: BruteForceOptimizableParameters.cs --- /* QuantProject - Quantitative Finance Library BruteForceOptimizableParameters.cs Copyright (C) 2006 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.ADT.Optimizing.BruteForce { /// <summary> /// Parameters to be optimized by a Brute Force optimizer /// </summary> public class BruteForceOptimizableParameters { IBruteForceOptimizableParametersManager bruteForceOptimizableParametersManager; private bool isFitnessSet; private double fitness; private int[] parameterValues; /// <summary> /// Fitness value for current parameters value /// </summary> public double Fitness { get { if ( !this.isFitnessSet ) { this.fitness = this.bruteForceOptimizableParametersManager.GetFitnessValue( this ); this.isFitnessSet = true; } return this.fitness; } } public int Length { get { return this.parameterValues.Length; } } public BruteForceOptimizableParameters( int[] parameterValues , IBruteForceOptimizableParametersManager bruteForceOptimizableParametersManager ) { this.parameterValues = parameterValues; this.bruteForceOptimizableParametersManager = bruteForceOptimizableParametersManager; this.isFitnessSet = false; } public int[] GetValues() { return this.parameterValues; } } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:42:18
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23844 Added Files: BruteForceOptimizer.cs Log Message: Optimizer that enumerates all possible parameter values --- NEW FILE: BruteForceOptimizer.cs --- /* QuantProject - Quantitative Finance Library BruteForceOptimizer.cs Copyright (C) 2006 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT; namespace QuantProject.ADT.Optimizing.BruteForce { /// <summary> /// Optimizer that enumerates all possible parameter values /// </summary> public class BruteForceOptimizer : IProgressNotifier { private IBruteForceOptimizableParametersManager bruteForceOptimizableParametersManager; private BruteForceOptimizableParameters bestParameters; private int analizedItems; public event NewProgressEventHandler NewProgress; public BruteForceOptimizableParameters BestParameters { get { return this.bestParameters; } } public BruteForceOptimizer( IBruteForceOptimizableParametersManager bruteForceOptimizableParametersManager ) { this.bruteForceOptimizableParametersManager = bruteForceOptimizableParametersManager; } #region Run private void handleProgress() { analizedItems ++ ; if ( analizedItems % 100000 == 0 ) { NewProgressEventArgs newProgressEventArgs = new NewProgressEventArgs( analizedItems , 0 ); if ( this.NewProgress != null ) this.NewProgress( this , newProgressEventArgs ); } } /// <summary> /// executes the optimization /// </summary> public void Run() { this.analizedItems = 0; this.bruteForceOptimizableParametersManager.Reset(); this.bestParameters = (BruteForceOptimizableParameters)this.bruteForceOptimizableParametersManager.Current; while( this.bruteForceOptimizableParametersManager.MoveNext() ) { BruteForceOptimizableParameters bruteForceOptimizableParameter = (BruteForceOptimizableParameters)this.bruteForceOptimizableParametersManager.Current; if ( this.bestParameters.Fitness < bruteForceOptimizableParameter.Fitness ) this.bestParameters = bruteForceOptimizableParameter; this.handleProgress(); } } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:40:48
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22825 Added Files: IBruteForceOptimizableParametersManager.cs Log Message: Interface to be implemented by any object used to run an instance of the BruteForceOptimizer class. --- NEW FILE: IBruteForceOptimizableParametersManager.cs --- /* QuantProject - Quantitative Finance Library IBruteForceOptimizableParametersManager.cs Copyright (C) 2006 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; namespace QuantProject.ADT.Optimizing.BruteForce { /// <summary> /// Interface to be implemented by any object used to run /// an instance of the BruteForceOptimizer class. /// </summary> public interface IBruteForceOptimizableParametersManager : IEnumerator { double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableParameters ); object Decode( BruteForceOptimizableParameters bruteForceOptimizableParameters ); } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:39:13
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22122/BruteForce Log Message: Directory /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce added to the repository |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:37:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21110 Added Files: WFLagBruteForceOptimizableParametersManager.cs Log Message: This class implements IBruteForceOptimizableParametersManager, in order to find the best driving position group and the best portfolio position group with respect to the lag strategy. Weights are NOT used in this implementation --- NEW FILE: WFLagBruteForceOptimizableParametersManager.cs --- /* QuantProject - Quantitative Finance Library WFLagBruteForceOptimizableParametersManager.cs Copyright (C) 2006 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using QuantProject.ADT.Optimizing.BruteForce; using QuantProject.ADT.Statistics.Combinatorial; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// This class implements IBruteForceOptimizableParametersManager, /// in order to find the best driving position group and the best /// portfolio position group with respect to the lag strategy. /// Weights are NOT used in this implementation /// </summary> public class WFLagBruteForceOptimizableParametersManager : IBruteForceOptimizableParametersManager { private Combination drivingCombination; private Combination portfolioCombination; private int numberOfDrivingPositions; private int numberOfPortfolioPositions; private WFLagGenomeManager wFLagGenomeManager; private DataTable eligibleTickersForDrivingPositions; private DataTable eligibleTickersForPortfolioPositions; public WFLagBruteForceOptimizableParametersManager( DataTable eligibleTickersForDrivingPositions , DataTable eligibleTickersForPortfolioPositions , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int numberOfDrivingPositions , int numberOfPortfolioPositions ) { this.eligibleTickersForDrivingPositions = eligibleTickersForDrivingPositions; this.eligibleTickersForPortfolioPositions = eligibleTickersForPortfolioPositions; this.numberOfDrivingPositions = numberOfDrivingPositions; this.numberOfPortfolioPositions = numberOfPortfolioPositions; this.drivingCombination = new Combination( - eligibleTickersForDrivingPositions.Rows.Count , eligibleTickersForDrivingPositions.Rows.Count - 1 , numberOfDrivingPositions ); this.portfolioCombination = new Combination( - eligibleTickersForPortfolioPositions.Rows.Count , eligibleTickersForPortfolioPositions.Rows.Count - 1 , numberOfPortfolioPositions ); this.wFLagGenomeManager = new WFLagGenomeManager( eligibleTickersForDrivingPositions , eligibleTickersForPortfolioPositions , firstOptimizationDate , lastOptimizationDate , numberOfDrivingPositions , numberOfPortfolioPositions , QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); } public bool MoveNext() { bool isNotTheLast = true; if ( !this.portfolioCombination.MoveNext() ) { // last portfolio combination this.portfolioCombination.Reset(); isNotTheLast = this.drivingCombination.MoveNext(); } return isNotTheLast; } public void Reset() { this.drivingCombination.Reset(); this.portfolioCombination.Reset(); } #region Current public object Current { get { return this.getCurrent(); } } private object getCurrent() { int[] currentValues = new int[ this.drivingCombination.Length + this.portfolioCombination.Length ]; for ( int i = 0 ; i < this.drivingCombination.Length ; i ++ ) currentValues[ i ] = this.drivingCombination.GetValue( i ); for ( int i = this.drivingCombination.Length ; i < this.drivingCombination.Length + this.portfolioCombination.Length ; i ++ ) currentValues[ i ] = this.portfolioCombination.GetValue( i - this.drivingCombination.Length ); BruteForceOptimizableParameters bruteForceOptimizableParameters = new BruteForceOptimizableParameters( currentValues , this ); return bruteForceOptimizableParameters; } #endregion #region Decode private double getWeight( int[] optimizableItem , int index ) { int weight = 1; if ( optimizableItem[ index ] < 0 ) // the position is short weight = -1; return weight; } private double[] getWeightRelatedParameterValuesForDrivingPositions( int[] optimizableParameters ) { double[] weightRelatedParameterValuesForDrivingPositions = new double[ this.numberOfDrivingPositions ]; for ( int parameterPosition = 0 ; parameterPosition < this.numberOfDrivingPositions ; parameterPosition++ ) weightRelatedParameterValuesForDrivingPositions[ parameterPosition ] = this.getWeight( optimizableParameters , parameterPosition ) / this.numberOfDrivingPositions; return weightRelatedParameterValuesForDrivingPositions; } private int getTickerIndexForDrivingPositions( int[] parameterValues , int parameterPosition ) { int tickerIndex = parameterValues[ parameterPosition ]; if ( tickerIndex < 0 ) // the position is short tickerIndex += this.eligibleTickersForDrivingPositions.Rows.Count; return tickerIndex; } private int[] getTickerRelatedParameterValuesForDrivingPositions( int[] optimizableParameters ) { int[] tickerRelatedParameterValuesForDrivingPositions = new int[ this.numberOfDrivingPositions ]; for ( int parameterPosition = 0 ; parameterPosition < this.numberOfDrivingPositions ; parameterPosition++ ) tickerRelatedParameterValuesForDrivingPositions[ parameterPosition ] = this.getTickerIndexForDrivingPositions( optimizableParameters , parameterPosition ); return tickerRelatedParameterValuesForDrivingPositions; } private double[] getWeightRelatedParameterValuesForPortfolioPositions( int[] optimizableParameters ) { double[] weightRelatedParameterValuesForPortfolioPositions = new double[ this.numberOfPortfolioPositions ]; int firstPositionForPortfolioRelatedGenomes = this.numberOfDrivingPositions; for ( int i = 0 ; i < this.numberOfPortfolioPositions ; i++ ) { int parameterPosition = firstPositionForPortfolioRelatedGenomes + i; weightRelatedParameterValuesForPortfolioPositions[ i ] = this.getWeight( optimizableParameters , parameterPosition ) / this.numberOfPortfolioPositions; } return weightRelatedParameterValuesForPortfolioPositions; } private int getTickerIndexForPortfolioPositions( int[] parameterValues , int parameterPosition ) { int tickerIndex = parameterValues[ parameterPosition ]; if ( tickerIndex < 0 ) // the position is short tickerIndex += this.eligibleTickersForPortfolioPositions.Rows.Count; return tickerIndex; } private int[] getTickerRelatedParameterValuesForPortfolioPositions( int[] parameterValues ) { int[] tickerRelatedParameterValuesForPortfolioPositions = new int[ this.numberOfPortfolioPositions ]; int firstPositionForPortfolioRelatedGenomes = this.numberOfDrivingPositions; for ( int i = 0 ; i < this.numberOfPortfolioPositions ; i++ ) { int parameterPosition = firstPositionForPortfolioRelatedGenomes + i; tickerRelatedParameterValuesForPortfolioPositions[ i ] = this.getTickerIndexForPortfolioPositions( parameterValues , parameterPosition ); } return tickerRelatedParameterValuesForPortfolioPositions; } #region decodeWeightedPositions private string[] decodeTickers( int[] tickerRelatedParameterValues , DataTable eligibleTickers ) { string[] tickers = new string[ tickerRelatedParameterValues.Length ]; for( int i = 0 ; i < tickerRelatedParameterValues.Length ; i++ ) { int currentParameterValue = tickerRelatedParameterValues[ i ]; tickers[ i ] = ( string )eligibleTickers.Rows[ currentParameterValue ][ 0 ]; } return tickers; } private WeightedPositions decodeWeightedPositions( double[] weightRelatedParameterValues , int[] tickerRelatedParameterValues , DataTable eligibleTickers ) { string[] tickers = this.decodeTickers( tickerRelatedParameterValues , eligibleTickers ); WeightedPositions weightedPositions = new WeightedPositions( weightRelatedParameterValues , tickers ); return weightedPositions; } #endregion private WeightedPositions decodeDrivingWeightedPositions( int[] optimizableItemValues ) { double[] weightRelatedParameterValuesForDrivingPositions = this.getWeightRelatedParameterValuesForDrivingPositions( optimizableItemValues ); int[] tickerRelatedParameterValuesForDrivingPositions = this.getTickerRelatedParameterValuesForDrivingPositions( optimizableItemValues ); return decodeWeightedPositions( weightRelatedParameterValuesForDrivingPositions , tickerRelatedParameterValuesForDrivingPositions , this.eligibleTickersForDrivingPositions ); } private WeightedPositions decodePortfolioWeightedPositions( int[] optimizableParameters ) { double[] weightRelatedParameterValuesForPortfolioPositions = this.getWeightRelatedParameterValuesForPortfolioPositions( optimizableParameters ); int[] tickerRelatedParameterValuesForPortfolioPositions = this.getTickerRelatedParameterValuesForPortfolioPositions( optimizableParameters ); return decodeWeightedPositions( weightRelatedParameterValuesForPortfolioPositions , tickerRelatedParameterValuesForPortfolioPositions , this.eligibleTickersForPortfolioPositions ); } public object Decode( BruteForceOptimizableParameters bruteForceOptimizableItem ) { int[] optimizableItemValues = bruteForceOptimizableItem.GetValues(); WeightedPositions drivingWeightedPositions = this.decodeDrivingWeightedPositions( optimizableItemValues ); WeightedPositions portfolioWeightedPositions = this.decodePortfolioWeightedPositions( optimizableItemValues ); WFLagWeightedPositions wFLagWeightedPositions = new WFLagWeightedPositions( drivingWeightedPositions , portfolioWeightedPositions ); return wFLagWeightedPositions; } #endregion #region GetFitnessValue public double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableItem ) { double fitnessValue; WFLagWeightedPositions wFLagWeightedPositions = ( WFLagWeightedPositions )this.Decode( bruteForceOptimizableItem ); int optimizableItem = bruteForceOptimizableItem.Length; int decodedWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions.Count + wFLagWeightedPositions.PortfolioWeightedPositions.Count; if ( decodedWeightedPositions < optimizableItem ) // the optimizable parameters object // contains a duplicate element either for // driving positions or for portfolio positions //fitnessValue = double.MinValue; fitnessValue = -0.2; else // all driving position parameters are distinct and // all portfolio position parameters are distinct fitnessValue = this.wFLagGenomeManager.GetFitnessValue( wFLagWeightedPositions ); return fitnessValue; } #endregion private int getMinValueForParameter( int parameterPosition ) { int minValueForParameter = -this.eligibleTickersForDrivingPositions.Rows.Count; if ( parameterPosition >= this.numberOfDrivingPositions ) // the parameter is for a portfolio position minValueForParameter = -this.eligibleTickersForPortfolioPositions.Rows.Count; return minValueForParameter; } private int getMaxValueForParameter( int parameterPosition ) { int maxValueForParameter = this.eligibleTickersForDrivingPositions.Rows.Count - 1; if ( parameterPosition >= this.numberOfDrivingPositions ) // the parameter is for a portfolio position maxValueForParameter = this.eligibleTickersForPortfolioPositions.Rows.Count - 1; return maxValueForParameter; } } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:33:51
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19059 Added Files: WFLagGOTester.cs Log Message: Used to test the GeneticOptimizer and the genome manager effectiveness --- NEW FILE: WFLagGOTester.cs --- /* QuantProject - Quantitative Finance Library WFLagGOTester.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Collections; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// Used to test the GeneticOptimizer and the genome manager /// effectiveness /// </summary> [Serializable] public class WFLagGOTester : WFLagChosenTickers { private WeightedPositions drivingWeightedPositions; private WeightedPositions portfolioWeightedPositions; private DateTime firstOptimizationDate; private DateTime lastOptimizationDate; private int generation; // public QPHashtable PortfolioPositions // { // get // { // return this.portfolioPositions; // } // } // public QPHashtable DrivingPositions // { // get // { // return this.drivingPositions; // } // } public WFLagGOTester( int numberOfDrivingPositions , int numberOfPositionsToBeChosen , int inSampleDays , IEndOfDayTimer endOfDayTimer , int generationNumberForGeneticOptimizer , int populationSizeForGeneticOptimizer ) : base( numberOfDrivingPositions , numberOfPositionsToBeChosen , inSampleDays , endOfDayTimer , generationNumberForGeneticOptimizer , populationSizeForGeneticOptimizer ) { } // { // this.eligibleTickers = eligibleTickers; // this.numberOfDrivingPositions = numberOfDrivingPositions; // this.numberOfPositionsToBeChosen = numberOfPositionsToBeChosen; // this.inSampleDays = inSampleDays; // this.endOfDayTimer = endOfDayTimer; // this.generationNumberForGeneticOptimizer = // generationNumberForGeneticOptimizer; // this.populationSizeForGeneticOptimizer = // populationSizeForGeneticOptimizer; // } #region SetWeightedPositions // private void setSignedTickers_clearPositions() // { // this.drivingPositions.Clear(); // this.portfolioPositions.Clear(); // } // private void newGenerationEventHandler( // object sender , NewGenerationEventArgs e ) // { // this.NewProgress( sender , // new NewProgressEventArgs( e.GenerationCounter , e.GenerationNumber ) ); // } private void setSignedTickers_setTickersFromGenome( IGenomeManager genomeManager , Genome genome ) { WFLagWeightedPositions wFLagWeightedPositions = ( WFLagWeightedPositions )genomeManager.Decode( genome ); this.drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; this.portfolioWeightedPositions = wFLagWeightedPositions.PortfolioWeightedPositions; } private double getBestGenome( WFLagEligibleTickers eligibleTickers , int seed , int populationSize , int generationNumber ) { this.firstOptimizationDate = this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( -( this.inSampleDays - 1 ) ); this.lastOptimizationDate = this.endOfDayTimer.GetCurrentTime().DateTime; WFLagGenomeManager genomeManager = new WFLagGenomeManager( eligibleTickers.EligibleTickers , eligibleTickers.EligibleTickers , this.firstOptimizationDate , this.lastOptimizationDate , this.numberOfDrivingPositions , this.numberOfPositionsToBeChosen , seed * 100 ); GeneticOptimizer geneticOptimizer = new GeneticOptimizer( 0.85 , 0.02 , 0.10 , populationSize , generationNumber , genomeManager , ConstantsProvider.SeedForRandomGenerator ); // geneticOptimizer.NewGeneration += // new NewGenerationEventHandler( this.newGenerationEventHandler ); geneticOptimizer.Run( false ); this.setSignedTickers_setTickersFromGenome( genomeManager , geneticOptimizer.BestGenome ); this.generation = geneticOptimizer.BestGenome.Generation; return geneticOptimizer.BestGenome.Fitness; } private double getBestGenomeForSingleGeneration( WFLagEligibleTickers eligibleTickers , int seed ) { return this.getBestGenome( eligibleTickers , seed , 100000 , 0 ); } private double getBestGenomeForMultipleGenerations( WFLagEligibleTickers eligibleTickers , int seed ) { return this.getBestGenome( eligibleTickers , seed , 10000 , 9 ); } private void setWeightedPositions( WFLagEligibleTickers eligibleTickers , int seed ) { double bestGenomeForSingleGeneration = this.getBestGenomeForSingleGeneration( eligibleTickers , seed ); double bestGenomeForMultipleGenerations = this.getBestGenomeForMultipleGenerations( eligibleTickers , seed ); Console.WriteLine( "Seed=\t" + seed + "\t; bestForSingle:\t" + bestGenomeForSingleGeneration + "\t; bestForMultiple:\t" + bestGenomeForMultipleGenerations ); } public override void SetWeightedPositions( WFLagEligibleTickers eligibleTickers ) { for ( int i=10 ; i<80 ; i++ ) this.setWeightedPositions( eligibleTickers , i ); System.Windows.Forms.MessageBox.Show( "Test is complete! Check the console output." ); } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:33:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv18829/WFLagBruteForceOptimizableItemManager Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager added to the repository |
|
From: Glauco S. <gla...@us...> - 2006-08-21 19:30:35
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17490/GeneticOptimizerTesting Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting added to the repository |
|
From: Marco M. <mi...@us...> - 2006-08-13 19:01:00
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31453/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Code has been reorganized in a more readable way. Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GeneticOptimizer.cs 11 Aug 2006 18:43:47 -0000 1.20 --- GeneticOptimizer.cs 13 Aug 2006 19:00:55 -0000 1.21 *************** *** 258,261 **** --- 258,263 ---- { //this.run_calculateRandomFitness(); to be tested yet + if (this.genomeSize == 0 || this.genomeSize < 0) + throw new IndexOutOfRangeException("Genome size not set"); this.createFirstGeneration(showOutputToConsole); if(this.keepOnRunningUntilConvergenceIsReached) *************** *** 263,276 **** { for (int i = 0; !this.IsConvergenceReached(); i++) ! { ! this.generateNewPopulation(showOutputToConsole); ! } } else // the GO simply generates the given number of populations and then stops { for (int i = 0; i < this.generationNumber; i++) - { this.generateNewPopulation(showOutputToConsole); - } } } --- 265,274 ---- { for (int i = 0; !this.IsConvergenceReached(); i++) ! this.generateNewPopulation(showOutputToConsole); } else // the GO simply generates the given number of populations and then stops { for (int i = 0; i < this.generationNumber; i++) this.generateNewPopulation(showOutputToConsole); } } *************** *** 279,282 **** --- 277,281 ---- { this.createNextGeneration(); + this.generationCounter++; this.updateBestGenomeFoundInRunning((Genome)this.currentGeneration[populationSize-1]); this.updateWorstGenomeFoundInRunning((Genome)this.currentGeneration[0]); *************** *** 296,312 **** } ! private void createFirstGeneration(bool showOutputToConsole) { - if (this.genomeSize == 0 || this.genomeSize < 0) - throw new IndexOutOfRangeException("Genome size not set"); - this.createGenomes(); this.currentGeneration.Sort(this.genomeComparer); if(this.NewGeneration != null) ! this.NewGeneration( this , new NewGenerationEventArgs( ! this.currentGeneration , this.generationCounter , this.generationNumber ) ); this.calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); this.setInitialBestAndWorstGenomes(); ! if (showOutputToConsole) this.showOutputToConsole(); --- 295,318 ---- } ! private void sortCurrentGenerationAndFireNewGenerationEvent() { this.currentGeneration.Sort(this.genomeComparer); if(this.NewGeneration != null) ! this.NewGeneration( this , new NewGenerationEventArgs( ! this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! } ! ! private void setSpecialFitnessForRouletteSelection() ! { this.calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); + } + + private void createFirstGeneration(bool showOutputToConsole) + { + this.createGenomes(); + this.sortCurrentGenerationAndFireNewGenerationEvent(); this.setInitialBestAndWorstGenomes(); ! this.setSpecialFitnessForRouletteSelection(); if (showOutputToConsole) this.showOutputToConsole(); *************** *** 421,439 **** } ! private void setCurrentEliteToTransmitToNextGeneration() { this.currentEliteToTransmitToNextGeneration.Clear(); for(int i = populationSize - 1; ! i >=(populationSize - this.elitismRate*this.populationSize - 1); ! i--) { ! if(this.currentGeneration[i] is Genome) ! this.currentEliteToTransmitToNextGeneration.Add((Genome)this.currentGeneration[i]); } ! } ! ! private void transmitEliteToNextGeneration() ! { for(int i = 0; i < this.currentEliteToTransmitToNextGeneration.Count; --- 427,442 ---- } ! private void createNextGeneration_transmitEliteToNextGeneration() { this.currentEliteToTransmitToNextGeneration.Clear(); for(int i = populationSize - 1; ! i >=(populationSize - this.elitismRate*this.populationSize - 1); ! i--) { ! if(this.currentGeneration[i] is Genome) ! this.currentEliteToTransmitToNextGeneration.Add((Genome)this.currentGeneration[i]); } ! for(int i = 0; i < this.currentEliteToTransmitToNextGeneration.Count; *************** *** 445,459 **** } ! private void createNextGeneration() { - this.nextGeneration.Clear(); - for (int i = 0 ; i < this.populationSize ; i+=2) { int indexForParent1 = this.rouletteSelection(); int indexForParent2 = this.rouletteSelection(); - Genome parent1, parent2; ! Genome[] childs; parent1 = ((Genome) this.currentGeneration[indexForParent1]); parent2 = ((Genome) this.currentGeneration[indexForParent2]); --- 448,459 ---- } ! private void createNextGeneration_addChildsWithRouletteSelection() { for (int i = 0 ; i < this.populationSize ; i+=2) { int indexForParent1 = this.rouletteSelection(); int indexForParent2 = this.rouletteSelection(); Genome parent1, parent2; ! Genome[] childs; parent1 = ((Genome) this.currentGeneration[indexForParent1]); parent2 = ((Genome) this.currentGeneration[indexForParent2]); *************** *** 461,504 **** { childs = this.genomeManager.GetChilds(parent1, parent2); ! } else {//if the crossover doesn't take place there are only ! //two childs, identical to parents childs = new Genome[2]; childs[0] = parent1.Clone(); childs[1] = parent2.Clone(); } ! foreach(Genome g in childs){ ! this.nextGeneration.Add(g); ! } } ! this.setCurrentEliteToTransmitToNextGeneration(); ! this.transmitEliteToNextGeneration(); ! ! this.mutateGenomes(this.nextGeneration); ! this.calculateFitnessAndMeaningForAllGenomes(this.nextGeneration); ! this.nextGeneration.Sort(this.genomeComparer); this.updateCurrentGeneration(); ! this.currentGeneration.Sort(this.genomeComparer); ! if(this.NewGeneration != null) ! this.NewGeneration( this , new NewGenerationEventArgs( ! this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness(); ! this.updateCumulativeSpecialFitnessListForRouletteSelection(); ! ! this.generationCounter++; } ! //mutate all genomes of the given population, according to the mutation rate ! private void mutateGenomes(ArrayList populationOfGenomes) { ! foreach(Genome g in populationOfGenomes) this.genomeManager.Mutate(g,this.MutationRate); } ! //calculate Fitness and Meaning for each genome in populationOfGenomes ! private void calculateFitnessAndMeaningForAllGenomes(ArrayList populationOfGenomes) { ! foreach(Genome g in populationOfGenomes) { if(!g.HasBeenCloned || g.HasBeenChanged) --- 461,498 ---- { childs = this.genomeManager.GetChilds(parent1, parent2); ! } else {//if the crossover doesn't take place there are only ! //two childs, identical to parents childs = new Genome[2]; childs[0] = parent1.Clone(); childs[1] = parent2.Clone(); } ! foreach(Genome g in childs) ! this.nextGeneration.Add(g); } ! } ! ! private void createNextGeneration() ! { ! this.nextGeneration.Clear(); ! this.createNextGeneration_addChildsWithRouletteSelection(); ! this.createNextGeneration_transmitEliteToNextGeneration(); ! this.mutateGenomes(); ! this.calculateFitnessAndMeaningForAllGenomes(); this.updateCurrentGeneration(); ! this.sortCurrentGenerationAndFireNewGenerationEvent(); ! this.setSpecialFitnessForRouletteSelection(); } ! private void mutateGenomes() { ! foreach(Genome g in this.nextGeneration) this.genomeManager.Mutate(g,this.MutationRate); } ! private void calculateFitnessAndMeaningForAllGenomes() { ! foreach(Genome g in this.nextGeneration) { if(!g.HasBeenCloned || g.HasBeenChanged) *************** *** 512,518 **** } } ! private void updateCurrentGeneration() { this.currentGeneration.Clear(); int numOfNextGeneration = this.nextGeneration.Count; --- 506,513 ---- } } ! private void updateCurrentGeneration() { + this.nextGeneration.Sort(this.genomeComparer); this.currentGeneration.Clear(); int numOfNextGeneration = this.nextGeneration.Count; |
|
From: Marco M. <mi...@us...> - 2006-08-11 18:43:52
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13229/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Pardon ... code for saving genomes to disk has been remarked in showOutputToConsole. Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GeneticOptimizer.cs 11 Aug 2006 18:21:45 -0000 1.19 --- GeneticOptimizer.cs 11 Aug 2006 18:43:47 -0000 1.20 *************** *** 317,323 **** string genes = ""; //System.Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); ! string pathFile = System.Configuration.ConfigurationSettings.AppSettings["GenericArchive"] + ! "\\GenomesThroughoutGenerations.txt"; ! System.IO.StreamWriter w = System.IO.File.AppendText(pathFile); for(int i = 0; i < this.populationSize; i++) { --- 317,323 ---- string genes = ""; //System.Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); ! // string pathFile = System.Configuration.ConfigurationSettings.AppSettings["GenericArchive"] + ! // "\\GenomesThroughoutGenerations.txt"; ! // System.IO.StreamWriter w = System.IO.File.AppendText(pathFile); for(int i = 0; i < this.populationSize; i++) { *************** *** 325,343 **** foreach(int gene in ((Genome)this.currentGeneration[i]).Genes() ) genes = genes + " " + gene.ToString(); ! // System.Console.WriteLine("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ! // ((Genome)this.currentGeneration[i]).Fitness + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).Generation); ! w.Write("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ((Genome)this.currentGeneration[i]).Fitness + " " + ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ((Genome)this.currentGeneration[i]).Generation + " " + ! this.BestGenome.Fitness); genes = ""; } ! w.Flush(); ! w.Close(); //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); --- 325,344 ---- foreach(int gene in ((Genome)this.currentGeneration[i]).Genes() ) genes = genes + " " + gene.ToString(); ! System.Console.WriteLine("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ((Genome)this.currentGeneration[i]).Fitness + " " + ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ((Genome)this.currentGeneration[i]).Generation + " " + ! this.BestGenome.Fitness); ! // w.Write("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ! // ((Genome)this.currentGeneration[i]).Fitness + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).Generation + " " + ! // this.BestGenome.Fitness); genes = ""; } ! // w.Flush(); ! // w.Close(); //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); |
|
From: Marco M. <mi...@us...> - 2006-08-11 18:21:51
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4044/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Back to previous version of IsConvergenceReached method. Plain fitness values (also negative) are used for computing convergence of current generation (just as before). Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GeneticOptimizer.cs 10 Aug 2006 16:08:27 -0000 1.18 --- GeneticOptimizer.cs 11 Aug 2006 18:21:45 -0000 1.19 *************** *** 52,55 **** --- 52,56 ---- private int genomeSize; private double totalSpecialFitnessForRouletteSelection; + private double totalFitness; private Genome bestGenome; private Genome worstGenome; *************** *** 287,300 **** { bool returnValue = false; ! double averageSpecialFitness = this.totalSpecialFitnessForRouletteSelection / this.populationSize; ! double bestSpecialFitnessReachedUntilNow = this.BestGenome.Fitness + ! Math.Abs(((Genome)this.currentGeneration[0]).Fitness); ! ! if (averageSpecialFitness >= ! this.minConvergenceRate * bestSpecialFitnessReachedUntilNow ) returnValue = true; return returnValue; - } --- 288,297 ---- { bool returnValue = false; ! double averageFitness = this.totalFitness / this.populationSize; ! double bestFitnessReachedUntilNow = this.BestGenome.Fitness; ! if (averageFitness >= this.minConvergenceRate * bestFitnessReachedUntilNow ) returnValue = true; return returnValue; } *************** *** 308,312 **** this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelection(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); this.setInitialBestAndWorstGenomes(); --- 305,309 ---- this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); this.setInitialBestAndWorstGenomes(); *************** *** 320,326 **** string genes = ""; //System.Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); ! // string pathFile = System.Configuration.ConfigurationSettings.AppSettings["GenericArchive"] + ! // "\\GenomesThroughoutGenerations.txt"; ! // System.IO.StreamWriter w = System.IO.File.AppendText(pathFile); for(int i = 0; i < this.populationSize; i++) { --- 317,323 ---- string genes = ""; //System.Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); ! string pathFile = System.Configuration.ConfigurationSettings.AppSettings["GenericArchive"] + ! "\\GenomesThroughoutGenerations.txt"; ! System.IO.StreamWriter w = System.IO.File.AppendText(pathFile); for(int i = 0; i < this.populationSize; i++) { *************** *** 328,345 **** foreach(int gene in ((Genome)this.currentGeneration[i]).Genes() ) genes = genes + " " + gene.ToString(); ! System.Console.WriteLine("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ! ((Genome)this.currentGeneration[i]).Fitness + " " + ! ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ! ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ! ((Genome)this.currentGeneration[i]).Generation); ! // w.Write("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + // ((Genome)this.currentGeneration[i]).Fitness + " " + // ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + // ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + // ((Genome)this.currentGeneration[i]).Generation); genes = ""; } ! // w.Flush(); ! // w.Close(); //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); --- 325,343 ---- foreach(int gene in ((Genome)this.currentGeneration[i]).Genes() ) genes = genes + " " + gene.ToString(); ! // System.Console.WriteLine("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + // ((Genome)this.currentGeneration[i]).Fitness + " " + // ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + // ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + // ((Genome)this.currentGeneration[i]).Generation); + w.Write("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + + ((Genome)this.currentGeneration[i]).Fitness + " " + + ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + + ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + + ((Genome)this.currentGeneration[i]).Generation + " " + + this.BestGenome.Fitness); genes = ""; } ! w.Flush(); ! w.Close(); //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); *************** *** 380,392 **** /// <summary> /// Calculate total special fitness for current generation /// </summary> ! private void calculateTotalSpecialFitnessForRouletteSelection() { this.totalSpecialFitnessForRouletteSelection = 0.0; double worstSpecialFitnessForRouletteSelection = Math.Abs(((Genome)this.currentGeneration[0]).Fitness); foreach(Genome g in this.currentGeneration) ! this.totalSpecialFitnessForRouletteSelection += g.Fitness + ! worstSpecialFitnessForRouletteSelection; } --- 378,396 ---- /// <summary> /// Calculate total special fitness for current generation + /// and plain total fitness /// </summary> ! private void calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness() { this.totalSpecialFitnessForRouletteSelection = 0.0; + this.totalFitness = 0.0; double worstSpecialFitnessForRouletteSelection = Math.Abs(((Genome)this.currentGeneration[0]).Fitness); foreach(Genome g in this.currentGeneration) ! { ! this.totalSpecialFitnessForRouletteSelection += g.Fitness + ! worstSpecialFitnessForRouletteSelection; ! this.totalFitness += g.Fitness; ! } ! } *************** *** 479,483 **** this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelection(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); --- 483,487 ---- this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelectionAndPlainTotalFitness(); this.updateCumulativeSpecialFitnessListForRouletteSelection(); |
|
From: Marco M. <mi...@us...> - 2006-08-10 16:08:33
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17362/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Fixed VERY important bug in rouletteSelection method: GO now works properly also with negative fitnesses. Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GeneticOptimizer.cs 7 Aug 2006 21:03:24 -0000 1.17 --- GeneticOptimizer.cs 10 Aug 2006 16:08:27 -0000 1.18 *************** *** 51,55 **** private int generationNumber; private int genomeSize; ! private double totalFitness; private Genome bestGenome; private Genome worstGenome; --- 51,55 ---- private int generationNumber; private int genomeSize; ! private double totalSpecialFitnessForRouletteSelection; private Genome bestGenome; private Genome worstGenome; *************** *** 60,64 **** private ArrayList currentEliteToTransmitToNextGeneration; private ArrayList nextGeneration; ! private ArrayList cumulativeFitnessList; private int generationCounter; --- 60,64 ---- private ArrayList currentEliteToTransmitToNextGeneration; private ArrayList nextGeneration; ! private ArrayList cumulativeSpecialFitnessListForRouletteSelection; private int generationCounter; *************** *** 210,214 **** this.genomeSize = this.genomeManager.GenomeSize; this.genomeComparer = new GenomeComparer(); ! this.cumulativeFitnessList = new ArrayList(this.PopulationSize); this.currentGeneration = new ArrayList(this.PopulationSize); int eliteNumber = (int)(this.ElitismRate*(double)this.PopulationSize); --- 210,214 ---- this.genomeSize = this.genomeManager.GenomeSize; this.genomeComparer = new GenomeComparer(); ! this.cumulativeSpecialFitnessListForRouletteSelection = new ArrayList(this.PopulationSize); this.currentGeneration = new ArrayList(this.PopulationSize); int eliteNumber = (int)(this.ElitismRate*(double)this.PopulationSize); *************** *** 227,231 **** { this.createFirstGeneration(false); ! this.averageRandomFitness = this.totalFitness/this.currentGeneration.Count; this.standardDeviationOfRandomFitness = this.calculateRandomFitness_getStdDevOfRandomFitness(); } --- 227,231 ---- { this.createFirstGeneration(false); ! this.averageRandomFitness = this.totalSpecialFitnessForRouletteSelection/this.currentGeneration.Count; this.standardDeviationOfRandomFitness = this.calculateRandomFitness_getStdDevOfRandomFitness(); } *************** *** 287,295 **** { bool returnValue = false; ! double averageFitnessOfCurrentGeneration = this.totalFitness / this.populationSize; ! double bestFitnessReachedUntilNow = this.BestGenome.Fitness; ! if (averageFitnessOfCurrentGeneration >= ! this.minConvergenceRate * bestFitnessReachedUntilNow ) returnValue = true; --- 287,296 ---- { bool returnValue = false; ! double averageSpecialFitness = this.totalSpecialFitnessForRouletteSelection / this.populationSize; ! double bestSpecialFitnessReachedUntilNow = this.BestGenome.Fitness + ! Math.Abs(((Genome)this.currentGeneration[0]).Fitness); ! if (averageSpecialFitness >= ! this.minConvergenceRate * bestSpecialFitnessReachedUntilNow ) returnValue = true; *************** *** 307,312 **** this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalFitness(); ! this.updateCumulativeFitnessList(); this.setInitialBestAndWorstGenomes(); --- 308,313 ---- this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelection(); ! this.updateCumulativeSpecialFitnessListForRouletteSelection(); this.setInitialBestAndWorstGenomes(); *************** *** 317,326 **** private void showOutputToConsole() { ! System.Console.WriteLine("\n\n\n\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); for(int i = 0; i < this.populationSize; i++) { ! System.Console.WriteLine((string)((Genome)this.currentGeneration[i]).Meaning + ! "--> " + ((Genome)this.currentGeneration[i]).Fitness); } //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); --- 318,345 ---- private void showOutputToConsole() { ! string genes = ""; ! //System.Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*\n\nGeneration " + this.generationCounter +"\n"); ! // string pathFile = System.Configuration.ConfigurationSettings.AppSettings["GenericArchive"] + ! // "\\GenomesThroughoutGenerations.txt"; ! // System.IO.StreamWriter w = System.IO.File.AppendText(pathFile); for(int i = 0; i < this.populationSize; i++) { ! int genomeNumber = i + 1; ! foreach(int gene in ((Genome)this.currentGeneration[i]).Genes() ) ! genes = genes + " " + gene.ToString(); ! System.Console.WriteLine("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ! ((Genome)this.currentGeneration[i]).Fitness + " " + ! ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ! ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ! ((Genome)this.currentGeneration[i]).Generation); ! // w.Write("\r\n" + this.GenerationCounter + " " + genomeNumber + " " + genes + " " + ! // ((Genome)this.currentGeneration[i]).Fitness + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenChanged.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).HasBeenCloned.ToString() + " " + ! // ((Genome)this.currentGeneration[i]).Generation); ! genes = ""; } + // w.Flush(); + // w.Close(); //Console.WriteLine("Press enter key to continue ..."); //Console.ReadLine(); *************** *** 334,338 **** private int rouletteSelection() { ! double randomFitness = this.totalFitness *(double)this.random.Next(1,1001)/1000; int idx = -1; int first = 0; --- 353,357 ---- private int rouletteSelection() { ! double randomFitness = this.totalSpecialFitnessForRouletteSelection *(double)this.random.Next(1,1001)/1000; int idx = -1; int first = 0; *************** *** 343,351 **** while (idx == -1 && first <= last) { ! if (randomFitness < (double)this.cumulativeFitnessList[mid]) { last = mid; } ! else if (randomFitness >= (double)this.cumulativeFitnessList[mid]) { first = mid; --- 362,370 ---- while (idx == -1 && first <= last) { ! if (randomFitness < (double)this.cumulativeSpecialFitnessListForRouletteSelection[mid]) { last = mid; } ! else if (randomFitness >= (double)this.cumulativeSpecialFitnessListForRouletteSelection[mid]) { first = mid; *************** *** 353,357 **** mid = (first + last)/2; if ((last - first) == 1) ! idx = last; } return idx; --- 372,376 ---- mid = (first + last)/2; if ((last - first) == 1) ! idx = last;//it's time to exit from the while loop } return idx; *************** *** 360,385 **** /// <summary> ! /// Calculate total fitness for current generation /// </summary> ! private void calculateTotalFitness() { ! this.totalFitness = 0.0; ! foreach(Genome g in this.currentGeneration) ! this.totalFitness += g.Fitness; } ! ! /// <summary> ! /// Rank current generation and sort in order of fitness. ! /// </summary> ! private void updateCumulativeFitnessList() { ! double cumulativeFitness = 0.0; ! this.cumulativeFitnessList.Clear(); for (int i = 0; i < this.populationSize; i++) { ! cumulativeFitness += ((Genome)this.currentGeneration[i]).Fitness; ! this.cumulativeFitnessList.Add(cumulativeFitness); } } --- 379,405 ---- /// <summary> ! /// Calculate total special fitness for current generation /// </summary> ! private void calculateTotalSpecialFitnessForRouletteSelection() { ! this.totalSpecialFitnessForRouletteSelection = 0.0; ! double worstSpecialFitnessForRouletteSelection = ! Math.Abs(((Genome)this.currentGeneration[0]).Fitness); foreach(Genome g in this.currentGeneration) ! this.totalSpecialFitnessForRouletteSelection += g.Fitness + ! worstSpecialFitnessForRouletteSelection; } ! ! private void updateCumulativeSpecialFitnessListForRouletteSelection() { ! double cumulativeSpecialFitness = 0.0; ! this.cumulativeSpecialFitnessListForRouletteSelection.Clear(); for (int i = 0; i < this.populationSize; i++) { ! cumulativeSpecialFitness += ! ((Genome)this.currentGeneration[i]).Fitness + ! Math.Abs(((Genome)this.currentGeneration[0]).Fitness); ! this.cumulativeSpecialFitnessListForRouletteSelection.Add(cumulativeSpecialFitness); } } *************** *** 459,464 **** this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalFitness(); ! this.updateCumulativeFitnessList(); this.generationCounter++; --- 479,484 ---- this.NewGeneration( this , new NewGenerationEventArgs( this.currentGeneration , this.generationCounter , this.generationNumber ) ); ! this.calculateTotalSpecialFitnessForRouletteSelection(); ! this.updateCumulativeSpecialFitnessListForRouletteSelection(); this.generationCounter++; *************** *** 492,496 **** this.currentGeneration.Clear(); int numOfNextGeneration = this.nextGeneration.Count; ! // Note that next generation is greater than current: // due to the population size, genomes with lowest fitness are abandoned for (int i = 1 ; i <= this.populationSize; i++) --- 512,516 ---- this.currentGeneration.Clear(); int numOfNextGeneration = this.nextGeneration.Count; ! // Note that next generation is greater than current: // due to the population size, genomes with lowest fitness are abandoned for (int i = 1 ; i <= this.populationSize; i++) |
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:45:30
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25535/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger Modified Files: WFLagChosenPositions.cs Log Message: - the Generation property has been added (First generation of the genetic optimizer, when the best genome was found) The custom deserialization has been patched accordingly Index: WFLagChosenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagChosenPositions.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFLagChosenPositions.cs 30 Jul 2006 13:50:26 -0000 1.2 --- WFLagChosenPositions.cs 8 Aug 2006 09:45:27 -0000 1.3 *************** *** 45,48 **** --- 45,49 ---- private WeightedPositions portfolioWeightedPositions; private DateTime lastOptimizationDate; + private int generation; public WeightedPositions DrivingWeightedPositions *************** *** 74,77 **** --- 75,85 ---- } + /// <summary> + /// First generation of the genetic optimizer, when the best genome was created + /// </summary> + public int Generation + { + get { return this.generation; } + } public WFLagChosenPositions( WFLagChosenTickers wFLagChosenTickers , DateTime lastOptimizationDate ) *************** *** 84,87 **** --- 92,96 ---- this.portfolioWeightedPositions = wFLagChosenTickers.PortfolioWeightedPositions; this.lastOptimizationDate = lastOptimizationDate; + this.generation = wFLagChosenTickers.Generation; } *************** *** 148,154 **** try { ! // this.portfolioWeightedPositions = new WeightedPositions(); ! // System.Type type = System.Type.GetType( ! // "QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositions" ); this.portfolioWeightedPositions = (WeightedPositions)info.GetValue( "portfolioWeightedPositions" , WeightedPositions.Type ); --- 157,163 ---- try { ! // this.portfolioWeightedPositions = new WeightedPositions(); ! // System.Type type = System.Type.GetType( ! // "QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositions" ); this.portfolioWeightedPositions = (WeightedPositions)info.GetValue( "portfolioWeightedPositions" , WeightedPositions.Type ); *************** *** 164,167 **** --- 173,189 ---- } } + private void deserializeGeneration( + SerializationInfo info , StreamingContext context ) + { + try + { + this.generation = (int)info.GetValue( + "generation" , int.MaxValue.GetType() ); + } + catch + { + this.generation = -9999; + } + } private void deserializeThisClassMembers( SerializationInfo info , StreamingContext context ) { *************** *** 170,173 **** --- 192,196 ---- this.deserializeDrivingWeightedPositions( info , context ); this.deserializePortfolioWeightedPositions( info , context ); + this.deserializeGeneration( info , context ); } void ISerializable.GetObjectData( |
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:44:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25043/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger Modified Files: WFLagChosenPositionsDebugInfo.cs Log Message: - the Generation property has been added (First generation of the genetic optimizer, when the best genome was found) Index: WFLagChosenPositionsDebugInfo.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger/WFLagChosenPositionsDebugInfo.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFLagChosenPositionsDebugInfo.cs 30 Jul 2006 13:45:54 -0000 1.4 --- WFLagChosenPositionsDebugInfo.cs 8 Aug 2006 09:44:12 -0000 1.5 *************** *** 61,64 **** --- 61,72 ---- get { return this.wFLagLog.InSampleDays; } } + /// <summary> + /// The number of the genetic optimizer's generation + /// when the corresponding genome was created + /// </summary> + public int Generation + { + get { return this.wFLagChosenPositions.Generation; } + } public double InSampleSharpeRatio { |
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:43:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24696/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagChosenTickers.cs Log Message: - the Generation property has been added (First generation of the genetic optimizer, when the best genome was found) Index: WFLagChosenTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagChosenTickers.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WFLagChosenTickers.cs 30 Jul 2006 13:44:48 -0000 1.3 --- WFLagChosenTickers.cs 8 Aug 2006 09:43:40 -0000 1.4 *************** *** 54,57 **** --- 54,58 ---- private DateTime firstOptimizationDate; private DateTime lastOptimizationDate; + private int generation; // public QPHashtable PortfolioPositions *************** *** 97,100 **** --- 98,108 ---- } } + /// <summary> + /// First generation of the genetic optimizer, when the best genome was found + /// </summary> + public int Generation + { + get { return this.generation; } + } public WFLagChosenTickers( int numberOfDrivingPositions , *************** *** 172,175 **** --- 180,186 ---- this.setSignedTickers_setTickersFromGenome( genomeManager , geneticOptimizer.BestGenome ); + + this.generation = geneticOptimizer.BestGenome.Generation; + } #endregion |
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:38:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22226/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagGenomeManagerWithWeights.cs WFLagGenomeManager.cs Log Message: Adapted to the new IGenomeManager interface: - properties MinValueForGenes and MaxValueForGenes have been replaced by GetMinValueForGenes(int genePosition) and GetMaxValueForGenes(int genePosition) methods. - property CurrentGeneticOptimizer has been deleted from the interface. Index: WFLagGenomeManagerWithWeights.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomeManagerWithWeights.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagGenomeManagerWithWeights.cs 30 Jul 2006 12:59:07 -0000 1.1 --- WFLagGenomeManagerWithWeights.cs 8 Aug 2006 09:37:57 -0000 1.2 *************** *** 41,57 **** } ! public int MinValueForGenes ! { ! get { return -this.numberOfEligibleTickersForDrivingWeightedPositions; } ! } ! public int MaxValueForGenes ! { ! get { return this.numberOfEligibleTickersForDrivingWeightedPositions - 1; } ! } ! public GeneticOptimizer CurrentGeneticOptimizer ! { ! get{ return this.currentGeneticOptimizer; } ! set{ this.currentGeneticOptimizer = value; } ! } /// <summary> --- 41,57 ---- } ! // public int MinValueForGenes ! // { ! // get { return -this.numberOfEligibleTickersForDrivingWeightedPositions; } ! // } ! // public int MaxValueForGenes ! // { ! // get { return this.numberOfEligibleTickersForDrivingWeightedPositions - 1; } ! // } ! // public GeneticOptimizer CurrentGeneticOptimizer ! // { ! // get{ return this.currentGeneticOptimizer; } ! // set{ this.currentGeneticOptimizer = value; } ! // } /// <summary> *************** *** 92,99 **** --- 92,116 ---- this.minimumPositionWeight = 0.2; // TO DO this value should become a constructor parameter + GenomeManagement.SetRandomGenerator( + QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator + + this.firstOptimizationDate.DayOfYear ); + this.wFLagCandidates = new WFLagCandidates( this.eligibleTickersForDrivingWeightedPositions , this.firstOptimizationDate , this.lastOptimizationDate ); } + public int GetMinValueForGenes( int genePosition ) + { + int minValueForGene = 0; + if ( genePosition % 2 == 0 ) + // gene refers to a weight, not to a ticker + minValueForGene = -this.numberOfEligibleTickersForDrivingWeightedPositions; + return minValueForGene; + } + public int GetMaxValueForGenes( int genePosition ) + { + return this.numberOfEligibleTickersForDrivingWeightedPositions - 1; + } + #region GetFitnessValue private string[] getTickers( WeightedPositions weightedPositions ) *************** *** 299,305 **** private double getAdditionalWeight( int weightRelatedGeneValue ) { ! double midrangeValue = ( this.MinValueForGenes + this.MaxValueForGenes ) / 2; double singleWeightFreeRange = 1 - this.minimumPositionWeight; ! double scaleRange = Convert.ToDouble( this.MaxValueForGenes - this.MinValueForGenes ); double nonScaledAdditionalWeight = Convert.ToDouble( weightRelatedGeneValue ) - midrangeValue; --- 316,324 ---- private double getAdditionalWeight( int weightRelatedGeneValue ) { ! double midrangeValue = ( ! this.GetMinValueForGenes( 0 ) + this.GetMaxValueForGenes( 0 ) ) / 2; double singleWeightFreeRange = 1 - this.minimumPositionWeight; ! double scaleRange = Convert.ToDouble( ! this.GetMinValueForGenes( 0 ) - this.GetMaxValueForGenes( 0 ) ); double nonScaledAdditionalWeight = Convert.ToDouble( weightRelatedGeneValue ) - midrangeValue; *************** *** 444,462 **** #endregion #region GetNewGeneValue ! private int getMinGeneValue( int i ) ! { ! int minGeneValue = 0; ! if ( i % 2 == 0 ) ! minGeneValue = this.MinValueForGenes; ! return minGeneValue; ! } ! private int getMaxGeneValue( int i ) ! { ! return this.MaxValueForGenes; ! } ! public int GetNewGeneValue( Genome genome , int i ) { ! int minGeneValue = this.getMinGeneValue( i ); ! int maxGeneValue = this.getMaxGeneValue( i ); int returnValue = GenomeManagement.RandomGenerator.Next( --- 463,481 ---- #endregion #region GetNewGeneValue ! // private int getMinGeneValue( int genePosition ) ! // { ! // int minGeneValue = 0; ! // if ( genePosition % 2 == 0 ) ! // minGeneValue = -this.numberOfEligibleTickersForDrivingWeightedPositions; ! // return minGeneValue; ! // } ! // private int getMaxGeneValue( int i ) ! // { ! // return this.MaxValueForGenes; ! // } ! public int GetNewGeneValue( Genome genome , int genePosition ) { ! int minGeneValue = this.GetMinValueForGenes( genePosition ); ! int maxGeneValue = this.GetMaxValueForGenes( genePosition ); int returnValue = GenomeManagement.RandomGenerator.Next( Index: WFLagGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomeManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFLagGenomeManager.cs 14 May 2006 21:16:51 -0000 1.2 --- WFLagGenomeManager.cs 8 Aug 2006 09:37:57 -0000 1.3 *************** *** 47,52 **** private int numberOfEligibleTickers; - private GeneticOptimizer currentGeneticOptimizer; - private WFLagCandidates wFLagCandidates; --- 47,50 ---- *************** *** 58,74 **** } } ! public int MinValueForGenes ! { ! get { return -this.numberOfEligibleTickers; } ! } ! public int MaxValueForGenes ! { ! get { return this.numberOfEligibleTickers - 1; } ! } ! public GeneticOptimizer CurrentGeneticOptimizer ! { ! get{ return this.currentGeneticOptimizer; } ! set{ this.currentGeneticOptimizer = value; } ! } public WFLagGenomeManager( --- 56,64 ---- } } ! // public GeneticOptimizer CurrentGeneticOptimizer ! // { ! // get{ return this.currentGeneticOptimizer; } ! // set{ this.currentGeneticOptimizer = value; } ! // } public WFLagGenomeManager( *************** *** 87,91 **** this.numberOfEligibleTickers = eligibleTickers.Rows.Count; ! GenomeManagement.SetRandomGenerator(QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator); this.wFLagCandidates = new WFLagCandidates( this.eligibleTickers , --- 77,83 ---- this.numberOfEligibleTickers = eligibleTickers.Rows.Count; ! GenomeManagement.SetRandomGenerator( ! QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator + ! firstQuoteDate.Date.DayOfYear ); this.wFLagCandidates = new WFLagCandidates( this.eligibleTickers , *************** *** 93,96 **** --- 85,96 ---- } + public int GetMinValueForGenes( int genePosition ) + { + return -this.numberOfEligibleTickers; + } + public int GetMaxValueForGenes( int genePosition ) + { + return this.numberOfEligibleTickers - 1; + } public static string GetTicker( string signedTicker ) *************** *** 267,275 **** // in this implementation only one gene is mutated // the new value has to be different from all the other genes of the genome - int newValueForGene = GenomeManagement.RandomGenerator.Next( - genome.MinValueForGenes , - genome.MaxValueForGenes + 1 ); int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next( genome.Size ); while( GenomeManipulator.IsTickerContainedInGenome( newValueForGene , genome ) ) --- 267,275 ---- // 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 ) ) *************** *** 279,284 **** { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.MinValueForGenes , ! genome.MaxValueForGenes + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , --- 279,284 ---- { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( genePositionToBeMutated ) , ! genome.GetMaxValueForGenes( genePositionToBeMutated ) + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , *************** *** 350,355 **** // the others already stored in the given genome int returnValue = ! GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); while( GenomeManipulator.IsTickerContainedInGenome(returnValue, genome) ) --- 350,356 ---- // the others already stored in the given genome int returnValue = ! GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( i ) , ! genome.GetMaxValueForGenes( i ) + 1); while( GenomeManipulator.IsTickerContainedInGenome(returnValue, genome) ) *************** *** 357,362 **** // short one for the same ticker { ! returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); } return returnValue; --- 358,364 ---- // short one for the same ticker { ! returnValue = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( i ) , ! genome.GetMaxValueForGenes( i ) + 1 ); } return returnValue; |
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:37:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22189/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank Modified Files: WFMultiOneRankGenomeManager.cs Log Message: Adapted to the new IGenomeManager interface: - properties MinValueForGenes and MaxValueForGenes have been replaced by GetMinValueForGenes(int genePosition) and GetMaxValueForGenes(int genePosition) methods. - property CurrentGeneticOptimizer has been deleted from the interface. Index: WFMultiOneRankGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/WFMultiOneRankGenomeManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WFMultiOneRankGenomeManager.cs 14 Mar 2006 14:13:41 -0000 1.3 --- WFMultiOneRankGenomeManager.cs 8 Aug 2006 09:37:34 -0000 1.4 *************** *** 52,68 **** get { return this.numberOfTickersInPortfolio; } } ! public int MinValueForGenes ! { ! get { return -this.numberOfEligibleTickers; } ! } ! public int MaxValueForGenes ! { ! get { return this.numberOfEligibleTickers - 1; } ! } ! public GeneticOptimizer CurrentGeneticOptimizer ! { ! get{ return this.currentGeneticOptimizer; } ! set{ this.currentGeneticOptimizer = value; } ! } public WFMultiOneRankGenomeManager( --- 52,68 ---- get { return this.numberOfTickersInPortfolio; } } ! // public int MinValueForGenes ! // { ! // get { return -this.numberOfEligibleTickers; } ! // } ! // public int MaxValueForGenes ! // { ! // get { return this.numberOfEligibleTickers - 1; } ! // } ! // public GeneticOptimizer CurrentGeneticOptimizer ! // { ! // get{ return this.currentGeneticOptimizer; } ! // set{ this.currentGeneticOptimizer = value; } ! // } public WFMultiOneRankGenomeManager( *************** *** 115,118 **** --- 115,126 ---- #endregion + public int GetMinValueForGenes( int genePosition ) + { + return -this.numberOfEligibleTickers; + } + public int GetMaxValueForGenes( int genePosition ) + { + return this.numberOfEligibleTickers - 1; + } #region GetFitnessValue *************** *** 208,216 **** // in this implementation only one gene is mutated // the new value has to be different from all the other genes of the genome - int newValueForGene = GenomeManagement.RandomGenerator.Next( - genome.MinValueForGenes , - genome.MaxValueForGenes + 1 ); int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next( genome.Size ); while( GenomeManipulator.IsTickerContainedInGenome( newValueForGene , genome ) ) --- 216,224 ---- // 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 ) ) *************** *** 220,225 **** { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.MinValueForGenes , ! genome.MaxValueForGenes + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , --- 228,233 ---- { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( genePositionToBeMutated ) , ! genome.GetMaxValueForGenes( genePositionToBeMutated ) + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , *************** *** 257,272 **** } #endregion ! public int GetNewGeneValue( Genome genome , int i ) { // in this implementation new gene values must be different from // the others already stored in the given genome ! int returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 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.MinValueForGenes, ! genome.MaxValueForGenes + 1); } --- 265,282 ---- } #endregion ! public 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); } |
|
From: Marco M. <mi...@us...> - 2006-08-07 21:21:23
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31240/b7_Scripts/TickerSelectionTesting/TestingOTCTypes Modified Files: RunEfficientOTCTypes.cs Log Message: Script name has been cut, in order to avoid the risk of creating a too long path for Windows. Index: RunEfficientOTCTypes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes/RunEfficientOTCTypes.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RunEfficientOTCTypes.cs 2 Jul 2006 19:42:15 -0000 1.4 --- RunEfficientOTCTypes.cs 7 Aug 2006 21:21:20 -0000 1.5 *************** *** 72,76 **** portfolioType, maxRunningHours) { ! this.ScriptName = "OTC_Types_ExpScoreWithCoeff"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.accounts = new Account[4]; --- 72,76 ---- portfolioType, maxRunningHours) { ! this.ScriptName = "OTC_Types_ExpScoreWithCoeffAndPriceSelection"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.accounts = new Account[4]; |
|
From: Marco M. <mi...@us...> - 2006-08-07 21:19:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30161/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: GenomeRepresentation.cs LinearCombinationTest.cs TestDisplayer.cs Log Message: TestDisplayer, the form for examining genomes saved to disk, has been improved. Index: LinearCombinationTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/LinearCombinationTest.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LinearCombinationTest.cs 3 Aug 2006 21:15:57 -0000 1.8 --- LinearCombinationTest.cs 7 Aug 2006 21:19:40 -0000 1.9 *************** *** 31,34 **** --- 31,35 ---- using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; *************** *** 52,58 **** private Account account; private IEndOfDayStrategy endOfDayStrategy; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType) { this.firstDate = firstDate; --- 53,61 ---- private Account account; private IEndOfDayStrategy endOfDayStrategy; + private PortfolioType portfolioType; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType, ! PortfolioType portfolioType) { this.firstDate = firstDate; *************** *** 61,68 **** // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; ! } public LinearCombinationTest( DateTime firstDate , DateTime lastDate , GenomeRepresentation genomeRepresentation , StrategyType strategyType, int numDaysForOscillatorStrategy) { --- 64,73 ---- // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; ! this.portfolioType = portfolioType; ! } public LinearCombinationTest( DateTime firstDate , DateTime lastDate , GenomeRepresentation genomeRepresentation , StrategyType strategyType, + PortfolioType portfolioType, int numDaysForOscillatorStrategy) { *************** *** 72,75 **** --- 77,81 ---- // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; + this.portfolioType = portfolioType; this.numDaysForOscillatorStrategy = numDaysForOscillatorStrategy; } *************** *** 125,129 **** case StrategyType.ExtremeCounterTrend: this.endOfDayStrategy = new ExtremeCounterTrendStrategy( ! this.account , signedTickers , weightsForSignedTickers, this.numDaysForOscillatorStrategy ); break; --- 131,136 ---- case StrategyType.ExtremeCounterTrend: this.endOfDayStrategy = new ExtremeCounterTrendStrategy( ! this.account , signedTickers , weightsForSignedTickers, this.numDaysForOscillatorStrategy, ! this.portfolioType); break; Index: GenomeRepresentation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/GenomeRepresentation.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenomeRepresentation.cs 3 Aug 2006 21:26:10 -0000 1.6 --- GenomeRepresentation.cs 7 Aug 2006 21:19:40 -0000 1.7 *************** *** 45,48 **** --- 45,50 ---- private DateTime lastOptimizationDate; private int eligibleTickers = -1; + private int halfPeriodDays = -1; + private PortfolioType portfolioType = PortfolioType.ShortAndLong; public string SignedTickers *************** *** 89,92 **** --- 91,109 ---- } + public int HalfPeriodDays + { + get + { + return this.halfPeriodDays; + } + } + + public PortfolioType PortfolioType + { + get + { + return this.portfolioType; + } + } // public static string[] GetSignedTickers( string signedTickers ) // { *************** *** 215,219 **** this.signedTickers = newRepresentationForSignedTickers.Substring(0, newRepresentationForSignedTickers.Length -1); } - } --- 232,235 ---- *************** *** 244,255 **** {ex = ex;} } - this.genomeRepresentation_synchronizeOldWithNew(); - } private void genomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers ) { this.fitness = genome.Fitness; --- 260,269 ---- {ex = ex;} } this.genomeRepresentation_synchronizeOldWithNew(); } private void genomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays, PortfolioType portfolioType ) { this.fitness = genome.Fitness; *************** *** 261,277 **** this.generationCounter = generationCounter; this.eligibleTickers = eligibleTickers; } ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate ) { this.genomeRepresentation( genome , ! firstOptimizationDate , lastOptimizationDate , -1, -1 ); } ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int generationCounter ) { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, -1 ); } --- 275,295 ---- this.generationCounter = generationCounter; this.eligibleTickers = eligibleTickers; + this.halfPeriodDays = halfPeriodDays; + this.portfolioType = portfolioType; } ! ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate ) { this.genomeRepresentation( genome , ! firstOptimizationDate , lastOptimizationDate , -1, -1, -1, PortfolioType.ShortAndLong ); } ! ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int generationCounter ) { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, -1, -1, PortfolioType.ShortAndLong); } *************** *** 281,287 **** { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers ); } ! #region GetObjectData /// <summary> --- 299,322 ---- { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, -1, PortfolioType.ShortAndLong); } ! ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays ) ! { ! this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, halfPeriodDays, ! PortfolioType.ShortAndLong); ! } ! ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays, PortfolioType portfolioType ) ! { ! this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, halfPeriodDays, portfolioType); ! } ! #region GetObjectData /// <summary> Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestDisplayer.cs 3 Aug 2006 21:15:57 -0000 1.9 --- TestDisplayer.cs 7 Aug 2006 21:19:40 -0000 1.10 *************** *** 27,30 **** --- 27,31 ---- using System.ComponentModel; using System.Windows.Forms; + using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.WalkForwardTesting.LinearCombination *************** *** 57,62 **** private System.Windows.Forms.RadioButton radioButtonImmediateTrendFollower; private StrategyType selectedStrategyType = StrategyType.OpenToCloseDaily; ! ! private void testdisplayer() { this.dgBestGenomes.DataSource = this.bestGenomes; --- 58,65 ---- private System.Windows.Forms.RadioButton radioButtonImmediateTrendFollower; private StrategyType selectedStrategyType = StrategyType.OpenToCloseDaily; ! private System.Windows.Forms.Label labelPortfolioType; ! private System.Windows.Forms.ComboBox comboBoxPortfolioType; ! ! private void testDisplayer() { this.dgBestGenomes.DataSource = this.bestGenomes; *************** *** 123,127 **** this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; ! this.testdisplayer(); } --- 126,137 ---- this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; ! this.comboBoxPortfolioType.Items.Add(PortfolioType.ShortAndLong); ! this.comboBoxPortfolioType.Items.Add(PortfolioType.OnlyLong); ! this.comboBoxPortfolioType.Items.Add(PortfolioType.OnlyShort); ! this.comboBoxPortfolioType.SelectedItem = PortfolioType.ShortAndLong; ! this.comboBoxPortfolioType.Text = this.comboBoxPortfolioType.SelectedItem.ToString(); ! this.comboBoxPortfolioType.Visible = false; ! this.labelPortfolioType.Visible = false; ! this.testDisplayer(); } *************** *** 160,163 **** --- 170,175 ---- this.radioButtonOTCCTODaily = new System.Windows.Forms.RadioButton(); this.radioButtonImmediateTrendFollower = new System.Windows.Forms.RadioButton(); + this.comboBoxPortfolioType = new System.Windows.Forms.ComboBox(); + this.labelPortfolioType = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).BeginInit(); this.SuspendLayout(); *************** *** 170,174 **** this.dgBestGenomes.Location = new System.Drawing.Point(0, 205); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(584, 168); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); --- 182,186 ---- this.dgBestGenomes.Location = new System.Drawing.Point(0, 205); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(704, 168); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); *************** *** 274,282 **** this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(584, 373); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.radioButtonImmediateTrendFollower, this.radioButtonOTCCTODaily, --- 286,312 ---- this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); // + // comboBoxPortfolioType + // + this.comboBoxPortfolioType.Location = new System.Drawing.Point(480, 104); + this.comboBoxPortfolioType.Name = "comboBoxPortfolioType"; + this.comboBoxPortfolioType.Size = new System.Drawing.Size(184, 21); + this.comboBoxPortfolioType.TabIndex = 13; + this.comboBoxPortfolioType.Text = "comboBoxPortfolioType"; + // + // labelPortfolioType + // + this.labelPortfolioType.Location = new System.Drawing.Point(480, 88); + this.labelPortfolioType.Name = "labelPortfolioType"; + this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); + this.labelPortfolioType.TabIndex = 14; + this.labelPortfolioType.Text = "Type of portfolio"; + // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(704, 373); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.labelPortfolioType, + this.comboBoxPortfolioType, this.radioButtonImmediateTrendFollower, this.radioButtonOTCCTODaily, *************** *** 346,361 **** new LinearCombinationTest( this.dtpFirstDate.Value , this.dtpLastDate.Value , genomeRepresentation , ! this.selectedStrategyType, Convert.ToInt32(this.textBoxDaysFPOscillatorAndRevOneRank.Text)); linearCombinationTest.Run(); this.lastSelectedGenomeRepresentation = genomeRepresentation; } ! private void dgBestGenomes_MouseUp_leftButton_updateDates( ! GenomeRepresentation newSelectedGenomeRepresentation ) ! { ! this.dtpFirstDate.Value = ! newSelectedGenomeRepresentation.FirstOptimizationDate; ! this.dtpLastDate.Value = ! newSelectedGenomeRepresentation.LastOptimizationDate; ! } private void dgBestGenomes_MouseUp_leftButton(object sender, System.Windows.Forms.MouseEventArgs e) { --- 376,404 ---- new LinearCombinationTest( this.dtpFirstDate.Value , this.dtpLastDate.Value , genomeRepresentation , ! this.selectedStrategyType, ! (PortfolioType)this.comboBoxPortfolioType.SelectedItem, Convert.ToInt32(this.textBoxDaysFPOscillatorAndRevOneRank.Text)); linearCombinationTest.Run(); this.lastSelectedGenomeRepresentation = genomeRepresentation; } ! ! ! private void dgBestGenomes_MouseUp_leftButton_updateForm( ! GenomeRepresentation newSelectedGenomeRepresentation ) ! { ! this.dtpFirstDate.Value = ! newSelectedGenomeRepresentation.FirstOptimizationDate; ! this.dtpLastDate.Value = ! newSelectedGenomeRepresentation.LastOptimizationDate; ! ! if(newSelectedGenomeRepresentation.HalfPeriodDays > 0) ! //genomeRepresentation derives from a strategy ! //based on HalfPeriodDays ! this.textBoxDaysFPOscillatorAndRevOneRank.Text = ! newSelectedGenomeRepresentation.HalfPeriodDays.ToString(); ! ! this.comboBoxPortfolioType.SelectedItem = ! newSelectedGenomeRepresentation.PortfolioType; ! } ! private void dgBestGenomes_MouseUp_leftButton(object sender, System.Windows.Forms.MouseEventArgs e) { *************** *** 365,370 **** GenomeRepresentation newSelectedGenomeRepresentation = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! dgBestGenomes_MouseUp_leftButton_updateDates( newSelectedGenomeRepresentation ); ! this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; } } --- 408,413 ---- GenomeRepresentation newSelectedGenomeRepresentation = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; ! dgBestGenomes_MouseUp_leftButton_updateForm( newSelectedGenomeRepresentation ); } } *************** *** 418,421 **** --- 461,466 ---- { this.update_selectedStrategyType(); + this.comboBoxPortfolioType.Visible = this.radioButtonExtremeCounterTrend.Checked; + this.labelPortfolioType.Visible = this.radioButtonExtremeCounterTrend.Checked;; } |
|
From: Marco M. <mi...@us...> - 2006-08-07 21:17:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28969/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend Modified Files: RunExtremeCounterTrend.cs Log Message: Script name has been cut. Previously, it was too long for being accepted as part of the path by Windows (path exceeding 260 chars). Index: RunExtremeCounterTrend.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/RunExtremeCounterTrend.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunExtremeCounterTrend.cs 3 Aug 2006 21:18:40 -0000 1.3 --- RunExtremeCounterTrend.cs 7 Aug 2006 21:17:13 -0000 1.4 *************** *** 73,77 **** portfolioType, maxRunningHours) { ! this.ScriptName = "ExtremeCounterTrendScriptWithSharpeRatio"; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; --- 73,77 ---- portfolioType, maxRunningHours) { ! this.ScriptName = "ECT_SR_NoWeights"; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; |
|
From: Marco M. <mi...@us...> - 2006-08-07 21:12:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26231/b7_Scripts/TickerSelectionTesting Modified Files: PortfolioType.cs Log Message: Added Serializable attribute to PortfolioType enumeration. Index: PortfolioType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/PortfolioType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PortfolioType.cs 26 Apr 2005 19:02:14 -0000 1.2 --- PortfolioType.cs 7 Aug 2006 21:12:24 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- /// to portfolio /// </summary> + [Serializable] public enum PortfolioType { |