quantproject-developers Mailing List for QuantProject (Page 66)
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
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17712/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: The generation number is now properly added to the logged information (if the position chooser uses a genetic optimizer) Index: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 16 Sep 2007 22:12:48 -0000 1.7 --- WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 7 Oct 2007 13:27:55 -0000 1.8 *************** *** 178,182 **** this.wFLagChosenPositions = new WFLagChosenPositions( ! wFLagWeightedPositions , now.DateTime ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = --- 178,182 ---- this.wFLagChosenPositions = new WFLagChosenPositions( ! wFLagWeightedPositions , genome.Generation , now.DateTime ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:24:41
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10707/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagChosenTickers.cs Log Message: Minor change: useless code has been commented out Index: WFLagChosenTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagChosenTickers.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WFLagChosenTickers.cs 3 Nov 2006 16:39:48 -0000 1.9 --- WFLagChosenTickers.cs 7 Oct 2007 13:24:37 -0000 1.10 *************** *** 204,253 **** } #endregion ! #region setWeightedPositions_usingTheBruteForceOptimizer ! private void newBruteForceOptimizerProgressEventHandler( ! object sender , NewProgressEventArgs e ) ! { ! this.NewProgress( sender , e ); ! } ! public virtual void setWeightedPositions_usingTheBruteForceOptimizer( ! WFLagEligibleTickers eligibleTickers ) ! { ! this.firstOptimizationDate = ! this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( ! -( this.inSampleDays - 1 ) ); ! this.lastOptimizationDate = ! this.endOfDayTimer.GetCurrentTime().DateTime; ! ! WFLagBruteForceOptimizableParametersManager ! wFLagBruteForceOptimizableItemManager= ! new WFLagBruteForceOptimizableParametersManager( ! eligibleTickers.EligibleTickers , ! eligibleTickers.EligibleTickers , ! this.firstOptimizationDate , ! this.lastOptimizationDate , ! this.numberOfDrivingPositions , ! this.numberOfPositionsToBeChosen , ! this.equityEvaluator ); ! ! BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( ! wFLagBruteForceOptimizableItemManager ); ! ! bruteForceOptimizer.NewProgress += ! new NewProgressEventHandler( ! this.newBruteForceOptimizerProgressEventHandler ); ! ! bruteForceOptimizer.Run(); ! ! BruteForceOptimizableParameters bestParameters = ! bruteForceOptimizer.BestParameters; ! ! WFLagWeightedPositions wFLagWeightedPositions = ! ( WFLagWeightedPositions )wFLagBruteForceOptimizableItemManager.Decode( ! bestParameters ); ! ! this.setWeightedPositions( wFLagWeightedPositions ); ! } ! #endregion ! #region setWeightedPositions_withFixedPortfolio // private void newBruteForceOptimizerProgressEventHandler( // object sender , NewProgressEventArgs e ) --- 204,208 ---- } #endregion ! // #region setWeightedPositions_usingTheBruteForceOptimizer // private void newBruteForceOptimizerProgressEventHandler( // object sender , NewProgressEventArgs e ) *************** *** 255,279 **** // this.NewProgress( sender , e ); // } ! public virtual void setWeightedPositions_withFixedPortfolio( ! WFLagEligibleTickers eligibleTickers , ! string longPortfolioTicker , string shortPortfolioTicker ) ! { ! this.firstOptimizationDate = ! this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( ! -( this.inSampleDays - 1 ) ); ! this.lastOptimizationDate = ! this.endOfDayTimer.GetCurrentTime().DateTime; ! ! // WFLagFixedPortfolioBruteForceOptimizableParametersManager ! // wFLagFixedPortfolioBruteForceOptimizableParametersManager= ! // new WFLagFixedPortfolioBruteForceOptimizableParametersManager( // eligibleTickers.EligibleTickers , - // longPortfolioTicker , - // shortPortfolioTicker , // this.firstOptimizationDate , // this.lastOptimizationDate , ! // this.numberOfDrivingPositions ); // ! // WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility // wFLagFixedPortfolioBruteForceOptimizableParametersManager= // new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( --- 210,288 ---- // this.NewProgress( sender , e ); // } ! // public virtual void setWeightedPositions_usingTheBruteForceOptimizer( ! // WFLagEligibleTickers eligibleTickers ) ! // { ! // this.firstOptimizationDate = ! // this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( ! // -( this.inSampleDays - 1 ) ); ! // this.lastOptimizationDate = ! // this.endOfDayTimer.GetCurrentTime().DateTime; ! // ! // WFLagBruteForceOptimizableParametersManager ! // wFLagBruteForceOptimizableItemManager= ! // new WFLagBruteForceOptimizableParametersManager( ! // eligibleTickers.EligibleTickers , // eligibleTickers.EligibleTickers , // this.firstOptimizationDate , // this.lastOptimizationDate , ! // this.numberOfDrivingPositions , ! // this.numberOfPositionsToBeChosen , ! // this.equityEvaluator ); // ! // BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( ! // wFLagBruteForceOptimizableItemManager ); ! // ! // bruteForceOptimizer.NewProgress += ! // new NewProgressEventHandler( ! // this.newBruteForceOptimizerProgressEventHandler ); ! // ! // bruteForceOptimizer.Run(); ! // ! // BruteForceOptimizableParameters bestParameters = ! // bruteForceOptimizer.BestParameters; ! // ! // WFLagWeightedPositions wFLagWeightedPositions = ! // ( WFLagWeightedPositions )wFLagBruteForceOptimizableItemManager.Decode( ! // bestParameters ); ! // ! // this.setWeightedPositions( wFLagWeightedPositions ); ! // } ! // #endregion ! // #region setWeightedPositions_withFixedPortfolio ! //// private void newBruteForceOptimizerProgressEventHandler( ! //// object sender , NewProgressEventArgs e ) ! //// { ! //// this.NewProgress( sender , e ); ! //// } ! // public virtual void setWeightedPositions_withFixedPortfolio( ! // WFLagEligibleTickers eligibleTickers , ! // string longPortfolioTicker , string shortPortfolioTicker ) ! // { ! // this.firstOptimizationDate = ! // this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( ! // -( this.inSampleDays - 1 ) ); ! // this.lastOptimizationDate = ! // this.endOfDayTimer.GetCurrentTime().DateTime; ! // ! //// WFLagFixedPortfolioBruteForceOptimizableParametersManager ! //// wFLagFixedPortfolioBruteForceOptimizableParametersManager= ! //// new WFLagFixedPortfolioBruteForceOptimizableParametersManager( ! //// eligibleTickers.EligibleTickers , ! //// longPortfolioTicker , ! //// shortPortfolioTicker , ! //// this.firstOptimizationDate , ! //// this.lastOptimizationDate , ! //// this.numberOfDrivingPositions ); ! //// ! //// WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility ! //// wFLagFixedPortfolioBruteForceOptimizableParametersManager= ! //// new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( ! //// eligibleTickers.EligibleTickers , ! //// longPortfolioTicker , ! //// shortPortfolioTicker , ! //// this.firstOptimizationDate , ! //// this.lastOptimizationDate , ! //// this.numberOfDrivingPositions ); ! // WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility // wFLagFixedPortfolioBruteForceOptimizableParametersManager= // new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( *************** *** 283,332 **** // this.firstOptimizationDate , // this.lastOptimizationDate , ! // this.numberOfDrivingPositions ); ! WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility ! wFLagFixedPortfolioBruteForceOptimizableParametersManager= ! new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( ! eligibleTickers.EligibleTickers , ! longPortfolioTicker , ! shortPortfolioTicker , ! this.firstOptimizationDate , ! this.lastOptimizationDate , ! this.numberOfDrivingPositions , ! this.equityEvaluator ); ! ! BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( ! wFLagFixedPortfolioBruteForceOptimizableParametersManager ); ! ! bruteForceOptimizer.NewProgress += ! new NewProgressEventHandler( ! this.newBruteForceOptimizerProgressEventHandler ); ! ! bruteForceOptimizer.Run( 100000 , ! wFLagFixedPortfolioBruteForceOptimizableParametersManager.TotalIterations ); ! ! BruteForceOptimizableParameters bestParameters = ! bruteForceOptimizer.BestParameters; ! ! WFLagWeightedPositions wFLagWeightedPositions = ! ( WFLagWeightedPositions )wFLagFixedPortfolioBruteForceOptimizableParametersManager.Decode( ! bestParameters ); ! ! this.setWeightedPositions( wFLagWeightedPositions ); ! } ! #endregion ! public virtual void SetWeightedPositions( ! WFLagEligibleTickers eligibleTickers ) ! { ! // this.setWeightedPositions_usingTheGeneticOptimizer( ! // eligibleTickers ); ! // this.setWeightedPositions_usingTheBruteForceOptimizer( ! // eligibleTickers ); ! this.setWeightedPositions_withFixedPortfolio( ! eligibleTickers , "SPY" , "IWM" ); ! // this.setWeightedPositions_withFixedPortfolio( ! // eligibleTickers , "XLF" , "SMH" ); // this.setWeightedPositions_withFixedPortfolio( ! // eligibleTickers , "QQQQ" , "SPY" ); ! } #endregion } --- 292,332 ---- // this.firstOptimizationDate , // this.lastOptimizationDate , ! // this.numberOfDrivingPositions , ! // this.equityEvaluator ); ! // ! // BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( ! // wFLagFixedPortfolioBruteForceOptimizableParametersManager ); ! // ! // bruteForceOptimizer.NewProgress += ! // new NewProgressEventHandler( ! // this.newBruteForceOptimizerProgressEventHandler ); ! // ! // bruteForceOptimizer.Run( 100000 , ! // wFLagFixedPortfolioBruteForceOptimizableParametersManager.TotalIterations ); ! // ! // BruteForceOptimizableParameters bestParameters = ! // bruteForceOptimizer.BestParameters; ! // ! // WFLagWeightedPositions wFLagWeightedPositions = ! // ( WFLagWeightedPositions )wFLagFixedPortfolioBruteForceOptimizableParametersManager.Decode( ! // bestParameters ); ! // ! // this.setWeightedPositions( wFLagWeightedPositions ); ! // } ! // #endregion ! // public virtual void SetWeightedPositions( ! // WFLagEligibleTickers eligibleTickers ) ! // { ! //// this.setWeightedPositions_usingTheGeneticOptimizer( ! //// eligibleTickers ); ! //// this.setWeightedPositions_usingTheBruteForceOptimizer( ! //// eligibleTickers ); // this.setWeightedPositions_withFixedPortfolio( ! // eligibleTickers , "SPY" , "IWM" ); ! //// this.setWeightedPositions_withFixedPortfolio( ! //// eligibleTickers , "XLF" , "SMH" ); ! //// this.setWeightedPositions_withFixedPortfolio( ! //// eligibleTickers , "QQQQ" , "SPY" ); ! // } #endregion } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:23:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8247/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger Modified Files: WFLagChosenPositions.cs Log Message: The generation number is now properly added to the logged information (if the position chooser uses a genetic optimizer) Index: WFLagChosenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagChosenPositions.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WFLagChosenPositions.cs 7 Aug 2007 16:52:48 -0000 1.6 --- WFLagChosenPositions.cs 7 Oct 2007 13:23:22 -0000 1.7 *************** *** 33,37 **** { /// <summary> ! /// Creates a copy of the relevant data for the WFLagChosenTickers object /// </summary> [Serializable] --- 33,37 ---- { /// <summary> ! /// Data to be logged (out of sample) for each new optimization /// </summary> [Serializable] *************** *** 93,97 **** --- 93,107 ---- this.lastOptimizationDate = lastOptimizationDate; } + /// <summary> + /// Data to be logged (out of sample) for each new optimization + /// </summary> + /// <param name="wFLagWeightedPositions">driving and portfolio + /// positions chosen</param> + /// <param name="generationWhenTheBestGenomeWasFound">generation when the + /// genetic optimizer found the best genome. This parameter is meaningless + /// if the optimizer does not use generations</param> + /// <param name="lastOptimizationDate"></param> public WFLagChosenPositions( WFLagWeightedPositions wFLagWeightedPositions , + int generationWhenTheBestGenomeWasFound , DateTime lastOptimizationDate ) { *************** *** 100,106 **** // this.portfolioPositions = // this.copy( wFLagChosenTickers.PortfolioWeightedPositions ); ! this.drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; ! this.portfolioWeightedPositions = wFLagWeightedPositions.PortfolioWeightedPositions; ! this.lastOptimizationDate = lastOptimizationDate; } --- 110,116 ---- // this.portfolioPositions = // this.copy( wFLagChosenTickers.PortfolioWeightedPositions ); ! this.initialize( wFLagWeightedPositions.DrivingWeightedPositions , ! wFLagWeightedPositions.PortfolioWeightedPositions , ! generationWhenTheBestGenomeWasFound , lastOptimizationDate ); } *************** *** 108,117 **** WeightedPositions portfolioWeightedPositions , DateTime lastOptimizationDate ) { ! // this.drivingPositions = ! // this.copy( wFLagChosenTickers.DrivingWeightedPositions ); ! // this.portfolioPositions = ! // this.copy( wFLagChosenTickers.PortfolioWeightedPositions ); ! this.drivingWeightedPositions = drivingWeightedPositions; ! this.portfolioWeightedPositions = portfolioWeightedPositions; this.lastOptimizationDate = lastOptimizationDate; } --- 118,137 ---- WeightedPositions portfolioWeightedPositions , DateTime lastOptimizationDate ) { ! // -1 is used because the optimizer was not genetic, so there is ! // no generation number to log ! this.initialize( drivingWeightedPositions , ! portfolioWeightedPositions , ! -1 , lastOptimizationDate ); ! } ! private void initialize( WeightedPositions drivingWeightedPositions , ! WeightedPositions portfolioWeightedPositions , ! int generationWhenTheBestGenomeWasFound , ! DateTime lastOptimizationDate ) ! { ! this.drivingWeightedPositions = ! drivingWeightedPositions; ! this.portfolioWeightedPositions = ! portfolioWeightedPositions; ! this.generation = generationWhenTheBestGenomeWasFound; this.lastOptimizationDate = lastOptimizationDate; } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:20:43
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2682/b4_Business/a2_Strategies Modified Files: WeightedPositions.cs Log Message: The GetReturns( ReturnsManager returnsManager ) method has been speed up (about 6 times faster now): several nested method calls have been replaced by a longer method, performing direct fast operations on arrays. Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WeightedPositions.cs 23 Sep 2007 21:54:57 -0000 1.9 --- WeightedPositions.cs 7 Oct 2007 13:20:37 -0000 1.10 *************** *** 394,414 **** #endregion #region GetBalancedWeights ! private static float[][] getTickerCloseToCloseReturnsForSignedTickers( ! string[] signedTickers , DateTime firstDate , DateTime lastDate ) ! { ! float[][] tickerReturns = new float[ signedTickers.Length ][]; ! for ( int i = 0 ; i < signedTickers.Length ; i++ ) ! { ! string ticker = SignedTicker.GetTicker( signedTickers[ i ] ); ! tickerReturns[ i ] = Quotes.GetArrayOfCloseToCloseRatios( ! ticker , firstDate , lastDate ); ! } ! return tickerReturns; ! } private static float getTickerReturnsStandardDeviations( int tickerIndex , SignedTickers signedTickers , ReturnsManager returnsManager ) { string ticker = signedTickers[ tickerIndex ].Ticker; ! return returnsManager.GetReturnsStandardDeviation( ticker ); } private static float[] getTickersReturnsStandardDeviations( --- 394,416 ---- #endregion #region GetBalancedWeights ! // private static float[][] getTickerCloseToCloseReturnsForSignedTickers( ! // string[] signedTickers , DateTime firstDate , DateTime lastDate ) ! // { ! // float[][] tickerReturns = new float[ signedTickers.Length ][]; ! // for ( int i = 0 ; i < signedTickers.Length ; i++ ) ! // { ! // string ticker = SignedTicker.GetTicker( signedTickers[ i ] ); ! // tickerReturns[ i ] = Quotes.GetArrayOfCloseToCloseRatios( ! // ticker , firstDate , lastDate ); ! // } ! // return tickerReturns; ! // } private static float getTickerReturnsStandardDeviations( int tickerIndex , SignedTickers signedTickers , ReturnsManager returnsManager ) { string ticker = signedTickers[ tickerIndex ].Ticker; ! float returnsStandardDeviation = ! returnsManager.GetReturnsStandardDeviation( ticker ); ! return returnsStandardDeviation; } private static float[] getTickersReturnsStandardDeviations( *************** *** 519,544 **** return tickerReturn * Convert.ToSingle( weightedPosition.Weight ); - - // int numberOfWeightedPositions = weightedPositions.Count; - // string[] tickers = this.getTickers( weightedPositions ); - // float[] multipliers = this.getMultipliers( weightedPositions ); - // // arrays of close to close returns, one for each signed ticker - // float[][] tickersReturns = - // this.wFLagCandidates.GetTickersReturns( tickers ); - // Aggiungi!!! weightedPositions.GetReturns( this.closeToCloseReturnsManager ) - // double[] linearCombinationReturns = - // new double[ tickersReturns[ 0 ].Length ]; - // for( int i = 0; i < linearCombinationReturns.Length ; i++ ) - // // computes linearCombinationReturns[ i ] - // { - // linearCombinationReturns[ i ] = 0; - // for ( int j=0 ; j < weightedPositions.Count ; j++ ) - // { - // double weightedPositionReturn = - // tickersReturns[ j ][ i ] * multipliers[ j ]; - // linearCombinationReturns[ i ] += weightedPositionReturn; - // } - // } - // return linearCombinationReturns; } private float getReturnActually( int i , ReturnsManager returnsManager ) --- 521,524 ---- *************** *** 560,564 **** { this.getReturnCheckParameters( i , returnsManager ); ! return getReturnActually( i , returnsManager ); } #endregion GetReturn --- 540,545 ---- { this.getReturnCheckParameters( i , returnsManager ); ! float currentReturn = this.getReturnActually( i , returnsManager ); ! return currentReturn; } #endregion GetReturn *************** *** 573,578 **** float[] returns = new float[ returnsManager.ReturnIntervals.Count ]; ! for ( int i = 0 ; i < returnsManager.NumberOfReturns ; i++ ) ! returns[ i ] = this.GetReturn( i , returnsManager ); return returns; } --- 554,580 ---- float[] returns = new float[ returnsManager.ReturnIntervals.Count ]; ! ! ! // weights[] is set to avoid several double to float conversions ! float[] weights = new float[ this.Count ]; ! float[][] tickersReturns = new float[ this.Count ][]; ! for ( int positionIndex = 0 ; positionIndex < this.Count ; positionIndex++ ) ! { ! weights[ positionIndex ] = ! Convert.ToSingle( ((WeightedPosition)(this[ positionIndex ])).Weight ); ! tickersReturns[ positionIndex ] = returnsManager.GetReturns( ! ((WeightedPosition)(this[ positionIndex ])).Ticker ); ! } ! ! for ( int intervalIndex = 0 ; ! intervalIndex < returnsManager.NumberOfReturns ; intervalIndex++ ) ! { ! returns[ intervalIndex ] = 0; ! for ( int positionIndex = 0 ; positionIndex < this.Count ; ! positionIndex++ ) ! returns[ intervalIndex ] += ! tickersReturns[ positionIndex ][ intervalIndex ] * ! weights[ positionIndex ]; ! } return returns; } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:16:26
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25191/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Minor change: a single line has been broken down to two separate lines, for a better debugging experience. This has been done for a couple of statements. Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ReturnsManager.cs 23 Sep 2007 16:24:45 -0000 1.6 --- ReturnsManager.cs 7 Oct 2007 13:15:55 -0000 1.7 *************** *** 109,113 **** { this.tickersMissingQuotes = new Set(); - this.tickersReturns = new Hashtable(); this.tickersReturnsStandardDeviations = new Hashtable(); --- 109,112 ---- *************** *** 172,179 **** private void setReturns( string ticker ) { - // EndOfDayDateTime firstEndOfDayDateTime = - // this.returnIntervals[ 0 ].Begin; - // EndOfDayDateTime lastEndOfDayDateTime = - // this.returnIntervals.LastEndOfDayDateTime; EndOfDayHistory endOfDayQuotes = this.historicalQuoteProvider.GetEndOfDayQuotes( ticker , --- 171,174 ---- *************** *** 189,195 **** { if ( !this.areReturnsAlreadySet( ticker ) ) ! // returns for this tickerhave not been set yet this.setReturns( ticker ); ! return this.getAlreadySetReturns( ticker ); } #endregion GetReturns --- 184,193 ---- { if ( !this.areReturnsAlreadySet( ticker ) ) ! { ! // returns for this ticker have not been set yet this.setReturns( ticker ); ! } ! float[] setReturns = this.getAlreadySetReturns( ticker ); ! return setReturns; } #endregion GetReturns *************** *** 218,222 **** { this.getReturnCheckParameters( ticker , returnIndex ); ! return this.getReturnActually( ticker , returnIndex ); } #endregion GetReturn --- 216,222 ---- { this.getReturnCheckParameters( ticker , returnIndex ); ! float actualReturn = ! this.getReturnActually( ticker , returnIndex ); ! return actualReturn; } #endregion GetReturn |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:14:22
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22030/b4_Business/a07_DataProviders Modified Files: HistoricalQuoteProvider.cs Log Message: Minor change: a single line has been broken down to two separate lines, for a better debugging experience Index: HistoricalQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalQuoteProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalQuoteProvider.cs 18 Sep 2007 22:42:08 -0000 1.2 --- HistoricalQuoteProvider.cs 7 Oct 2007 13:14:19 -0000 1.3 *************** *** 48,53 **** EndOfDayDateTime endOfDayDateTime ) { ! return QuantProject.Data.DataProviders.HistoricalDataProvider.WasExchanged( ticker , endOfDayDateTime.GetNearestExtendedDateTime() ); } #region GetEndOfDayQuotes --- 48,55 ---- EndOfDayDateTime endOfDayDateTime ) { ! bool wasExchanged = ! QuantProject.Data.DataProviders.HistoricalDataProvider.WasExchanged( ticker , endOfDayDateTime.GetNearestExtendedDateTime() ); + return wasExchanged; } #region GetEndOfDayQuotes *************** *** 66,71 **** --- 68,75 ---- (EndOfDayDateTime)endOfDayHistory.GetByIndex( historyIndex ); if ( this.WasExchanged( ticker , currentEndOfDayDateTime ) ) + { this.addQuoteActually( ticker , currentEndOfDayDateTime , endOfDayQuotes ); + } else throw new Exception( "The ticker " + ticker + " is not " + |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:13:55
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21094/b4_Business/a07_DataProviders Modified Files: HistoricalAdjustedQuoteProvider.cs Log Message: Minor change: a single line has been broken down to two separate lines, for a better debugging experience Index: HistoricalAdjustedQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalAdjustedQuoteProvider.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HistoricalAdjustedQuoteProvider.cs 16 Sep 2007 21:53:53 -0000 1.3 --- HistoricalAdjustedQuoteProvider.cs 7 Oct 2007 13:13:52 -0000 1.4 *************** *** 40,45 **** EndOfDayDateTime endOfDayDateTime ) { ! return HistoricalDataProvider.GetAdjustedMarketValue( instrumentKey , endOfDayDateTime.GetNearestExtendedDateTime() ); } } --- 40,47 ---- EndOfDayDateTime endOfDayDateTime ) { ! double marketValue = ! HistoricalDataProvider.GetAdjustedMarketValue( instrumentKey , endOfDayDateTime.GetNearestExtendedDateTime() ); + return marketValue; } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:12:18
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17881/b1_ADT/Optimizing/BruteForce Modified Files: BruteForceOptimizer.cs Log Message: A variable name has been changed: bruteForceOptimizableParameter is bruteForceOptimizableParameters now Index: BruteForceOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/BruteForce/BruteForceOptimizer.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BruteForceOptimizer.cs 8 Sep 2006 15:36:33 -0000 1.2 --- BruteForceOptimizer.cs 7 Oct 2007 13:12:13 -0000 1.3 *************** *** 81,88 **** while( this.bruteForceOptimizableParametersManager.MoveNext() ) { ! BruteForceOptimizableParameters bruteForceOptimizableParameter = (BruteForceOptimizableParameters)this.bruteForceOptimizableParametersManager.Current; ! if ( this.bestParameters.Fitness < bruteForceOptimizableParameter.Fitness ) ! this.bestParameters = bruteForceOptimizableParameter; this.handleProgress(); } --- 81,88 ---- while( this.bruteForceOptimizableParametersManager.MoveNext() ) { ! BruteForceOptimizableParameters bruteForceOptimizableParameters = (BruteForceOptimizableParameters)this.bruteForceOptimizableParametersManager.Current; ! if ( this.bestParameters.Fitness < bruteForceOptimizableParameters.Fitness ) ! this.bestParameters = bruteForceOptimizableParameters; this.handleProgress(); } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 13:03:56
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31435 Modified Files: b7_Scripts.csproj Log Message: - WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableEncoded.cs has been added - WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagBruteForceFixedPortfolioWeightedPositionsChooser.cs has been removed - WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagFitnessEvaluator.cs has been added - WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** b7_Scripts.csproj 16 Sep 2007 21:46:25 -0000 1.77 --- b7_Scripts.csproj 7 Oct 2007 13:03:52 -0000 1.78 *************** *** 834,837 **** --- 834,842 ---- /> <File + RelPath = "WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableEncoded.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableGenomes.cs" SubType = "Code" *************** *** 864,906 **** /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagBruteForceFixedPortfolioWeightedPositionsChooser.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticWithEqualWeights\WFLagGeneticWithEqualWeights.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagBruteForceOptimizableParametersManager.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagChosenPositions.cs" --- 869,912 ---- /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagFitnessEvaluator.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding\IWFLagDecoder.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding\WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers\WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticWithEqualWeights\WFLagGeneticWithEqualWeights.cs" SubType = "Code" BuildAction = "Compile" /> + <Folder RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\" /> <File RelPath = "WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagChosenPositions.cs" |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24822 Removed Files: WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs Log Message: The code for the brute force optimizable parameters managers for the lag strategy, has been moved to this new folder: b7_Scripts\WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers --- WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:59:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23056 Removed Files: WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs Log Message: The code for the brute force optimizable parameters managers for the lag strategy, has been moved to this new folder: b7_Scripts\WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers --- WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:58:31
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20044 Removed Files: WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs Log Message: b7_Scripts\WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers --- WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:57:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17697 Removed Files: WFLagBruteForceOptimizableParametersManager.cs Log Message: The code for the brute force optimizable parameters managers for the lag strategy, has been moved to this new folder: b7_Scripts\WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers --- WFLagBruteForceOptimizableParametersManager.cs DELETED --- |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/OptimizableParametersManagers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6706 Added Files: WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.cs Log Message: Implements IBruteForceOptimizableParametersManager Weights are balanced with respect to volatility both for portfolio positions and for driving positions Portfolio positions are given to the constructor, while driving positions are optimized --- NEW FILE: WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.cs --- /* QuantProject - Quantitative Finance Library WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.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; using System.Data; using QuantProject.ADT.Optimizing.BruteForce; using QuantProject.ADT.Statistics; using QuantProject.ADT.Statistics.Combinatorial; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers.Decoding; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers { /// <summary> /// Implements IBruteForceOptimizableParametersManager /// Weights are balanced with respect to volatility both for portfolio /// positions and for driving positions /// Portfolio positions are given to the constructor, while /// driving positions are optimized /// </summary> public class WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving : IBruteForceOptimizableParametersManager { // private double[] weightsForDrivingPositions; private DataTable eligibleTickersForDrivingPositions; private IWFLagDecoder wFLagDecoder; private WFLagFitnessEvaluator wFLagFitnessEvaluator; private Combination drivingCombination; // private double[] standardDeviationForDrivingPositions; // private float[][] drivingPositionsCloseToCloseReturns; public object Current { get { int[] currentValues = new int[ this.drivingCombination.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; } } public int TotalIterations { get { return Convert.ToInt32( this.drivingCombination.TotalNumberOfCombinations ); } } public WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving( DataTable eligibleTickersForDrivingPositions , string portfolioLongTicker , string portfolioShortTicker , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int numberOfDrivingPositions , IWFLagDecoder wFLagDecoder , IEquityEvaluator equityEvaluator , ReturnsManager returnsManager ) { this.eligibleTickersForDrivingPositions = eligibleTickersForDrivingPositions; this.wFLagDecoder = wFLagDecoder; this.wFLagFitnessEvaluator = new WFLagFitnessEvaluator( equityEvaluator , returnsManager ); this.drivingCombination = new Combination( - eligibleTickersForDrivingPositions.Rows.Count , eligibleTickersForDrivingPositions.Rows.Count - 1 , numberOfDrivingPositions ); } // protected override double[] // getWeightRelatedParameterValuesForDrivingPositions( // int[] optimizableParameters ) // { // double[] weightsForPortfolioPositions = // this.getWeightsForPortfolioPositions(); // string[] tickersForPortfolioPositions = // new string[ 2 ] { this.portfolioLongTicker , this.portfolioShortTicker }; // WeightedPositions weightedPositions = // new WeightedPositions( weightsForPortfolioPositions , // tickersForPortfolioPositions ); // return weightedPositions; // } // #region getWeightRelatedParameterValuesForDrivingPositions // private ArrayList getArrayListOfEligibleTickersForDrivingPositions() // { // ArrayList tickers = new ArrayList(); // foreach ( DataRow eligibleDrivingTicker in // this.eligibleTickersForDrivingWeightedPositions.Rows ) // tickers.Add( eligibleDrivingTicker[ 0 ] ); // return tickers; // } // private void setDrivingPositionsCloseToCloseReturns() // { // ArrayList tickers = // this.getArrayListOfEligibleTickersForDrivingPositions(); // this.drivingPositionsCloseToCloseReturns = // this.wFLagCandidates.GetTickersReturns( tickers ); // } // private void setStandardDeviationForDrivingPositionsActually( // int drivingPositionIndex ) // { // this.standardDeviationForDrivingPositions[ drivingPositionIndex ] = // BasicFunctions.GetStdDev( // this.drivingPositionsCloseToCloseReturns[ drivingPositionIndex ] ); // } // private void setStandardDeviationForDrivingPositionsActually() // { // this.setDrivingPositionsCloseToCloseReturns(); // this.standardDeviationForDrivingPositions = // new double[ this.eligibleTickersForDrivingWeightedPositions.Rows.Count ]; // for ( int i = 0 ; // i < this.eligibleTickersForDrivingWeightedPositions.Rows.Count ; // i++ ) // this.setStandardDeviationForDrivingPositionsActually( i ); // } // private void setStandardDeviationForDrivingPositions() // { // if ( this.standardDeviationForDrivingPositions == null ) // // this.standardDeviationForDrivingPositions has not been set yet // this.setStandardDeviationForDrivingPositionsActually(); // } // private double getStandardDeviation( int[] parameterValues , // int parameterPosition ) // { // int tickerIndex = this.getTickerIndexForDrivingPosition( // parameterValues , parameterPosition ); // return this.standardDeviationForDrivingPositions[ tickerIndex ]; // } // private double getMaxStandardDeviationForCurrentDrivingPositions( // int[] optimizableParameters ) // { // double maxStandardDeviationForCurrentDrivingPositions = 0; // for ( int parameterPosition = 0 ; parameterPosition < optimizableParameters.Length ; // parameterPosition++ ) // { // double drivingPositionStandardDeviation = // this.getStandardDeviation( optimizableParameters , parameterPosition ); // if ( drivingPositionStandardDeviation > maxStandardDeviationForCurrentDrivingPositions ) // maxStandardDeviationForCurrentDrivingPositions = drivingPositionStandardDeviation; // } // return maxStandardDeviationForCurrentDrivingPositions; // } // private double getNonNormalizedWeightForDrivingPosition( // int[] parameterValues , // int parameterPosition , // double maxStandardDeviationForCurrentDrivingPositions ) // { // double drivingPositionStandardDeviation = // this.getStandardDeviation( parameterValues , parameterPosition ); // double nonNormalizedWeightForDrivingPosition = // maxStandardDeviationForCurrentDrivingPositions / // drivingPositionStandardDeviation; // if ( parameterValues[ parameterPosition ] < 0 ) // nonNormalizedWeightForDrivingPosition = // -nonNormalizedWeightForDrivingPosition; // return nonNormalizedWeightForDrivingPosition; // } // private double[] getNonNormalizedWeightsForDrivingPositionsUsingStandardDeviations( // int[] parameterValues , // double maxStandardDeviationForCurrentDrivingPositions ) // { // double[] nonNormalizedWeightsForDrivingPositions = // new double[ parameterValues.Length ]; // for ( int parameterPosition = 0 ; parameterPosition < parameterValues.Length ; // parameterPosition++ ) // { // nonNormalizedWeightsForDrivingPositions[ parameterPosition ] = // this.getNonNormalizedWeightForDrivingPosition( // parameterValues , parameterPosition , // maxStandardDeviationForCurrentDrivingPositions ); // } // return nonNormalizedWeightsForDrivingPositions; // } // private double[] getNonNormalizedWeightsForDrivingPositions( // int[] parameterValues ) // { // double maxStandardDeviationForCurrentDrivingPositions = // this.getMaxStandardDeviationForCurrentDrivingPositions( parameterValues ); // return getNonNormalizedWeightsForDrivingPositionsUsingStandardDeviations( // parameterValues , maxStandardDeviationForCurrentDrivingPositions ); // } // private double[] getWeightsForDrivingPositions( // int[] parameterValues ) // { // double[] nonNormalizedWeightsForDrivingPositions = // this.getNonNormalizedWeightsForDrivingPositions( parameterValues ); // return // WeightedPositions.GetNormalizedWeights( // nonNormalizedWeightsForDrivingPositions ); // } // protected override double[] // getWeightRelatedParameterValuesForDrivingPositions( // int[] parameterValues ) // { // this.setStandardDeviationForDrivingPositions(); // return this.getWeightsForDrivingPositions( parameterValues ); // } // #endregion public bool MoveNext() { return this.drivingCombination.MoveNext(); } public void Reset() { this.drivingCombination.Reset(); } public object Decode( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { return this.wFLagDecoder.Decode( bruteForceOptimizableParameters.GetValues() ); } public double GetFitnessValue( BruteForceOptimizableParameters bruteForceOptimizableParameters ) { object meaning = this.Decode( bruteForceOptimizableParameters ); double fitnessValue = this.wFLagFitnessEvaluator.GetFitnessValue( meaning ); return fitnessValue; } } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:51:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/OptimizableParametersManagers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5206/OptimizableParametersManagers Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/OptimizableParametersManagers added to the repository |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/Decoding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24601 Added Files: WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility.cs Log Message: Decodes an array of int to a WFLagWeightedPositions object Weights are balanced with respect to volatility both for portfolio positions and for driving positions --- NEW FILE: WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility.cs --- /* QuantProject - Quantitative Finance Library WFLagDecoderForBalancedFixedPortfolioAndBalancedDriving.cs Copyright (C) 2007 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.Collections; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers.Decoding { /// <summary> /// Decodes an array of int to a WFLagWeightedPositions object /// Weights are balanced with respect to volatility both for portfolio /// positions and for driving positions /// </summary> public class WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility : IWFLagDecoder { private WFLagEligibleTickers eligibleTickersForDrivingWeightedPositions; private int numberOfDrivingPositions; private SignedTickers portfolioSignedTickers; private ReturnsManager returnsManager; private WFLagMeaningForUndecodableEncoded wFLagMeaningForUndecodableEncoded; private string[] tickersForPortfolioPositions; public WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility( WFLagEligibleTickers eligibleTickersForDrivingWeightedPositions , int numberOfDrivingPositions , SignedTickers portfolioSignedTickers , ReturnsManager returnsManager ) { this.eligibleTickersForDrivingWeightedPositions = eligibleTickersForDrivingWeightedPositions; this.numberOfDrivingPositions = numberOfDrivingPositions; this.portfolioSignedTickers = portfolioSignedTickers; this.returnsManager = returnsManager; this.wFLagMeaningForUndecodableEncoded = new WFLagMeaningForUndecodableEncoded(); } #region Decode #region getSignedTickersForDrivingPositions private int[] getTickerRelatedGeneValuesForDrivingPositions( int[] encoded ) { // this method is useless for a fixed portfolio decoder, // but I've written as a guideline for other decoders which // will use numberOfDrivingPositions instead of encoded.Length return IntArrayManager.SubArray( encoded , 0 , encoded.Length ); } private void decodeSignedTicker_checkParameters( int geneValue , WFLagEligibleTickers eligibleTickers ) { if ( geneValue >= eligibleTickers.EligibleTickers.Rows.Count ) throw new Exception( "geneValue is too (positive) large for eligibleTickers !!" ); if ( geneValue < -eligibleTickers.EligibleTickers.Rows.Count ) throw new Exception( "geneValue is too (negative) large for eligibleTickers !!" ); } private SignedTicker decodeSignedTicker( int signedTickerCode , WFLagEligibleTickers eligibleTickers ) { SignedTicker signedTicker; string ticker; decodeSignedTicker_checkParameters( signedTickerCode , eligibleTickers ); if ( signedTickerCode >= 0 ) { // long ticker ticker = ( string )eligibleTickers.EligibleTickers.Rows[ signedTickerCode ][ 0 ]; signedTicker = new SignedTicker( ticker , PositionType.Long ); } else { // short ticker ticker = ( string )eligibleTickers.EligibleTickers.Rows[ -(signedTickerCode+1) ][ 0 ]; signedTicker = new SignedTicker( ticker , PositionType.Short ); } return signedTicker; } private SignedTicker decodeSignedTickers( int i , int[] tickerRelatedGeneValues , WFLagEligibleTickers eligibleTickers ) { int currentGeneValue = tickerRelatedGeneValues[ i ]; return this.decodeSignedTicker( currentGeneValue , eligibleTickers ); } private SignedTickers decodeSignedTickers( int[] tickerRelatedGeneValues , WFLagEligibleTickers eligibleTickers ) { SignedTickers signedTickers = new SignedTickers(); for( int i = 0 ; i < tickerRelatedGeneValues.Length ; i++ ) { SignedTicker signedTicker = this.decodeSignedTickers( i , tickerRelatedGeneValues , eligibleTickers ); signedTickers.Add( signedTicker ); } return signedTickers; } private SignedTickers getSignedTickersForDrivingPositions( int[] encoded ) { int[] encodedDrivingPositions = this.getTickerRelatedGeneValuesForDrivingPositions( encoded ); return this.decodeSignedTickers( encodedDrivingPositions , this.eligibleTickersForDrivingWeightedPositions ); } #endregion getSignedTickersForDrivingPositions private string[] getTickersForDrivingPositions( int[] encoded ) { return this.getSignedTickersForDrivingPositions( encoded ).Tickers; } private bool isDecodable( int[] encoded ) { return ( WeightedPositions.AreValidTickers( this.getTickersForDrivingPositions( encoded ) ) ); } private WeightedPositions decodeDrivingWeightedPositions( int[] encoded ) { SignedTickers signedTickers = this.getSignedTickersForDrivingPositions( encoded ); double[] balancedWeightsForDrivingPositions = WeightedPositions.GetBalancedWeights( signedTickers , this.returnsManager ); WeightedPositions weightedPositions = new WeightedPositions( balancedWeightsForDrivingPositions , signedTickers.Tickers ); return weightedPositions; } #region getTickersForPortfolioPositions private void setTickerForPortfolioPositions( int i ) { SignedTicker signedTicker = this.portfolioSignedTickers[ i ]; this.tickersForPortfolioPositions[ i ] = signedTicker.Ticker; } private void setTickersForPortfolioPositions() { this.tickersForPortfolioPositions = new string[ this.portfolioSignedTickers.Count ]; for( int i=0 ; i < portfolioSignedTickers.Count ; i++ ) this.setTickerForPortfolioPositions( i ); } private string[] getTickersForPortfolioPositions() { if ( this.tickersForPortfolioPositions == null ) this.setTickersForPortfolioPositions(); return this.tickersForPortfolioPositions; } #endregion //getTickersForPortfolioPositions private double[] getBalancedWeightsForPortfolioPositions() { return WeightedPositions.GetBalancedWeights( this.portfolioSignedTickers , this.returnsManager ); } private WeightedPositions decodeWeightedPositions( double[] weights , string[] tickers ) { double[] normalizedWeights = WeightedPositions.GetNormalizedWeights( weights ); WeightedPositions weightedPositions = new WeightedPositions( normalizedWeights , tickers ); return weightedPositions; } private WeightedPositions decodePortfolioWeightedPositions( int[] encoded ) { string[] tickersForPortfolioPositions = this.getTickersForPortfolioPositions(); double[] portfolioPositionsWeights = this.getBalancedWeightsForPortfolioPositions(); return this.decodeWeightedPositions( portfolioPositionsWeights , tickersForPortfolioPositions ); } private WFLagWeightedPositions decodeDecodable( int[] encoded ) { WeightedPositions drivingWeightedPositions = this.decodeDrivingWeightedPositions( encoded ); WeightedPositions portfolioWeightedPositions = this.decodePortfolioWeightedPositions( encoded ); WFLagWeightedPositions wFLagWeightedPositions = new WFLagWeightedPositions( drivingWeightedPositions , portfolioWeightedPositions ); return wFLagWeightedPositions; } /// <summary> /// A positive array value means a long position. /// A negative array value means a short position. /// The positive value n means the same ticker as the value -(n+1). /// Thus, if there are p (>0) eligible tickers, array values should /// range from -p to p-1 /// </summary> /// <param name="encoded"></param> /// <returns></returns> public object Decode( int[] encoded ) { object meaning; if ( this.isDecodable( encoded ) ) // genome can be decoded to a WFLagWeightedPositions object meaning = this.decodeDecodable( encoded ); else // genome cannot be decoded to a WFLagWeightedPositions object meaning = this.wFLagMeaningForUndecodableEncoded; return meaning; } #endregion Decode } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:40:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/Decoding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16135 Added Files: IWFLagDecoder.cs Log Message: To be implemented by decoders for the Lag strategy --- NEW FILE: IWFLagDecoder.cs --- /* QuantProject - Quantitative Finance Library IWFLagDecoder.cs Copyright (C) 2007 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; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers.Decoding { /// <summary> /// To be implemented by decoders for the Lag strategy /// </summary> public interface IWFLagDecoder { /// <summary> /// Decodes the given optimization's candidate /// </summary> object Decode( int[] encoded ); } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:40:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/Decoding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15244/Decoding Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/Decoding added to the repository |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/BruteForce In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23030 Added Files: WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs Log Message: Computes the best driving positions, for the given portfolio tickers, with respect to the lag strategy, using the brute force optimization method. Weights for driving positions and for portfolio positions are searched in such a way to balance each position with respect to its volatility. --- NEW FILE: WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs --- /* QuantProject - Quantitative Finance Library WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.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.BruteForce; //using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers.Decoding; using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WFLagDebugger; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers { /// <summary> /// Computes the best driving positions, for the given portfolio /// tickers, with respect to the lag strategy, using /// the brute force optimization method. /// Weights for driving positions and for portfolio positions are searched in /// such a way to balance each position with respect to its volatility. /// </summary> [Serializable] public class WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving : IWFLagWeightedPositionsChooser { public event NewProgressEventHandler NewProgress; protected int numberOfDrivingPositions; protected SignedTickers portfolioSignedTickers; protected int inSampleDays; protected string benchmark; protected IEquityEvaluator equityEvaluator; private IWFLagDecoder wFLagDecoder; private ReturnsManager returnsManager; private WFLagChosenPositions wFLagChosenPositions; private WeightedPositions drivingWeightedPositions; private WeightedPositions portfolioWeightedPositions; private DateTime firstOptimizationDate; private DateTime lastOptimizationDate; public int NumberOfDrivingPositions { get { return this.numberOfDrivingPositions; } } public int NumberOfPortfolioPositions { get { return this.portfolioSignedTickers.Count; } } public int NumberDaysForInSampleOptimization { get { return this.inSampleDays; } } public string Benchmark { get { return this.benchmark; } } public WeightedPositions DrivingWeightedPositions { get { return this.drivingWeightedPositions; } } public WeightedPositions PortfolioWeightedPositions { get { return this.portfolioWeightedPositions; } } public DateTime FirstOptimizationDate { get { return this.firstOptimizationDate; } } public DateTime LastOptimizationDate { get { return this.lastOptimizationDate; } } public WFLagChosenPositions WFLagChosenPositions { get { return this.wFLagChosenPositions; } } public WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving( int numberOfDrivingPositions , SignedTickers portfolioSignedTickers , int inSampleDays , string benchmark , IEquityEvaluator equityEvaluator ) { this.numberOfDrivingPositions = numberOfDrivingPositions; this.portfolioSignedTickers = portfolioSignedTickers; this.inSampleDays = inSampleDays; this.benchmark = benchmark; this.equityEvaluator = equityEvaluator; } #region SetWeightedPositions // private void setSignedTickers_clearPositions() // { // this.drivingPositions.Clear(); // this.portfolioPositions.Clear(); // } // #region setWeightedPositions_usingTheGeneticOptimizer // private void newGenerationEventHandler( // object sender , NewGenerationEventArgs e ) // { // this.NewProgress( sender , // new NewProgressEventArgs( e.GenerationCounter , e.GenerationNumber ) ); // } private void setWeightedPositions( WFLagWeightedPositions wFLagWeightedPositions ) { this.drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; this.portfolioWeightedPositions = wFLagWeightedPositions.PortfolioWeightedPositions; } // private void setSignedTickers_setTickersFromGenome( // IGenomeManager genomeManager , // Genome genome ) // { // WFLagWeightedPositions wFLagWeightedPositions = // ( WFLagWeightedPositions )genomeManager.Decode( genome ); // this.setWeightedPositions( wFLagWeightedPositions ); //// this.drivingWeightedPositions = //// wFLagWeightedPositions.DrivingWeightedPositions; //// this.portfolioWeightedPositions = //// wFLagWeightedPositions.PortfolioWeightedPositions; // } // public virtual void setWeightedPositions_usingTheGeneticOptimizer( // WFLagEligibleTickers eligibleTickers ) // { // 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 , // this.equityEvaluator , // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); // // GeneticOptimizer geneticOptimizer = new GeneticOptimizer( // 0.85 , // 0.02 , // 0.001 , // this.populationSizeForGeneticOptimizer , // this.generationNumberForGeneticOptimizer , // genomeManager , // ConstantsProvider.SeedForRandomGenerator ); // // geneticOptimizer.NewGeneration += // new NewGenerationEventHandler( this.newGenerationEventHandler ); // // geneticOptimizer.Run( false ); // // this.setSignedTickers_setTickersFromGenome( // genomeManager , geneticOptimizer.BestGenome ); // // this.generation = geneticOptimizer.BestGenome.Generation; // // } // #endregion // #region setWeightedPositions_usingTheBruteForceOptimizer // private void newBruteForceOptimizerProgressEventHandler( // object sender , NewProgressEventArgs e ) // { // this.NewProgress( sender , e ); // } // public virtual void setWeightedPositions_usingTheBruteForceOptimizer( // WFLagEligibleTickers eligibleTickers ) // { // this.firstOptimizationDate = // this.endOfDayTimer.GetCurrentTime().DateTime.AddDays( // -( this.inSampleDays - 1 ) ); // this.lastOptimizationDate = // this.endOfDayTimer.GetCurrentTime().DateTime; // // WFLagBruteForceOptimizableParametersManager // wFLagBruteForceOptimizableItemManager= // new WFLagBruteForceOptimizableParametersManager( // eligibleTickers.EligibleTickers , // eligibleTickers.EligibleTickers , // this.firstOptimizationDate , // this.lastOptimizationDate , // this.numberOfDrivingPositions , // this.numberOfPositionsToBeChosen , // this.equityEvaluator ); // // BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( // wFLagBruteForceOptimizableItemManager ); // // bruteForceOptimizer.NewProgress += // new NewProgressEventHandler( // this.newBruteForceOptimizerProgressEventHandler ); // // bruteForceOptimizer.Run(); // // BruteForceOptimizableParameters bestParameters = // bruteForceOptimizer.BestParameters; // // WFLagWeightedPositions wFLagWeightedPositions = // ( WFLagWeightedPositions )wFLagBruteForceOptimizableItemManager.Decode( // bestParameters ); // // this.setWeightedPositions( wFLagWeightedPositions ); // } // #endregion #region setDecoder #region setReturnsManager protected virtual ReturnIntervals getReturnIntervals( EndOfDayDateTime now ) { DateTime firstInSampleDateForDrivingPositions = now.DateTime.AddDays( -( this.NumberDaysForInSampleOptimization - 1 ) ); DateTime lastInSampleOptimizationDate = now.DateTime; ReturnIntervals returnIntervals = new CloseToCloseIntervals( new EndOfDayDateTime( firstInSampleDateForDrivingPositions , EndOfDaySpecificTime.MarketClose ) , new EndOfDayDateTime( lastInSampleOptimizationDate , EndOfDaySpecificTime.MarketClose ) , this.benchmark ); return returnIntervals; } private void setReturnsManager( EndOfDayDateTime now ) { ReturnIntervals returnIntervals = this.getReturnIntervals( now ); IHistoricalQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); this.returnsManager = new ReturnsManager( returnIntervals , historicalQuoteProvider ); } #endregion setReturnsManager protected virtual void setDecoder( WFLagEligibleTickers eligibleTickersForDrivingPositions , EndOfDayDateTime now ) { this.setReturnsManager( now ); this.wFLagDecoder = new WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility( eligibleTickersForDrivingPositions , this.numberOfDrivingPositions , this.portfolioSignedTickers , returnsManager ); } #endregion setDecoder #region setWeightedPositions_withFixedPortfolio // private void newBruteForceOptimizerProgressEventHandler( // object sender , NewProgressEventArgs e ) // { // this.NewProgress( sender , e ); // } private void newBruteForceOptimizerProgressEventHandler( object sender , NewProgressEventArgs e ) { this.NewProgress( sender , e ); } public virtual void setWeightedPositions_withFixedPortfolio( WFLagEligibleTickers eligibleTickers , string longPortfolioTicker , string shortPortfolioTicker , EndOfDayDateTime now ) { this.firstOptimizationDate = now.DateTime.AddDays( -( this.inSampleDays - 1 ) ); this.lastOptimizationDate = now.DateTime; // WFLagFixedPortfolioBruteForceOptimizableParametersManager // wFLagFixedPortfolioBruteForceOptimizableParametersManager= // new WFLagFixedPortfolioBruteForceOptimizableParametersManager( // eligibleTickers.EligibleTickers , // longPortfolioTicker , // shortPortfolioTicker , // this.firstOptimizationDate , // this.lastOptimizationDate , // this.numberOfDrivingPositions ); // // WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility // wFLagFixedPortfolioBruteForceOptimizableParametersManager= // new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( // eligibleTickers.EligibleTickers , // longPortfolioTicker , // shortPortfolioTicker , // this.firstOptimizationDate , // this.lastOptimizationDate , // this.numberOfDrivingPositions ); WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving wFLagFixedPortfolioBruteForceOptimizableParametersManager= new WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving( eligibleTickers.EligibleTickers , longPortfolioTicker , shortPortfolioTicker , this.firstOptimizationDate , this.lastOptimizationDate , this.numberOfDrivingPositions , this.wFLagDecoder , this.equityEvaluator , this.returnsManager ); BruteForceOptimizer bruteForceOptimizer = new BruteForceOptimizer( wFLagFixedPortfolioBruteForceOptimizableParametersManager ); bruteForceOptimizer.NewProgress += new NewProgressEventHandler( this.newBruteForceOptimizerProgressEventHandler ); bruteForceOptimizer.Run( 10000 , wFLagFixedPortfolioBruteForceOptimizableParametersManager.TotalIterations ); BruteForceOptimizableParameters bestParameters = bruteForceOptimizer.BestParameters; WFLagWeightedPositions wFLagWeightedPositions = ( WFLagWeightedPositions )wFLagFixedPortfolioBruteForceOptimizableParametersManager.Decode( bestParameters ); this.setWeightedPositions( wFLagWeightedPositions ); } #endregion public virtual void ChosePositions( WFLagEligibleTickers eligibleTickersForDrivingPositions , WFLagEligibleTickers eligibleTickersForPortfolioPositions , EndOfDayDateTime now ) { this.setDecoder( eligibleTickersForDrivingPositions , now ); this.setWeightedPositions_withFixedPortfolio( eligibleTickersForDrivingPositions , "SPY" , "IWM" , now ); this.wFLagChosenPositions = new WFLagChosenPositions( this.DrivingWeightedPositions , this.PortfolioWeightedPositions , now.DateTime ); } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:12:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/BruteForce In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22462/BruteForce Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/BruteForce added to the repository |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:12:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18854 Removed Files: WFLagBruteForceFixedPortfolioWeightedPositionsChooser.cs Log Message: The new folder b7_Scripts\WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce has been created for the Brute Force optimizers --- WFLagBruteForceFixedPortfolioWeightedPositionsChooser.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:12:04
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Collections In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10124/b1_ADT/Collections Added Files: IntArrayManager.cs Log Message: This class provides methods to manage arrays of int --- NEW FILE: IntArrayManager.cs --- /* QuantProject - Quantitative Finance Library IntArrayManager.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.Collections { /// <summary> /// This class provides methods to manage arrays of int /// </summary> public class IntArrayManager { public IntArrayManager() { // // TODO: Add constructor logic here // } #region SubArray private static void subArray_checkParameters( int[] arrayOfInt , int firstPosition , int numberOfElementsToBeSelected ) { if ( firstPosition < 0 ) throw new Exception( "firstPosition is less than zero!" ); if ( firstPosition >= arrayOfInt.Length ) throw new Exception( "firstPosition is >= than arrayOfInt.Length!" ); if ( numberOfElementsToBeSelected < 0 ) throw new Exception( "numberOfElementsToBeSelected is less than zero!" ); if ( firstPosition + numberOfElementsToBeSelected > arrayOfInt.Length ) throw new Exception( "firstPosition + numberOfElementsToBeSelected is >= arrayOfInt.Length !!" ); } /// <summary> /// Returns a subarray of arrayOfInt /// </summary> /// <param name="arrayOfInt"></param> /// <param name="firstPosition"></param> /// <param name="numberOfElementsToBeSelected"></param> /// <returns></returns> public static int[] SubArray( int[] arrayOfInt , int firstPosition , int numberOfElementsToBeSelected ) { subArray_checkParameters( arrayOfInt , firstPosition , numberOfElementsToBeSelected ); int[] subArray = new int[ numberOfElementsToBeSelected ]; for ( int i = 0 ; i < numberOfElementsToBeSelected ; i++ ) { int currentPosition = firstPosition + i; subArray[ i ] = arrayOfInt[ currentPosition ]; } return arrayOfInt; } #endregion SubArray } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:03:41
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10980/b1_ADT Modified Files: b1_ADT.csproj Log Message: Collections\IntArrayManager.cs has been added Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** b1_ADT.csproj 13 Jul 2007 10:00:42 -0000 1.25 --- b1_ADT.csproj 7 Oct 2007 10:27:50 -0000 1.26 *************** *** 163,166 **** --- 163,171 ---- /> <File + RelPath = "Collections\IntArrayManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Collections\QPHashtable.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:03:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14610 Added Files: WFLagMeaningForUndecodableEncoded.cs Log Message: Object used to assign a dummy meaning to those objects (genomes or bruteForceOptimizableParameters) that cannot be decoded to a WFLagWeightedPositions (usually for duplicated tickers) --- NEW FILE: WFLagMeaningForUndecodableEncoded.cs --- /* QuantProject - Quantitative Finance Library WFLagMeaningForUndecodableEncoded.cs Copyright (C) 2007 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.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// Object used to assign a dummy meaning to those objects (genomes or /// bruteForceOptimizableParameters) that /// cannot be decoded to a WFLagWeightedPositions /// (usually for duplicated tickers) /// </summary> public class WFLagMeaningForUndecodableEncoded { public WFLagMeaningForUndecodableEncoded() { // // TODO: Add constructor logic here // } } } |
|
From: Glauco S. <gla...@us...> - 2007-10-07 12:03:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19578 Added Files: WFLagFitnessEvaluator.cs Log Message: Computes the fitness for a given WFLagWeightedPositions object --- NEW FILE: WFLagFitnessEvaluator.cs --- /* QuantProject - Quantitative Finance Library WFLagFitnessEvaluator.cs Copyright (C) 2007 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WeightedPositionsChoosers { /// <summary> /// Computes the fitness for a given WFLagWeightedPositions object /// </summary> public class WFLagFitnessEvaluator { private ReturnsManager returnsManager; private IEquityEvaluator equityEvaluator; public WFLagFitnessEvaluator( IEquityEvaluator equityEvaluator , ReturnsManager returnsManager ) { this.equityEvaluator = equityEvaluator; this.returnsManager = returnsManager; } #region GetFitnessValue private string[] getTickers( WeightedPositions weightedPositions ) { string[] tickers = new string[ weightedPositions.Count ]; for ( int i = 0 ; i < weightedPositions.Count ; i++ ) { WeightedPosition weightedPosition = weightedPositions.GetWeightedPosition( i ); tickers[ i ] = weightedPosition.Ticker; } return tickers; } private float[] getMultipliers( WeightedPositions weightedPositions ) { float[] multipliers = new float[ weightedPositions.Count ]; for ( int i = 0 ; i < weightedPositions.Count ; i++ ) { WeightedPosition weightedPosition = weightedPositions.GetWeightedPosition( i ); multipliers[ i ] = Convert.ToSingle( weightedPosition.Weight ); } return multipliers; } private float[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { float[] linearCombinatioReturns = weightedPositions.GetReturns( this.returnsManager ); return linearCombinatioReturns; } private float[] getFitnessValue_getStrategyReturn( float[] drivingPositionsReturns , float[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) float[] strategyReturns = new float[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) // the current linear combination of tickers, at period i // has a negative return // go short tomorrow strategyReturns[ i ] = -portfolioPositionsReturns[ i + 1 ]; else // the current linear combination of tickers, at period i // has a positive return // go long tomorrow strategyReturns[ i ] = portfolioPositionsReturns[ i + 1 ]; return strategyReturns; } private float getFitnessValue( float[] strategyReturns ) { float fitnessValue = this.equityEvaluator.GetReturnsEvaluation( strategyReturns ); return fitnessValue; } private float getFitnessValue( WFLagWeightedPositions wFLagWeightedPositions ) { float[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); float[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); float[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); float fitnessValue = this.getFitnessValue( strategyReturns ); return fitnessValue; } public double GetFitnessValue( object meaning ) { double fitnessValue; if ( meaning is WFLagWeightedPositions ) { // for the current optimization's candidate, // all driving positions are distinct and // all portfolio positions are distinct WFLagWeightedPositions wFLagWeightedPositions = (WFLagWeightedPositions)meaning; fitnessValue = this.getFitnessValue( wFLagWeightedPositions ); } else { // the current optimization's candidate contains // a duplicate gene for either // driving positions or portfolio positions fitnessValue = -0.4; } return fitnessValue; } #endregion GetFitnessValue } } |