quantproject-developers Mailing List for QuantProject (Page 78)
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-11-03 16:34:11
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17671/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting Modified Files: WFLagGOTester.cs Log Message: The script structure has been improved: an IEquityEvaluator parameter has been added to the RunWalkForwardLag constructor Index: WFLagGOTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/GeneticOptimizerTesting/WFLagGOTester.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagGOTester.cs 21 Aug 2006 19:33:46 -0000 1.1 --- WFLagGOTester.cs 3 Nov 2006 16:34:06 -0000 1.2 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.Strategies; + using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Timing; *************** *** 67,71 **** IEndOfDayTimer endOfDayTimer , int generationNumberForGeneticOptimizer , ! int populationSizeForGeneticOptimizer ) : base( numberOfDrivingPositions , numberOfPositionsToBeChosen , --- 68,73 ---- IEndOfDayTimer endOfDayTimer , int generationNumberForGeneticOptimizer , ! int populationSizeForGeneticOptimizer , ! IEquityEvaluator equityEvaluator ) : base( numberOfDrivingPositions , numberOfPositionsToBeChosen , *************** *** 73,77 **** endOfDayTimer , generationNumberForGeneticOptimizer , ! populationSizeForGeneticOptimizer ) { } --- 75,80 ---- endOfDayTimer , generationNumberForGeneticOptimizer , ! populationSizeForGeneticOptimizer , ! equityEvaluator) { } *************** *** 129,132 **** --- 132,136 ---- this.numberOfDrivingPositions , this.numberOfPositionsToBeChosen , + this.equityEvaluator , seed * 100 ); |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:32:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17170/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagMain.cs Log Message: The script structure has been improved: an IEquityEvaluator parameter has been added to the RunWalkForwardLag constructor Index: WFLagMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagMain.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WFLagMain.cs 24 Jun 2006 14:33:44 -0000 1.5 --- WFLagMain.cs 3 Nov 2006 16:32:53 -0000 1.6 *************** *** 117,131 **** private void NewBacktest_Click(object sender, System.EventArgs e) { - new RunWalkForwardLag( "millo" , 500 , - 3 , 3 , 90 , 20 , 3 , 5000 , "MSFT" , - new DateTime( 2003 , 1 , 1 ) , - new DateTime( 2003 , 1 , 8 ) , - 1 ).Run(); // new RunWalkForwardLag( "ib_etf" , 500 , ! // 4 , 4 , 200 , 14 , 50 , 90000 , "EWQ" , // new DateTime( 2003 , 8 , 13 ) , // new DateTime( 2003 , 12 , 31 ) , ! // 7.4 ).Run(); ! // new RunWalkForwardLag( "ib_etf" , 500 , // 4 , 4 , 250 , 2 , 15 , 30000 , "EWQ" , // new DateTime( 2003 , 1 , 1 ) , --- 117,147 ---- private void NewBacktest_Click(object sender, System.EventArgs e) { // new RunWalkForwardLag( "ib_etf" , 500 , ! // 4 , 2 , 200 , 3 , 4500 , 1000 , "EWQ" , // new DateTime( 2003 , 8 , 13 ) , // new DateTime( 2003 , 12 , 31 ) , ! // 8 ).Run(); ! // new RunWalkForwardLag( "millo" , 500 , ! // 3 , 2 , 90 , 20 , 3 , 5000 , "MSFT" , ! // new DateTime( 2003 , 1 , 1 ) , ! // new DateTime( 2003 , 1 , 8 ) , ! // 1 ).Run(); ! ! // fixed portfolio ! // new RunWalkForwardLag( "DrvPstns" , 500 , ! // 4 , 4 , 100 , 13 , 9 , 100 , "EWQ" , ! // new DateTime( 2001 , 1 , 1 ) , ! // new DateTime( 2003 , 12 , 31 ) , ! // 7 ).Run(); ! // XLF vs SMH ! // QQQQ vs SPY ! new RunWalkForwardLag( "DrvPstns" , 500 , ! 4 , 2 , 200 , 13 , 9 , 100 , "EWQ" , ! new DateTime( 2002 , 1 , 1 ) , ! new DateTime( 2003 , 12 , 31 ) , ! new QuantProject.Business.Strategies.EquityEvaluation.WinningPeriods() , ! 8.5 ).Run(); ! ! // new RunWalkForwardLag( "ib_etf" , 500 , // 4 , 4 , 250 , 2 , 15 , 30000 , "EWQ" , // new DateTime( 2003 , 1 , 1 ) , |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:29:46
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15598/b4_Business Modified Files: b4_Business.csproj Log Message: - a2_Strategies\EquityEvaluation\IEquityEvaluator.cs has been added - a2_Strategies\EquityEvaluation\WinningPeriods.cs has been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** b4_Business.csproj 31 Jul 2006 16:39:47 -0000 1.36 --- b4_Business.csproj 3 Nov 2006 16:29:42 -0000 1.37 *************** *** 620,623 **** --- 620,633 ---- /> <File + RelPath = "a2_Strategies\EquityEvaluation\IEquityEvaluator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a2_Strategies\EquityEvaluation\WinningPeriods.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a3_Testing\BackTester.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:28:31
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15105 Added Files: WinningPeriods.cs Log Message: Equity line evaluator, measuring the percentage of winning periods on the total number of non flat periods --- NEW FILE: WinningPeriods.cs --- /* QuantProject - Quantitative Finance Library WinningPeriods.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.Business.Strategies.EquityEvaluation { /// <summary> /// Equity line evaluator, measuring the percentage of winning /// periods on the total number of non flat periods /// </summary> public class WinningPeriods : IEquityEvaluator { public WinningPeriods() { } public double GetReturnsEvaluation( double[] returns ) { int winningPeriods = 0; int losingPeriods = 0; for ( int i = 0 ; i < returns.Length ; i++ ) { if ( returns[ i ] > 0 ) winningPeriods++; if ( returns[ i ] < 0 ) losingPeriods++; } return ( Convert.ToDouble( winningPeriods ) / Convert.ToDouble( winningPeriods + losingPeriods ) ); } } } |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:27:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv14354 Modified Files: IEquityEvaluator.cs Log Message: Interface to be implemented by equity line evaluators Index: IEquityEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation/IEquityEvaluator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IEquityEvaluator.cs 3 Nov 2006 16:25:40 -0000 1.1 --- IEquityEvaluator.cs 3 Nov 2006 16:27:03 -0000 1.2 *************** *** 26,30 **** { /// <summary> ! /// Interface to be implemented by equity evaluators /// </summary> public interface IEquityEvaluator --- 26,30 ---- { /// <summary> ! /// Interface to be implemented by equity line evaluators /// </summary> public interface IEquityEvaluator |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:25:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13928 Added Files: IEquityEvaluator.cs Log Message: Interface to be implemented by equity evaluators --- NEW FILE: IEquityEvaluator.cs --- /* QuantProject - Quantitative Finance Library IEquityEvaluator.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.Business.Strategies.EquityEvaluation { /// <summary> /// Interface to be implemented by equity evaluators /// </summary> public interface IEquityEvaluator { double GetReturnsEvaluation( double[] returns ); } } |
|
From: Glauco S. <gla...@us...> - 2006-11-03 16:24:57
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13528/EquityEvaluation Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation added to the repository |
|
From: Marco M. <mi...@us...> - 2006-10-22 18:50:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22156/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: FixedLevelOscillatorPVOStrategy.cs Log Message: Added symmetricalThresholds parameter, in order to fix a unique threshold for overbought / oversold. Index: FixedLevelOscillatorPVOStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/FixedLevelOscillatorPVOStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FixedLevelOscillatorPVOStrategy.cs 17 Sep 2006 21:24:53 -0000 1.1 --- FixedLevelOscillatorPVOStrategy.cs 22 Oct 2006 18:50:10 -0000 1.2 *************** *** 52,56 **** 0,0, "^GSPC", ! 0, 0, 0, 0, 0, 0, 0, PortfolioType.ShortAndLong, 0.5) { --- 52,56 ---- 0,0, "^GSPC", ! 0, 0, 0, 0, 0, 0, false, 0, PortfolioType.ShortAndLong, 0.5) { |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21838/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: RunPVO.cs GenomeManagerPVO.cs EndOfDayTimerHandlerPVO.cs Log Message: Added symmetricalThresholds parameter, in order to fix a unique threshold for overbought / oversold. Index: GenomeManagerPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/GenomeManagerPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerPVO.cs 17 Sep 2006 21:24:53 -0000 1.1 --- GenomeManagerPVO.cs 22 Oct 2006 18:49:20 -0000 1.2 *************** *** 46,49 **** --- 46,51 ---- private int maxLevelForOverboughtThreshold; private int divisorForThresholdComputation; + private bool symmetricalThresholds = false; + private int numOfGenesDedicatedToThresholds; private double currentOversoldThreshold = 0.0; private double currentOverboughtThreshold = 0.0; *************** *** 54,65 **** //throughout the period itself ! private void genomeManagerPVO_checkParametersForThresholdComputation() { if(this.maxLevelForOverboughtThreshold < this.minLevelForOverboughtThreshold || this.maxLevelForOversoldThreshold < this.minLevelForOversoldThreshold || this.divisorForThresholdComputation < this.maxLevelForOverboughtThreshold || ! this.divisorForThresholdComputation < this.maxLevelForOversoldThreshold) ! throw new Exception("Bad parameters for threshold computation!"); } --- 56,69 ---- //throughout the period itself ! private void genomeManagerPVO_checkParametersForThresholdsComputation() { if(this.maxLevelForOverboughtThreshold < this.minLevelForOverboughtThreshold || this.maxLevelForOversoldThreshold < this.minLevelForOversoldThreshold || this.divisorForThresholdComputation < this.maxLevelForOverboughtThreshold || ! this.divisorForThresholdComputation < this.maxLevelForOversoldThreshold || ! (this.symmetricalThresholds && (this.minLevelForOversoldThreshold != this.minLevelForOverboughtThreshold || ! this.maxLevelForOversoldThreshold != this.maxLevelForOverboughtThreshold) ) ) ! throw new Exception("Bad parameters for thresholds computation!"); } *************** *** 74,78 **** int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, ! PortfolioType portfolioType) : base(setOfInitialTickers, --- 78,83 ---- int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, ! bool symmetricalThresholds, ! PortfolioType inSamplePortfolioType) : base(setOfInitialTickers, *************** *** 81,95 **** numberOfTickersInPortfolio, 0.0, ! portfolioType) { this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; ! this.minLevelForOversoldThreshold = minLevelForOversoldThreshold; this.maxLevelForOversoldThreshold = maxLevelForOversoldThreshold; this.minLevelForOverboughtThreshold = minLevelForOverboughtThreshold; this.maxLevelForOverboughtThreshold = maxLevelForOverboughtThreshold; ! this.divisorForThresholdComputation = divisorForThresholdComputation; ! this.genomeManagerPVO_checkParametersForThresholdComputation(); this.retrieveData(); } --- 86,105 ---- numberOfTickersInPortfolio, 0.0, ! inSamplePortfolioType) { this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; ! this.divisorForThresholdComputation = divisorForThresholdComputation; ! this.minLevelForOversoldThreshold = minLevelForOversoldThreshold; this.maxLevelForOversoldThreshold = maxLevelForOversoldThreshold; this.minLevelForOverboughtThreshold = minLevelForOverboughtThreshold; this.maxLevelForOverboughtThreshold = maxLevelForOverboughtThreshold; ! this.symmetricalThresholds = symmetricalThresholds; ! if(this.symmetricalThresholds)//value for thresholds must be unique ! numOfGenesDedicatedToThresholds = 1; ! else ! numOfGenesDedicatedToThresholds = 2; ! this.genomeManagerPVO_checkParametersForThresholdsComputation(); this.retrieveData(); } *************** *** 97,102 **** public override int GenomeSize { ! get{return this.genomeSize + 2;} ! //two initial genes are for oversold and overbought thresholds } --- 107,128 ---- public override int GenomeSize { ! get{return this.genomeSize + this.numOfGenesDedicatedToThresholds;} ! } ! ! #region Get Min and Max Value ! ! private int getMinValueForGenes_getMinValueForTicker() ! { ! int returnValue; ! switch (this.portfolioType) ! { ! case PortfolioType.OnlyLong : ! returnValue = 0; ! break; ! default://For ShortAndLong or OnlyShort portfolios ! returnValue = - this.originalNumOfTickers; ! break; ! } ! return returnValue; } *************** *** 110,117 **** break; case 1 ://gene for overbought threshold ! returnValue = this.minLevelForOverboughtThreshold; ! break; default://gene for ticker ! returnValue = - this.originalNumOfTickers; break; } --- 136,146 ---- break; case 1 ://gene for overbought threshold ! if(this.numOfGenesDedicatedToThresholds == 2) ! returnValue = this.minLevelForOverboughtThreshold; ! else ! returnValue = this.getMinValueForGenes_getMinValueForTicker(); ! break; default://gene for ticker ! returnValue = this.getMinValueForGenes_getMinValueForTicker(); break; } *************** *** 119,122 **** --- 148,166 ---- } + private int getMaxValueForGenes_getMaxValueForTicker() + { + int returnValue; + switch (this.portfolioType) + { + case PortfolioType.OnlyShort : + returnValue = - 1; + break; + default ://For ShortAndLong or OnlyLong portfolios + returnValue = this.originalNumOfTickers - 1; + break; + } + return returnValue; + } + public override int GetMaxValueForGenes(int genePosition) { *************** *** 128,144 **** break; case 1 ://gene for overbought threshold ! returnValue = this.maxLevelForOverboughtThreshold; break; default://gene for ticker ! returnValue = this.originalNumOfTickers - 1; break; } return returnValue; } ! protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); returnValue = QuantProject.ADT.ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, Quotes.AdjustedCloseToCloseRatio); --- 172,194 ---- break; case 1 ://gene for overbought threshold ! if(this.numOfGenesDedicatedToThresholds == 2) ! returnValue = this.maxLevelForOverboughtThreshold; ! else ! returnValue = this.getMaxValueForGenes_getMaxValueForTicker(); break; default://gene for ticker ! returnValue = this.getMaxValueForGenes_getMaxValueForTicker(); break; } return returnValue; } ! ! #endregion ! protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); + tickerQuotes.RecalculateCloseToCloseRatios(); returnValue = QuantProject.ADT.ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, Quotes.AdjustedCloseToCloseRatio); *************** *** 175,180 **** this.currentOversoldThreshold = Convert.ToDouble(genome.Genes()[0])/ Convert.ToDouble(this.divisorForThresholdComputation); ! this.currentOverboughtThreshold = Convert.ToDouble(genome.Genes()[1])/ ! Convert.ToDouble(this.divisorForThresholdComputation); } --- 225,234 ---- this.currentOversoldThreshold = Convert.ToDouble(genome.Genes()[0])/ Convert.ToDouble(this.divisorForThresholdComputation); ! ! if(this.symmetricalThresholds) ! this.currentOverboughtThreshold = this.currentOversoldThreshold; ! else ! this.currentOverboughtThreshold = Convert.ToDouble(genome.Genes()[1])/ ! Convert.ToDouble(this.divisorForThresholdComputation); } *************** *** 183,187 **** int returnValue = 0; foreach(double equityReturn in equityLine) ! if(equityReturn > 0.0) returnValue++; --- 237,242 ---- int returnValue = 0; foreach(double equityReturn in equityLine) ! if(equityReturn != 0.0) ! //the applied strategy gets positions on the market returnValue++; *************** *** 234,239 **** protected override double getTickerWeight(int[] genes, int tickerPositionInGenes) { ! return 1.0/(genes.Length - 2); ! //two genes are for thresholds } --- 289,293 ---- protected override double getTickerWeight(int[] genes, int tickerPositionInGenes) { ! return 1.0/(genes.Length - this.numOfGenesDedicatedToThresholds); } *************** *** 243,247 **** for(int i = 0; i<returnValue.Length; i++) { ! for(int j=2; j<genes.Length; j++)//the first two genes are for thresholds returnValue[i] += this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray(genes,j,i); --- 297,301 ---- for(int i = 0; i<returnValue.Length; i++) { ! for(int j=this.numOfGenesDedicatedToThresholds; j<genes.Length; j++)//the first numOfGenesDedicatedToThresholds are for thresholds returnValue[i] += this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray(genes,j,i); *************** *** 252,264 **** public override object Decode(Genome genome) { ! string[] arrayOfTickers = new string[genome.Genes().Length - 2]; int geneForTicker; ! for(int genePosition = 2; genePosition < genome.Genes().Length; genePosition++) { geneForTicker = (int)genome.Genes().GetValue(genePosition); ! arrayOfTickers[genePosition - 2] = this.decode_getTickerCodeForLongOrShortTrade(geneForTicker); } ! GenomeMeaningPVO meaning = new GenomeMeaningPVO( arrayOfTickers, Convert.ToDouble(genome.Genes()[0])/Convert.ToDouble(this.divisorForThresholdComputation), --- 306,329 ---- public override object Decode(Genome genome) { ! string[] arrayOfTickers = ! new string[genome.Genes().Length - this.numOfGenesDedicatedToThresholds]; int geneForTicker; ! GenomeMeaningPVO meaning; ! for(int genePosition = this.numOfGenesDedicatedToThresholds; ! genePosition < genome.Genes().Length; ! genePosition++) { geneForTicker = (int)genome.Genes().GetValue(genePosition); ! arrayOfTickers[genePosition - this.numOfGenesDedicatedToThresholds] = this.decode_getTickerCodeForLongOrShortTrade(geneForTicker); } ! if(this.symmetricalThresholds) ! meaning = new GenomeMeaningPVO( ! arrayOfTickers, ! Convert.ToDouble(genome.Genes()[0])/Convert.ToDouble(this.divisorForThresholdComputation), ! Convert.ToDouble(genome.Genes()[0])/Convert.ToDouble(this.divisorForThresholdComputation), ! this.numDaysForOscillatingPeriod); ! else ! meaning = new GenomeMeaningPVO( arrayOfTickers, Convert.ToDouble(genome.Genes()[0])/Convert.ToDouble(this.divisorForThresholdComputation), *************** *** 277,284 **** childs[1] = parent2.Clone(); //exchange of genes coding thresholds ! childs[0].SetGeneValue(parent2.GetGeneValue(0),0); ! childs[0].SetGeneValue(parent2.GetGeneValue(1),1); ! childs[1].SetGeneValue(parent1.GetGeneValue(0),0); ! childs[1].SetGeneValue(parent1.GetGeneValue(1),1); return childs; } --- 342,358 ---- childs[1] = parent2.Clone(); //exchange of genes coding thresholds ! ! if(this.symmetricalThresholds)//unique value for thresholds ! { ! childs[0].SetGeneValue(parent2.GetGeneValue(0),0); ! childs[1].SetGeneValue(parent1.GetGeneValue(0),0); ! } ! else//two different values for thresholds ! { ! childs[0].SetGeneValue(parent2.GetGeneValue(0),0); ! childs[1].SetGeneValue(parent1.GetGeneValue(0),0); ! childs[0].SetGeneValue(parent2.GetGeneValue(1),1); ! childs[1].SetGeneValue(parent1.GetGeneValue(1),1); ! } return childs; } *************** *** 295,300 **** returnValue = GenomeManagement.RandomGenerator.Next(minValueForGene, maxValueForGene + 1); ! while(genePosition > 1 ! && GenomeManipulator.IsTickerContainedInGenome(returnValue,genome,2,genome.Size - 1)) //while in the given position has to be stored //a new gene pointing to a ticker and --- 369,377 ---- returnValue = GenomeManagement.RandomGenerator.Next(minValueForGene, maxValueForGene + 1); ! while(genePosition > this.numOfGenesDedicatedToThresholds - 1 ! && GenomeManipulator.IsTickerContainedInGenome(returnValue, ! genome, ! this.numOfGenesDedicatedToThresholds, ! genome.Size - 1)) //while in the given position has to be stored //a new gene pointing to a ticker and *************** *** 319,326 **** { int newValueForGene = GenomeManagement.RandomGenerator.Next(minValueForGene, ! maxValueForGene +1); ! while(genePositionToBeMutated > 1 && ! GenomeManipulator.IsTickerContainedInGenome(newValueForGene,genome,2,genome.Size - 1)) //while in the proposed genePositionToBeMutated has to be stored //a new gene pointing to a ticker and --- 396,406 ---- { int newValueForGene = GenomeManagement.RandomGenerator.Next(minValueForGene, ! maxValueForGene + 1); ! while(genePositionToBeMutated > this.numOfGenesDedicatedToThresholds - 1 && ! GenomeManipulator.IsTickerContainedInGenome(newValueForGene, ! genome, ! this.numOfGenesDedicatedToThresholds, ! genome.Size - 1)) //while in the proposed genePositionToBeMutated has to be stored //a new gene pointing to a ticker and Index: RunPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/RunPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunPVO.cs 17 Sep 2006 21:24:53 -0000 1.1 --- RunPVO.cs 22 Oct 2006 18:49:20 -0000 1.2 *************** *** 53,65 **** public class RunPVO : RunEfficientPortfolio { ! private int minLevelForOversoldThreshold; ! private int maxLevelForOversoldThreshold; ! private int minLevelForOverboughtThreshold; ! private int maxLevelForOverboughtThreshold; ! private int divisorForThresholdComputation; //to be used by the optimizer ! private int numDaysBetweenEachOptimization; ! private double maxAcceptableCloseToCloseDrawdown; ! private int numDaysForOscillatingPeriod; public RunPVO(string tickerGroupID, int maxNumOfEligibleTickersForOptimization, --- 53,66 ---- public class RunPVO : RunEfficientPortfolio { ! protected int minLevelForOversoldThreshold; ! protected int maxLevelForOversoldThreshold; ! protected int minLevelForOverboughtThreshold; ! protected int maxLevelForOverboughtThreshold; ! protected int divisorForThresholdComputation; //to be used by the optimizer ! protected int numDaysBetweenEachOptimization; ! protected double maxAcceptableCloseToCloseDrawdown; ! protected int numDaysForOscillatingPeriod; ! protected bool symmetricalThresholds = false; public RunPVO(string tickerGroupID, int maxNumOfEligibleTickersForOptimization, *************** *** 74,79 **** int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, double maxRunningHours): base(tickerGroupID, maxNumOfEligibleTickersForOptimization, --- 75,81 ---- int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, + bool symmetricalThresholds, int numDaysBetweenEachOptimization, ! PortfolioType inSamplePortfolioType, double maxAcceptableCloseToCloseDrawdown, double maxRunningHours): base(tickerGroupID, maxNumOfEligibleTickersForOptimization, *************** *** 82,86 **** populationSizeForGeneticOptimizer, benchmark, startDate, endDate, 0.0, ! portfolioType, maxRunningHours) { this.ScriptName = "PVO_SR_NoWeights_PriceSel"; --- 84,88 ---- populationSizeForGeneticOptimizer, benchmark, startDate, endDate, 0.0, ! inSamplePortfolioType, maxRunningHours) { this.ScriptName = "PVO_SR_NoWeights_PriceSel"; *************** *** 90,93 **** --- 92,96 ---- this.maxLevelForOverboughtThreshold = maxLevelForOverboughtThreshold; this.divisorForThresholdComputation = divisorForThresholdComputation; + this.symmetricalThresholds = symmetricalThresholds; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; *************** *** 110,113 **** --- 113,117 ---- this.maxLevelForOverboughtThreshold, this.divisorForThresholdComputation, + this.symmetricalThresholds, this.numDaysBetweenEachOptimization, this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); *************** *** 137,141 **** public override void SaveScriptResults() { ! string fileName = this.scriptName + "OsDays_" + numDaysForOscillatingPeriod + "_From_" + this.tickerGroupID + "_" + this.numberOfEligibleTickers + "_DaysForOpt" + this.numDaysForOptimizationPeriod + "Tick" + --- 141,147 ---- public override void SaveScriptResults() { ! string fileName = DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! this.scriptName + "OsDays_" + numDaysForOscillatingPeriod + "_From_" + this.tickerGroupID + "_" + this.numberOfEligibleTickers + "_DaysForOpt" + this.numDaysForOptimizationPeriod + "Tick" + Index: EndOfDayTimerHandlerPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/EndOfDayTimerHandlerPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerPVO.cs 17 Sep 2006 21:24:53 -0000 1.1 --- EndOfDayTimerHandlerPVO.cs 22 Oct 2006 18:49:20 -0000 1.2 *************** *** 48,70 **** public class EndOfDayTimerHandlerPVO : EndOfDayTimerHandler { ! private int minLevelForOversoldThreshold; ! private int maxLevelForOversoldThreshold; ! private int minLevelForOverboughtThreshold; ! private int maxLevelForOverboughtThreshold; ! private int divisorForThresholdComputation; protected int numDaysForOscillatingPeriod; protected double currentOversoldThreshold; protected double currentOverboughtThreshold; ! private double maxAcceptableCloseToCloseDrawdown; ! private bool stopLossConditionReached; ! private double currentAccountValue; ! private double previousAccountValue; ! private int numDaysBetweenEachOptimization; ! private int numDaysElapsedSinceLastOptimization; ! private DateTime lastCloseDate; ! private IGenomeManager iGenomeManager; ! private int seedForRandomGenerator; ! private bool portfolioHasBeenOverbought; ! private bool portfolioHasBeenOversold; public EndOfDayTimerHandlerPVO(string tickerGroupID, int numberOfEligibleTickers, --- 48,71 ---- public class EndOfDayTimerHandlerPVO : EndOfDayTimerHandler { ! protected int minLevelForOversoldThreshold; ! protected int maxLevelForOversoldThreshold; ! protected int minLevelForOverboughtThreshold; ! protected int maxLevelForOverboughtThreshold; ! protected int divisorForThresholdComputation; protected int numDaysForOscillatingPeriod; protected double currentOversoldThreshold; protected double currentOverboughtThreshold; ! protected double maxAcceptableCloseToCloseDrawdown; ! protected bool stopLossConditionReached; ! protected double currentAccountValue; ! protected double previousAccountValue; ! protected int numDaysBetweenEachOptimization; ! protected int numDaysElapsedSinceLastOptimization; ! protected DateTime lastCloseDate; ! protected IGenomeManager iGenomeManager; ! protected int seedForRandomGenerator; ! protected bool portfolioHasBeenOverbought; ! protected bool portfolioHasBeenOversold; ! protected bool symmetricalThresholds; public EndOfDayTimerHandlerPVO(string tickerGroupID, int numberOfEligibleTickers, *************** *** 80,83 **** --- 81,85 ---- int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, + bool symmetricalThresholds, int numDaysBetweenEachOptimization, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown): *************** *** 95,98 **** --- 97,101 ---- this.maxLevelForOverboughtThreshold = maxLevelForOverboughtThreshold; this.divisorForThresholdComputation = divisorForThresholdComputation; + this.symmetricalThresholds = symmetricalThresholds; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; *************** *** 259,263 **** ! protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); --- 262,266 ---- ! protected virtual DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); *************** *** 266,271 **** SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate, ! currentDate.AddDays(-30), numOfTickersInGroupAtCurrentDate, 25,500, 0.0001,100); --- 269,274 ---- SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate.AddDays(-30), ! currentDate, numOfTickersInGroupAtCurrentDate, 25,500, 0.0001,100); *************** *** 276,288 **** this.numberOfEligibleTickers); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromMostLiquid = ! new SelectorByQuotationAtEachMarketDay(mostLiquidSelector.GetTableOfSelectedTickers(), false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers, this.benchmark); ! return quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } ! private void addPVOGenomeToBestGenomes(Genome genome, DateTime firstOptimizationDate, DateTime secondOptimizationDate, --- 279,298 ---- this.numberOfEligibleTickers); ! SelectorByCloseToCloseCorrelationToBenchmark byCorrelationToBenchmark = ! new SelectorByCloseToCloseCorrelationToBenchmark(mostLiquidSelector.GetTableOfSelectedTickers(), ! "^GSPC",false, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers/2,false); ! ! ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = ! new SelectorByQuotationAtEachMarketDay(byCorrelationToBenchmark.GetTableOfSelectedTickers(), false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers/2, this.benchmark); ! return quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); } ! protected void addPVOGenomeToBestGenomes(Genome genome, DateTime firstOptimizationDate, DateTime secondOptimizationDate, *************** *** 324,327 **** --- 334,338 ---- this.maxLevelForOverboughtThreshold, this.divisorForThresholdComputation, + this.symmetricalThresholds, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, |
|
From: Marco M. <mi...@us...> - 2006-10-22 18:30:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13946/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientPortfolio.cs Log Message: Fixed important bug in a sub method called by getRatesOfReturn (for the portfolio represented by the genome): the bug was caused by considering 0 a short ticker, while the decode method considered 0, properly, a long ticker. This fix should improve, theoretically, all scripts using IGenomeManager deriving from GenomeManagerForEfficientPortfolio. like the OpenToClose script. Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** GenomeManagerForEfficientPortfolio.cs 17 Sep 2006 21:41:37 -0000 1.25 --- GenomeManagerForEfficientPortfolio.cs 22 Oct 2006 18:30:18 -0000 1.26 *************** *** 152,156 **** this.minValueForGenes = - this.originalNumOfTickers; //if gene g is negative, it refers to the ticker |g|-1 to be shorted ! this.maxValueForGenes = 0; break; case QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios.PortfolioType.ShortAndLong : --- 152,156 ---- this.minValueForGenes = - this.originalNumOfTickers; //if gene g is negative, it refers to the ticker |g|-1 to be shorted ! this.maxValueForGenes = - 1; break; case QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios.PortfolioType.ShortAndLong : *************** *** 321,326 **** { string initialCharForTickerCode = ""; ! int position = geneValue; ! if(geneValue<0) { position = Math.Abs(geneValue) - 1; --- 321,326 ---- { string initialCharForTickerCode = ""; ! int position = geneValue;//for geneValue >= 0 the coded ticker is for long ! if(geneValue < 0) { position = Math.Abs(geneValue) - 1; *************** *** 434,439 **** { int position = geneValueForTickerIdx; ! if(geneValueForTickerIdx<0) ! position = Math.Abs(geneValueForTickerIdx + 1); return position; } --- 434,439 ---- { int position = geneValueForTickerIdx; ! if(geneValueForTickerIdx < 0) ! position = Math.Abs(geneValueForTickerIdx) - 1; return position; } *************** *** 444,448 **** { bool longReturns = false; ! if(genes[tickerPositionInGenes] > 0) //genes[tickerPositionInGenes], the code for ticker, points to a ticker for which long returns are to be examined longReturns = true; --- 444,448 ---- { bool longReturns = false; ! if(genes[tickerPositionInGenes] >= 0) //genes[tickerPositionInGenes], the code for ticker, points to a ticker for which long returns are to be examined longReturns = true; |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:13:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4107/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WeightedPositions.cs Log Message: The GetNormalizedWeights public method has been added: given a generic set of virtual weights, it returns proportionate weights whose absolute values sum up to 1 Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WeightedPositions.cs 8 Sep 2006 15:32:27 -0000 1.2 --- WeightedPositions.cs 8 Oct 2006 16:13:54 -0000 1.3 *************** *** 275,279 **** tickers ); } ! } } --- 275,315 ---- tickers ); } ! #region GetNormalizedWeights ! private static double getAbsoluteWeightSum( double[] nonNormalizedWeights ) ! { ! double absoluteWeightSum = 0; ! foreach ( double nonNormalizedWeight in nonNormalizedWeights ) ! absoluteWeightSum += Math.Abs( nonNormalizedWeight ); ! return absoluteWeightSum; ! } ! private static double getNormalizingFactor( double[] nonNormalizedWeights ) ! { ! double absoluteWeightSum = ! getAbsoluteWeightSum( nonNormalizedWeights ); ! double normalizingFactor = 1 / absoluteWeightSum; ! return normalizingFactor; ! } ! private static double[] getNormalizedWeights( double[] nonNormalizedWeights , ! double normalizingFactor ) ! { ! double[] normalizedWeights = new double[ nonNormalizedWeights.Length ]; ! for ( int i = 0 ; i < nonNormalizedWeights.Length ; i ++ ) ! normalizedWeights[ i ] = nonNormalizedWeights[ i ] * normalizingFactor; ! return normalizedWeights; ! } ! /// <summary> ! /// Returns weights whose absolute values sum up to 1 ! /// </summary> ! /// <param name="nonNormalizedWeights"></param> ! /// <returns></returns> ! /// ! public static double[] GetNormalizedWeights( double[] nonNormalizedWeights ) ! { ! double normalizingFactor = ! getNormalizingFactor( nonNormalizedWeights ); ! return ! getNormalizedWeights( nonNormalizedWeights , normalizingFactor ); ! } ! #endregion } } |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:12:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3279/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager Modified Files: WFLagBruteForceOptimizableParametersManager.cs Log Message: - the private members eligibleTickersForDrivingPositions and eligibleTickersForPortfolioPositions are protected now - the private method getTickerIndexForDrivingPositions is protected now Index: WFLagBruteForceOptimizableParametersManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager/WFLagBruteForceOptimizableParametersManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagBruteForceOptimizableParametersManager.cs 21 Aug 2006 19:37:22 -0000 1.1 --- WFLagBruteForceOptimizableParametersManager.cs 8 Oct 2006 16:12:01 -0000 1.2 *************** *** 44,49 **** private int numberOfPortfolioPositions; private WFLagGenomeManager wFLagGenomeManager; ! private DataTable eligibleTickersForDrivingPositions; ! private DataTable eligibleTickersForPortfolioPositions; public WFLagBruteForceOptimizableParametersManager( --- 44,49 ---- private int numberOfPortfolioPositions; private WFLagGenomeManager wFLagGenomeManager; ! protected DataTable eligibleTickersForDrivingPositions; ! protected DataTable eligibleTickersForPortfolioPositions; public WFLagBruteForceOptimizableParametersManager( *************** *** 140,144 **** return weightRelatedParameterValuesForDrivingPositions; } ! private int getTickerIndexForDrivingPositions( int[] parameterValues , int parameterPosition ) { --- 140,144 ---- return weightRelatedParameterValuesForDrivingPositions; } ! protected int getTickerIndexForDrivingPositions( int[] parameterValues , int parameterPosition ) { |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:10:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2840/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagCandidates.cs Log Message: The Count property has been added Index: WFLagCandidates.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagCandidates.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFLagCandidates.cs 30 Jul 2006 13:53:26 -0000 1.4 --- WFLagCandidates.cs 8 Oct 2006 16:10:45 -0000 1.5 *************** *** 41,44 **** --- 41,52 ---- private Hashtable closeToCloseReturns; + /// <summary> + /// Number of eligible tickers + /// </summary> + public int Count + { + get { return this.eligibleTickers.Rows.Count; } + } + public WFLagCandidates( DataTable eligibleTickers , DateTime firstQuoteDate , DateTime lastQuoteDate ) |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:10:19
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2760/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger Modified Files: WFLagChosenPositionsDebugInfo.cs Log Message: Bug fixed: a new statement is used for the rare case when the firstCommonDateForTickers comes after this.getInSampleFirstDate() It may happen when this.getInSampleFirstDate() falls in a non market day and one of the involved tickers begins being quoted from the following market day Index: WFLagChosenPositionsDebugInfo.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger/WFLagChosenPositionsDebugInfo.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WFLagChosenPositionsDebugInfo.cs 8 Aug 2006 09:44:12 -0000 1.5 --- WFLagChosenPositionsDebugInfo.cs 8 Oct 2006 16:10:16 -0000 1.6 *************** *** 122,127 **** this.preSampleSharpeRatio30 = this.getPreSampleSharpeRatio( 30 ); this.preSampleSharpeRatio150 = this.getPreSampleSharpeRatio( 150 ); ! this.preSampleMaxSharpeRatio = this.getPreSampleSharpeRatio( ! this.MaxPreSampleDays ); this.postSampleSharpeRatio30 = this.getPostSampleSharpeRatio( 30 ); this.postSampleSharpeRatio150 = this.getPostSampleSharpeRatio( 150 ); --- 122,128 ---- this.preSampleSharpeRatio30 = this.getPreSampleSharpeRatio( 30 ); this.preSampleSharpeRatio150 = this.getPreSampleSharpeRatio( 150 ); ! if ( this.MaxPreSampleDays > 1 ) ! this.preSampleMaxSharpeRatio = this.getPreSampleSharpeRatio( ! this.MaxPreSampleDays - 1 ); this.postSampleSharpeRatio30 = this.getPostSampleSharpeRatio( 30 ); this.postSampleSharpeRatio150 = this.getPostSampleSharpeRatio( 150 ); *************** *** 178,182 **** TimeSpan timeSpan = this.getInSampleFirstDate() - firstCommonDateForTickers; ! this.maxPreSampleDays = timeSpan.Days - 1; // I subtract one, so I have the number of daily returns } private DateTime getInSampleFirstDate() --- 179,189 ---- TimeSpan timeSpan = this.getInSampleFirstDate() - firstCommonDateForTickers; ! this.maxPreSampleDays = timeSpan.Days; ! // the following statement is used for the rare case when the ! // firstCommonDateForTickers comes after this.getInSampleFirstDate() ! // It may happen when this.getInSampleFirstDate() ! // falls in a non market day and one of the involved tickers begins being ! // quoted from the following market day ! this.maxPreSampleDays = Math.Max( this.maxPreSampleDays , 0 ); } private DateTime getInSampleFirstDate() *************** *** 203,207 **** { double preSampleSharpeRatio = this.dummyValue; ! if ( this.MaxPreSampleDays >= days ) { DateTime lastDateTime = this.getInSampleFirstDate(); --- 210,214 ---- { double preSampleSharpeRatio = this.dummyValue; ! if ( this.MaxPreSampleDays > days ) { DateTime lastDateTime = this.getInSampleFirstDate(); |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:08:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1898/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagChosenTickers.cs Log Message: Code has been added so that now WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility and/or WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility can be used also Index: WFLagChosenTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagChosenTickers.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WFLagChosenTickers.cs 20 Sep 2006 21:06:33 -0000 1.7 --- WFLagChosenTickers.cs 8 Oct 2006 16:08:30 -0000 1.8 *************** *** 269,272 **** --- 269,281 ---- // this.numberOfDrivingPositions ); // + // WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility + // wFLagFixedPortfolioBruteForceOptimizableParametersManager= + // new WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( + // eligibleTickers.EligibleTickers , + // longPortfolioTicker , + // shortPortfolioTicker , + // this.firstOptimizationDate , + // this.lastOptimizationDate , + // this.numberOfDrivingPositions ); WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility wFLagFixedPortfolioBruteForceOptimizableParametersManager= *************** *** 306,315 **** // this.setWeightedPositions_usingTheBruteForceOptimizer( // eligibleTickers ); - this.setWeightedPositions_withFixedPortfolio( - eligibleTickers , "SPY" , "IWM" ); // this.setWeightedPositions_withFixedPortfolio( ! // eligibleTickers , "XLF" , "SMH" ); // this.setWeightedPositions_withFixedPortfolio( ! // eligibleTickers , "QQQQ" , "SPY" ); } #endregion --- 315,324 ---- // 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...> - 2006-10-08 16:06:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1079/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagEligibleTickers.cs Log Message: A bug has been fixed: one more historical day is used by the Selectors Index: WFLagEligibleTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagEligibleTickers.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WFLagEligibleTickers.cs 20 Sep 2006 21:02:45 -0000 1.3 --- WFLagEligibleTickers.cs 8 Oct 2006 16:06:32 -0000 1.4 *************** *** 74,78 **** SelectorByLiquidity mostLiquid = new SelectorByLiquidity( this.tickerGroupID , true , ! dateTime.AddDays( - this.numberDaysForPerformanceCalculation ) , dateTime , 200000 , 99999 ); DataTable groupTickers = mostLiquid.GetTableOfSelectedTickers(); --- 74,78 ---- SelectorByLiquidity mostLiquid = new SelectorByLiquidity( this.tickerGroupID , true , ! dateTime.AddDays( - ( this.numberDaysForPerformanceCalculation - 1 ) ) , dateTime , 200000 , 99999 ); DataTable groupTickers = mostLiquid.GetTableOfSelectedTickers(); *************** *** 87,91 **** new SelectorByQuotationAtEachMarketDay( groupTickers , false , ! dateTime.AddDays( - this.numberDaysForPerformanceCalculation ) , dateTime , this.numberEligibleTickersToBeChosen , this.benchmark ); return quotedInEachMarketDay.GetTableOfSelectedTickers(); --- 87,91 ---- new SelectorByQuotationAtEachMarketDay( groupTickers , false , ! dateTime.AddDays( - ( this.numberDaysForPerformanceCalculation - 1 ) ) , dateTime , this.numberEligibleTickersToBeChosen , this.benchmark ); return quotedInEachMarketDay.GetTableOfSelectedTickers(); |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:03:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv32232/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager Modified Files: WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs Log Message: - the private method getWeightRelatedParameterValuesForDrivingPositions has been changed to protected virtual (it is overridden by derived classes) - the private method getTickerIndexForDrivingPositions has become protected Index: WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager/WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs 20 Sep 2006 21:01:56 -0000 1.2 --- WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs 8 Oct 2006 16:03:44 -0000 1.3 *************** *** 136,140 **** return weight; } ! private double[] getWeightRelatedParameterValuesForDrivingPositions( int[] optimizableParameters ) { --- 136,140 ---- return weight; } ! protected virtual double[] getWeightRelatedParameterValuesForDrivingPositions( int[] optimizableParameters ) { *************** *** 148,152 **** return weightRelatedParameterValuesForDrivingPositions; } ! private int getTickerIndexForDrivingPositions( int[] parameterValues , int parameterPosition ) { --- 148,152 ---- return weightRelatedParameterValuesForDrivingPositions; } ! protected int getTickerIndexForDrivingPosition( int[] parameterValues , int parameterPosition ) { *************** *** 166,170 **** parameterPosition < this.numberOfDrivingPositions ; parameterPosition++ ) tickerRelatedParameterValuesForDrivingPositions[ parameterPosition ] = ! this.getTickerIndexForDrivingPositions( optimizableParameters , parameterPosition ); return tickerRelatedParameterValuesForDrivingPositions; --- 166,170 ---- parameterPosition < this.numberOfDrivingPositions ; parameterPosition++ ) tickerRelatedParameterValuesForDrivingPositions[ parameterPosition ] = ! this.getTickerIndexForDrivingPosition( optimizableParameters , parameterPosition ); return tickerRelatedParameterValuesForDrivingPositions; |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:02:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31395/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager Modified Files: WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs Log Message: Class name has been changed from WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility to WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility Index: WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager/WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs 20 Sep 2006 21:50:08 -0000 1.1 --- WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs 8 Oct 2006 16:02:01 -0000 1.2 *************** *** 2,6 **** QuantProject - Quantitative Finance Library ! WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs Copyright (C) 2006 Glauco Siliprandi --- 2,6 ---- QuantProject - Quantitative Finance Library ! WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs Copyright (C) 2006 Glauco Siliprandi *************** *** 31,35 **** /// to normalize the portfolio's tickers volatility /// </summary> ! public class WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility : WFLagFixedPortfolioBruteForceOptimizableParametersManager { --- 31,35 ---- /// to normalize the portfolio's tickers volatility /// </summary> ! public class WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility : WFLagFixedPortfolioBruteForceOptimizableParametersManager { *************** *** 40,44 **** private double standardDeviationForLongPosition; ! public WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( DataTable eligibleTickersForDrivingPositions , string portfolioLongTicker , --- 40,44 ---- private double standardDeviationForLongPosition; ! public WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility( DataTable eligibleTickersForDrivingPositions , string portfolioLongTicker , |
|
From: Glauco S. <gla...@us...> - 2006-10-08 16:00:30
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30861/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagGenomeManager.cs Log Message: eligibleTickersForDrivingWeightedPositions and eligibleTickersForPortfolioWeightedPositions where private members, they are protected now Index: WFLagGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomeManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WFLagGenomeManager.cs 20 Sep 2006 20:58:30 -0000 1.5 --- WFLagGenomeManager.cs 8 Oct 2006 16:00:19 -0000 1.6 *************** *** 42,47 **** private int numberOfTickersInPortfolio; private int numberOfEligibleTickersForDrivingWeightedPositions; ! private DataTable eligibleTickersForDrivingWeightedPositions; ! private DataTable eligibleTickersForPortfolioWeightedPositions; private DateTime firstOptimizationDate; private DateTime lastOptimizationDate; --- 42,47 ---- private int numberOfTickersInPortfolio; private int numberOfEligibleTickersForDrivingWeightedPositions; ! protected DataTable eligibleTickersForDrivingWeightedPositions; ! protected DataTable eligibleTickersForPortfolioWeightedPositions; private DateTime firstOptimizationDate; private DateTime lastOptimizationDate; |
|
From: Glauco S. <gla...@us...> - 2006-10-08 15:59:21
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30428/b5_Presentation Modified Files: b5_Presentation.csproj Log Message: Minor automatic VSNet changes Index: b5_Presentation.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/b5_Presentation.csproj,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** b5_Presentation.csproj 20 Sep 2006 21:49:09 -0000 1.31 --- b5_Presentation.csproj 8 Oct 2006 15:59:18 -0000 1.32 *************** *** 161,165 **** <File RelPath = "Charting\Chart.cs" ! SubType = "Code" BuildAction = "Compile" /> --- 161,165 ---- <File RelPath = "Charting\Chart.cs" ! SubType = "UserControl" BuildAction = "Compile" /> |
|
From: Glauco S. <gla...@us...> - 2006-10-08 15:58:54
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30045/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** b7_Scripts.csproj 20 Sep 2006 21:47:30 -0000 1.65 --- b7_Scripts.csproj 8 Oct 2006 15:58:49 -0000 1.66 *************** *** 710,713 **** --- 710,718 ---- /> <File + RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2006-10-08 15:58:03
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29648/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager Added Files: WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs Log Message: Implements IBruteForceOptimizableParametersManager using weights to normalize not only the portfolio's tickers volatility, but the driving positions volatility too --- NEW FILE: WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs --- /* QuantProject - Quantitative Finance Library WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.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.Statistics; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// Implements IBruteForceOptimizableParametersManager using weights /// to normalize the portfolio's tickers volatility /// </summary> public class WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility : WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility { // private double[] weightsForDrivingPositions; private double[] standardDeviationForDrivingPositions; private float[][] drivingPositionsCloseToCloseReturns; public WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( DataTable eligibleTickersForDrivingPositions , string portfolioLongTicker , string portfolioShortTicker , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int numberOfDrivingPositions ) : base( eligibleTickersForDrivingPositions , portfolioLongTicker , portfolioShortTicker , firstOptimizationDate , lastOptimizationDate , 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 } } |
|
From: Marco M. <mi...@us...> - 2006-10-07 09:46:27
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29317/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Added RecalculateCloseToCloseRatios method, in order to recalculate CTC ratios from adjusted close quotes stored in the database. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Quotes.cs 17 Sep 2006 21:36:09 -0000 1.31 --- Quotes.cs 7 Oct 2006 09:46:22 -0000 1.32 *************** *** 1092,1095 **** --- 1092,1149 ---- // precedingDays ) ); // } + + #region RecalculateCloseToCloseRatios + + private float recalculateCloseToCloseRatios_getAdjCloseJustBeforeCurrentFirstClose() + { + float returnValue = float.MinValue; + DateTime firstCurrentDate = (DateTime)this.Rows[0][Quotes.Date]; + int daysBeforeCurrent = 1; + if(firstCurrentDate > DataAccess.Tables.Quotes.GetFirstQuoteDate(this.Ticker) ) + //there exist other quotes in the database that precede first current quote + { + while(returnValue == float.MinValue) + { + try{ + returnValue = + DataAccess.Tables.Quotes.GetAdjustedClose(this.Ticker, + firstCurrentDate.AddDays( + -daysBeforeCurrent) ); + + } + catch(Exception ex){ex = ex;} + finally{ + daysBeforeCurrent++; + } + } + } + return returnValue; + } + + /// <summary> + /// Recalculate close to close ratios + /// overwriting the value(if present) stored in the + /// database + /// </summary> + /// <returns></returns> + public void RecalculateCloseToCloseRatios() + { + float adjustedCloseJustBeforeTheCurrentFirstClose = + this.recalculateCloseToCloseRatios_getAdjCloseJustBeforeCurrentFirstClose(); + for(int i = 0; i<this.Rows.Count; i++) + { + if(i == 0 && adjustedCloseJustBeforeTheCurrentFirstClose > float.MinValue) + //there exists a valid quote just before the first current close + this.Rows[i][Quotes.AdjustedCloseToCloseRatio] = + (float)this.Rows[i][Quotes.AdjustedClose] / + adjustedCloseJustBeforeTheCurrentFirstClose; + else if(i>0) + this.Rows[i][Quotes.AdjustedCloseToCloseRatio] = + (float)this.Rows[i][Quotes.AdjustedClose] / + (float)this.Rows[i - 1][Quotes.AdjustedClose]; + } + } + #endregion + } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12982/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagBruteForceOptimizableItemManager Added Files: WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs Log Message: Implements IBruteForceOptimizableParametersManager using weights to normalize the portfolio's tickers volatility --- NEW FILE: WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs --- /* QuantProject - Quantitative Finance Library WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.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.Statistics; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// Implements IBruteForceOptimizableParametersManager using weights /// to normalize the portfolio's tickers volatility /// </summary> public class WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility : WFLagFixedPortfolioBruteForceOptimizableParametersManager { private double[] weightsForPortfolioPositions; private double weightForLongPosition; private double weightForShortPosition; private double standardDeviationForShortPosition; private double standardDeviationForLongPosition; public WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility( DataTable eligibleTickersForDrivingPositions , string portfolioLongTicker , string portfolioShortTicker , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int numberOfDrivingPositions ) : base( eligibleTickersForDrivingPositions , portfolioLongTicker , portfolioShortTicker , firstOptimizationDate , lastOptimizationDate , numberOfDrivingPositions ) { this.standardDeviationForLongPosition = double.MinValue; this.standardDeviationForShortPosition = double.MinValue; } protected override WeightedPositions decodePortfolioWeightedPositions( int[] optimizableParameters ) { double[] weightsForPortfolioPositions = this.getWeightsForPortfolioPositions(); string[] tickersForPortfolioPositions = new string[ 2 ] { this.portfolioLongTicker , this.portfolioShortTicker }; WeightedPositions weightedPositions = new WeightedPositions( weightsForPortfolioPositions , tickersForPortfolioPositions ); return weightedPositions; } #region getWeightsForPortfolioPositions private double getStandardDeviation( string ticker ) { float[][] tickersReturns = this.wFLagCandidates.GetTickersReturns( new string[ 1 ] { ticker } ); return BasicFunctions.GetStdDev( tickersReturns[ 0 ] ); } private void setStandardDeviationForShortPosition() { this.standardDeviationForShortPosition = this.getStandardDeviation( this.portfolioShortTicker ); } private double getStandardDeviationForShortPosition() { if ( this.standardDeviationForShortPosition == double.MinValue ) // this.standardDeviationForShortPosition has not been set yet this.setStandardDeviationForShortPosition(); return this.standardDeviationForShortPosition; } private void setStandardDeviationForLongPosition() { this.standardDeviationForLongPosition = this.getStandardDeviation( this.portfolioLongTicker ); } private double getStandardDeviationForLongPosition() { if ( this.standardDeviationForLongPosition == double.MinValue ) // this.standardDeviationForLongPosition has not been set yet this.setStandardDeviationForLongPosition(); return this.standardDeviationForLongPosition; } private void setWeightsForPortfolioPositions() { this.weightForLongPosition = this.getStandardDeviationForShortPosition() / ( this.getStandardDeviationForShortPosition() + this.getStandardDeviationForLongPosition() ); this.weightForShortPosition = -1 + this.weightForLongPosition; this.weightsForPortfolioPositions = new double[ 2 ] { this.weightForLongPosition , this.weightForShortPosition }; } private double[] getWeightsForPortfolioPositions() { if ( this.weightsForPortfolioPositions == null ) this.setWeightsForPortfolioPositions(); return this.weightsForPortfolioPositions; } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2006-09-20 21:49:34
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12596/b3_Data Modified Files: b3_Data.csproj Log Message: Minor automatic VSNet changes Index: b3_Data.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/b3_Data.csproj,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** b3_Data.csproj 17 Sep 2006 23:01:19 -0000 1.42 --- b3_Data.csproj 20 Sep 2006 21:49:30 -0000 1.43 *************** *** 136,140 **** <File RelPath = "ExtendedDataTable.cs" ! SubType = "Code" BuildAction = "Compile" /> --- 136,140 ---- <File RelPath = "ExtendedDataTable.cs" ! SubType = "Component" BuildAction = "Compile" /> |