quantproject-developers Mailing List for QuantProject (Page 64)
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: Marco M. <mi...@us...> - 2008-01-14 23:07:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7110/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO Modified Files: EndOfDayTimerHandlerWeightedPVO.cs GenomeManagerWeightedPVO.cs RunWeightedPVO.cs Log Message: Several changes applied to the classes implementing the Portfolio Value Oscillator strategy (the most important one relates to the use of ReturnsManager) Index: EndOfDayTimerHandlerWeightedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/EndOfDayTimerHandlerWeightedPVO.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerWeightedPVO.cs 29 Aug 2007 09:50:21 -0000 1.2 --- EndOfDayTimerHandlerWeightedPVO.cs 14 Jan 2008 23:07:04 -0000 1.3 *************** *** 65,69 **** bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, --- 65,70 ---- bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double minimumAcceptableGain): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, *************** *** 81,85 **** overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown) { --- 82,87 ---- overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! minimumAcceptableGain) { *************** *** 141,145 **** this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, this.populationSizeForGeneticOptimizer, --- 143,147 ---- this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType,this.benchmark); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, this.populationSizeForGeneticOptimizer, *************** *** 148,152 **** if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.2; GO.Run(false); --- 150,154 ---- if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.5; GO.Run(false); Index: RunWeightedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/RunWeightedPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunWeightedPVO.cs 27 Feb 2007 22:52:40 -0000 1.1 --- RunWeightedPVO.cs 14 Jan 2008 23:07:04 -0000 1.2 *************** *** 61,64 **** --- 61,65 ---- protected int numDaysBetweenEachOptimization; protected double maxAcceptableCloseToCloseDrawdown; + protected double minimumAcceptableGain; protected int numDaysForOscillatingPeriod; protected bool symmetricalThresholds = false; *************** *** 80,83 **** --- 81,85 ---- int numDaysBetweenEachOptimization, PortfolioType inSamplePortfolioType, double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain, double maxRunningHours): base(tickerGroupID, maxNumOfEligibleTickersForOptimization, *************** *** 97,100 **** --- 99,103 ---- this.overboughtMoreThanOversoldForFixedPortfolio = overboughtMoreThanOversoldForFixedPortfolio; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; + this.minimumAcceptableGain = minimumAcceptableGain; this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; *************** *** 119,123 **** this.overboughtMoreThanOversoldForFixedPortfolio, this.numDaysBetweenEachOptimization, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); } --- 122,127 ---- this.overboughtMoreThanOversoldForFixedPortfolio, this.numDaysBetweenEachOptimization, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, ! this.minimumAcceptableGain); } Index: GenomeManagerWeightedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/GenomeManagerWeightedPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerWeightedPVO.cs 27 Feb 2007 22:52:40 -0000 1.1 --- GenomeManagerWeightedPVO.cs 14 Jan 2008 23:07:04 -0000 1.2 *************** *** 40,61 **** /// </summary> [Serializable] ! public class GenomeManagerWeightedPVO : GenomeManagerForEfficientPortfolio { - protected int minLevelForOversoldThreshold; - protected int maxLevelForOversoldThreshold; - protected int minLevelForOverboughtThreshold; - protected int maxLevelForOverboughtThreshold; - protected int divisorForThresholdComputation; - protected bool symmetricalThresholds = false; - protected bool overboughtMoreThanOversoldForFixedPortfolio = false; - protected int numOfGenesDedicatedToThresholds; - protected double currentOversoldThreshold = 0.0; - protected double currentOverboughtThreshold = 0.0; - protected int numDaysForOscillatingPeriod; protected int[] genePositionsPointingToTickers; ! ! protected double[] portfolioValues;//the values for each unit, invested ! //at the beginning of the optimization period, ! //throughout the period itself protected bool genePositionPointsToATicker(int genePosition) --- 40,80 ---- /// </summary> [Serializable] ! public class GenomeManagerWeightedPVO : GenomeManagerPVO { protected int[] genePositionsPointingToTickers; ! ! public GenomeManagerWeightedPVO(DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! int numDaysForOscillatingPeriod, ! int minLevelForOversoldThreshold, ! int maxLevelForOversoldThreshold, ! int minLevelForOverboughtThreshold, ! int maxLevelForOverboughtThreshold, ! int divisorForThresholdComputation, ! bool symmetricalThresholds, ! bool overboughtMoreThanOversoldForFixedPortfolio, ! PortfolioType inSamplePortfolioType, ! string benchmark) ! : ! base(setOfInitialTickers, ! firstQuoteDate, lastQuoteDate, ! numberOfTickersInPortfolio, ! numDaysForOscillatingPeriod, ! minLevelForOversoldThreshold, ! maxLevelForOversoldThreshold, ! minLevelForOverboughtThreshold, ! maxLevelForOverboughtThreshold, ! divisorForThresholdComputation, ! symmetricalThresholds, ! overboughtMoreThanOversoldForFixedPortfolio, ! inSamplePortfolioType, ! benchmark) ! ! ! { ! this.genePositionsPointingToTickers = new int[(this.GenomeSize - this.numOfGenesDedicatedToThresholds)/2]; ! } protected bool genePositionPointsToATicker(int genePosition) *************** *** 93,153 **** return this.genePositionsPointingToTickers; } ! ! private void genomeManagerWeightedPVO_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) ) || ! (this.overboughtMoreThanOversoldForFixedPortfolio && ! (this.minLevelForOverboughtThreshold > Convert.ToInt32(Convert.ToDouble(this.minLevelForOversoldThreshold)* Convert.ToDouble(this.divisorForThresholdComputation) / ! (Convert.ToDouble(this.divisorForThresholdComputation) - Convert.ToDouble(this.minLevelForOversoldThreshold) ) ) || ! this.maxLevelForOverboughtThreshold < Convert.ToInt32(Convert.ToDouble(this.maxLevelForOversoldThreshold) * Convert.ToDouble(this.divisorForThresholdComputation) / ! (Convert.ToDouble(this.divisorForThresholdComputation) - Convert.ToDouble(this.maxLevelForOversoldThreshold) ) ) ) ) ) ! ! throw new Exception("Bad parameters for thresholds computation!"); ! } ! ! public GenomeManagerWeightedPVO(DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! int numDaysForOscillatingPeriod, ! int minLevelForOversoldThreshold, ! int maxLevelForOversoldThreshold, ! int minLevelForOverboughtThreshold, ! int maxLevelForOverboughtThreshold, ! int divisorForThresholdComputation, ! bool symmetricalThresholds, ! bool overboughtMoreThanOversoldForFixedPortfolio, ! PortfolioType inSamplePortfolioType) ! : ! base(setOfInitialTickers, ! firstQuoteDate, ! lastQuoteDate, ! 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; ! this.overboughtMoreThanOversoldForFixedPortfolio = overboughtMoreThanOversoldForFixedPortfolio; ! if(this.symmetricalThresholds)//value for thresholds must be unique ! numOfGenesDedicatedToThresholds = 1; ! else ! numOfGenesDedicatedToThresholds = 2; ! this.genePositionsPointingToTickers = new int[(this.GenomeSize - this.numOfGenesDedicatedToThresholds)/2]; ! this.genomeManagerWeightedPVO_checkParametersForThresholdsComputation(); ! this.retrieveData(); ! } public override int GenomeSize --- 112,116 ---- return this.genePositionsPointingToTickers; } ! public override int GenomeSize *************** *** 233,337 **** #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); - for(int i = 0; i<returnValue.Length; i++) - returnValue[i] = returnValue[i] - 1.0f; - - this.numberOfExaminedReturns = returnValue.Length; - - return returnValue; - } - //starting from this.numDaysForOscillatingPeriod day, - //it computes for each day ahead the value of the - //portfolio opened numDaysForOscillatingPeriod days ago - private double[] getPortfolioMovingValues() - { - double[] returnValue = new double[this.portfolioRatesOfReturn.Length]; - double[] valuesInOscillatingPeriod = new double[this.numDaysForOscillatingPeriod]; - valuesInOscillatingPeriod[0] = 1.0; - for(int i = this.numDaysForOscillatingPeriod; i<returnValue.Length; i++) - { - for(int j = 1; - j < this.numDaysForOscillatingPeriod; j++) - valuesInOscillatingPeriod[j] = - valuesInOscillatingPeriod[j - 1] + - valuesInOscillatingPeriod[j - 1] * - this.portfolioRatesOfReturn[i-this.numDaysForOscillatingPeriod+j]; - returnValue[i-1] = valuesInOscillatingPeriod[this.numDaysForOscillatingPeriod -1]; - } - return returnValue; - } - - private void getFitnessValue_setCurrentThresholds(Genome genome) - { - 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); - } - - private int getFitnessValue_getDaysOnTheMarket(double[] equityLine) - { - int returnValue = 0; - foreach(double equityReturn in equityLine) - if(equityReturn != 0.0) - //the applied strategy gets positions on the market - returnValue++; - - return returnValue; - } - - //fitness is a sharpe-ratio based indicator for the equity line resulting - //from applying the strategy - public override double GetFitnessValue(Genome genome) - { - double returnValue = -1.0; - this.portfolioRatesOfReturn = this.getPortfolioRatesOfReturn(genome.Genes()); - this.portfolioValues = this.getPortfolioMovingValues(); - this.getFitnessValue_setCurrentThresholds(genome); - double[] equityLine = this.getFitnessValue_getEquityLineRates(); - double fitness = Double.NaN; - if(this.getFitnessValue_getDaysOnTheMarket(equityLine) > - equityLine.Length / 2) - //if the genome represents a portfolio that stays on the market - //at least half of the theoretical days - fitness = AdvancedFunctions.GetSharpeRatio(equityLine); - if(!double.IsNaN(fitness) && !double.IsInfinity(fitness)) - returnValue = fitness; - - return returnValue; - } - - private double[] getFitnessValue_getEquityLineRates() - { - double[] returnValue = new double[this.PortfolioRatesOfReturn.Length]; - double coefficient = 0.0; - for(int i = 0; i<this.PortfolioRatesOfReturn.Length - 1;i++) - { - if(this.portfolioValues[i] >= - 1.0 + this.currentOverboughtThreshold) - //portfolio is overbought - coefficient = -1.0; - else if(this.portfolioValues[i] <= - 1.0 - this.currentOversoldThreshold && - this.portfolioValues[i] > 0.0) - //portfolio is oversold - coefficient = 1.0; - - returnValue[i + 1] = - coefficient * this.PortfolioRatesOfReturn[i + 1]; - } - return returnValue; - } - protected override double getTickerWeight(int[] genes, int tickerPositionInGenes) { --- 196,199 ---- *************** *** 358,378 **** } - protected override double[] getPortfolioRatesOfReturn(int[] genes) - { - double[] returnValue = new double[this.numberOfExaminedReturns]; - for(int i = 0; i<returnValue.Length; i++) - { - for(int genePosition=this.numOfGenesDedicatedToThresholds; - genePosition<genes.Length; - genePosition++)//the first numOfGenesDedicatedToThresholds are for thresholds - { - if( this.genePositionPointsToATicker(genePosition) ) - returnValue[i] += - this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray(genes,genePosition,i); - } - } - return returnValue; - } - public override object Decode(Genome genome) { --- 220,223 ---- |
|
From: Marco M. <mi...@us...> - 2008-01-14 23:07:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7110/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO Modified Files: EndOfDayTimerHandlerWeightedBalancedPVO.cs GenomeManagerWeightedBalancedPVO.cs RunWeightedBalancedPVO.cs Log Message: Several changes applied to the classes implementing the Portfolio Value Oscillator strategy (the most important one relates to the use of ReturnsManager) Index: EndOfDayTimerHandlerWeightedBalancedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO/EndOfDayTimerHandlerWeightedBalancedPVO.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandlerWeightedBalancedPVO.cs 29 Aug 2007 09:50:21 -0000 1.3 --- EndOfDayTimerHandlerWeightedBalancedPVO.cs 14 Jan 2008 23:07:05 -0000 1.4 *************** *** 68,72 **** bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, --- 68,73 ---- bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double minimumAcceptableGain): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, *************** *** 84,88 **** overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown) { --- 85,90 ---- overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! minimumAcceptableGain) { *************** *** 144,148 **** this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, this.populationSizeForGeneticOptimizer, --- 146,150 ---- this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType, this.benchmark); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, this.populationSizeForGeneticOptimizer, *************** *** 151,155 **** if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.1; GO.Run(false); --- 153,157 ---- if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.2; GO.Run(false); Index: RunWeightedBalancedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO/RunWeightedBalancedPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunWeightedBalancedPVO.cs 27 Feb 2007 22:52:40 -0000 1.1 --- RunWeightedBalancedPVO.cs 14 Jan 2008 23:07:05 -0000 1.2 *************** *** 61,64 **** --- 61,65 ---- protected int numDaysBetweenEachOptimization; protected double maxAcceptableCloseToCloseDrawdown; + protected double minimumAcceptableGain; protected int numDaysForOscillatingPeriod; protected bool symmetricalThresholds = false; *************** *** 80,83 **** --- 81,85 ---- int numDaysBetweenEachOptimization, PortfolioType inSamplePortfolioType, double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain, double maxRunningHours): base(tickerGroupID, maxNumOfEligibleTickersForOptimization, *************** *** 97,100 **** --- 99,103 ---- this.overboughtMoreThanOversoldForFixedPortfolio = overboughtMoreThanOversoldForFixedPortfolio; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; + this.minimumAcceptableGain = minimumAcceptableGain; this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; *************** *** 119,123 **** this.overboughtMoreThanOversoldForFixedPortfolio, this.numDaysBetweenEachOptimization, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); } --- 122,127 ---- this.overboughtMoreThanOversoldForFixedPortfolio, this.numDaysBetweenEachOptimization, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, ! this.minimumAcceptableGain); } Index: GenomeManagerWeightedBalancedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO/GenomeManagerWeightedBalancedPVO.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenomeManagerWeightedBalancedPVO.cs 9 Apr 2007 18:00:52 -0000 1.2 --- GenomeManagerWeightedBalancedPVO.cs 14 Jan 2008 23:07:05 -0000 1.3 *************** *** 83,87 **** bool symmetricalThresholds, bool overboughtMoreThanOversoldForFixedPortfolio, ! PortfolioType inSamplePortfolioType) : base(setOfInitialTickers, --- 83,88 ---- bool symmetricalThresholds, bool overboughtMoreThanOversoldForFixedPortfolio, ! PortfolioType inSamplePortfolioType, ! string benchmark) : base(setOfInitialTickers, *************** *** 97,101 **** symmetricalThresholds, overboughtMoreThanOversoldForFixedPortfolio, ! inSamplePortfolioType) { --- 98,103 ---- symmetricalThresholds, overboughtMoreThanOversoldForFixedPortfolio, ! inSamplePortfolioType, ! benchmark) { |
|
From: Marco M. <mi...@us...> - 2008-01-14 23:02:35
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6067/b4_Business/a2_Strategies/TickersRelationships Added Files: CloseToCloseCorrelationProvider.cs CorrelationProvider.cs OpenToCloseCorrelationProvider.cs TickersPearsonCorrelation.cs Log Message: Added classes for providing correlation indexes of various types --- NEW FILE: CloseToCloseCorrelationProvider.cs --- /* QuantProject - Quantitative Finance Library CloseToCloseCorrelationProvider.cs Copyright (C) 2007 Marco Milletti 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 System.Collections; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Class that provides close to close correlation's indexes two by two within a /// given set of tickers /// </summary> [Serializable] public class CloseToCloseCorrelationProvider : CorrelationProvider { private int closeToCloseIntervalLength; /// <summary> /// Creates the provider for the close to close correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="closeToCloseIntervalLength">Length of the close To Close /// interval return</param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> /// <param name="benchmark">The benchmark used for computation /// of returns</param> public CloseToCloseCorrelationProvider(string[] tickersToAnalyze, DateTime startDate, DateTime endDate, int closeToCloseIntervalLength, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(tickersToAnalyze, startDate, endDate, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue, benchmark) { this.closeToCloseIntervalLength = closeToCloseIntervalLength; } /// <summary> /// Creates the provider for the close to close correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="returnsManager"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> public CloseToCloseCorrelationProvider( string[] tickersToAnalyze, ReturnsManager returnsManager, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue ): base(tickersToAnalyze, returnsManager, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue) { } protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { this.firstEndOfDayDateTime = new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketClose); this.lastEndOfDayDateTime = new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketClose); } protected override void setReturnsManager() { CloseToCloseIntervals closeToCloseIntervals = new CloseToCloseIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark, this.closeToCloseIntervalLength); this.returnsManager = new ReturnsManager(closeToCloseIntervals, new HistoricalAdjustedQuoteProvider() ); } } // end of class } --- NEW FILE: TickersPearsonCorrelation.cs --- /* QuantProject - Quantitative Finance Library TickersPearsonCorrelation.cs Copyright (C) 2007 Marco Milletti 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.Timing; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Struct used for the storage of correlation info /// </summary> [Serializable] public struct TickersPearsonCorrelation : IComparable { private string firstTicker; public string FirstTicker { get { return this.firstTicker; } } private string secondTicker; public string SecondTicker { get { return this.secondTicker; } } private double correlationValue; public double CorrelationValue { get { return this.correlationValue; } } public TickersPearsonCorrelation( string firstTicker, string secondTicker, double pearsonCorrelationValue) { this.firstTicker = firstTicker; this.secondTicker = secondTicker; this.correlationValue = pearsonCorrelationValue; } public int CompareTo(object correlationToBeCompared) { int returnValue = 1; TickersPearsonCorrelation toBeCompared = (TickersPearsonCorrelation)correlationToBeCompared; if( this.correlationValue < toBeCompared.correlationValue) returnValue = - 1; else if (this.correlationValue == toBeCompared.correlationValue) returnValue = 0; // else if (this.correlationValue > toBeCompared.correlationValue) // returnValue = 1; return returnValue; } } } --- NEW FILE: OpenToCloseCorrelationProvider.cs --- /* QuantProject - Quantitative Finance Library OpenToCloseCorrelationProvider.cs Copyright (C) 2008 Marco Milletti 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 System.Collections; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Class that provides open to close correlation's indexes two by two within a /// given set of tickers /// </summary> [Serializable] public class OpenToCloseCorrelationProvider : CorrelationProvider { /// <summary> /// Creates the provider for the open to close correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> /// <param name="benchmark">The benchmark used for computation /// of returns</param> public OpenToCloseCorrelationProvider(string[] tickersToAnalyze, DateTime startDate, DateTime endDate, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(tickersToAnalyze, startDate, endDate, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue, benchmark) { } /// <summary> /// Creates the provider for the open to close correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="returnsManager"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> public OpenToCloseCorrelationProvider( string[] tickersToAnalyze, ReturnsManager returnsManager, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue ) : base(tickersToAnalyze, returnsManager, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue) { } protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { this.firstEndOfDayDateTime = new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketOpen); this.lastEndOfDayDateTime = new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketClose); } protected override void setReturnsManager() { DailyOpenToCloseIntervals dailyOpenToCloseIntervals = new DailyOpenToCloseIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark); this.returnsManager = new ReturnsManager(dailyOpenToCloseIntervals, new HistoricalRawQuoteProvider() ); } } // end of class } --- NEW FILE: CorrelationProvider.cs --- /* QuantProject - Quantitative Finance Library CorrelationProvider.cs Copyright (C) 2008 Marco Milletti 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 System.Collections; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Abstract class that provides correlation's indexes two by two within a /// given set of tickers /// </summary> [Serializable] public abstract class CorrelationProvider { protected ReturnsManager returnsManager; protected string[] tickers; protected float minimumAbsoluteReturnValue; protected float maximumAbsoluteReturnValue; protected int numOfCombinationTwoByTwo; protected TickersPearsonCorrelation[] pearsonCorrelations; protected EndOfDayDateTime firstEndOfDayDateTime; protected EndOfDayDateTime lastEndOfDayDateTime; protected string benchmark; /// <summary> /// Creates the correlation provider /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> /// <param name="benchmark">The benchmark used for computation /// of returns</param> public CorrelationProvider(string[] tickersToAnalyze, DateTime startDate, DateTime endDate, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) { this.tickers = tickersToAnalyze; this.setEndOfDayDatesTime(startDate, endDate); this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; this.benchmark = benchmark; this.numOfCombinationTwoByTwo = (int)((Math.Pow(this.tickers.Length, 2) - this.tickers.Length ) / 2); this.setReturnsManager(); } /// <summary> /// Creates the correlation provider /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="returnsManager"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> public CorrelationProvider( string[] tickersToAnalyze, ReturnsManager returnsManager, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue ) { this.tickers = tickersToAnalyze; this.returnsManager = returnsManager; this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; this.numOfCombinationTwoByTwo = (int)((Math.Pow(this.tickers.Length, 2) - this.tickers.Length ) / 2); } protected abstract void setEndOfDayDatesTime(DateTime startDate, DateTime endDate); protected abstract void setReturnsManager(); protected float[] getOrderedTickersPearsonCorrelations_setCorrelations_getValue_getFilteredReturnsForFirstTicker( float[] firstTickerReturns, float[] secondTickerReturns) { float[] returnValue; float[] tempReturnValue = new float[firstTickerReturns.Length]; int countSignificantReturns = 0; for(int i = 0; i<firstTickerReturns.Length; i++) if( Math.Abs(firstTickerReturns[i]) >= this.minimumAbsoluteReturnValue && Math.Abs(firstTickerReturns[i]) <= this.maximumAbsoluteReturnValue && Math.Abs(secondTickerReturns[i]) >= this.minimumAbsoluteReturnValue && Math.Abs(secondTickerReturns[i]) <= this.maximumAbsoluteReturnValue ) { countSignificantReturns++; tempReturnValue[ countSignificantReturns - 1 ] = firstTickerReturns[ i ]; } returnValue = new float[countSignificantReturns]; Array.Copy(tempReturnValue, 0, returnValue, 0, countSignificantReturns); return returnValue; } protected double getOrderedTickersPearsonCorrelations_setCorrelations_getValue( int indexOfFirstTicker, int indexOfSecondTicker) { double returnValue; float[] firstTickerSignificantReturns = this.getOrderedTickersPearsonCorrelations_setCorrelations_getValue_getFilteredReturnsForFirstTicker( this.returnsManager.GetReturns(this.tickers[indexOfFirstTicker]), this.returnsManager.GetReturns(this.tickers[indexOfSecondTicker]) ); float[] secondTickerSignificantReturns = this.getOrderedTickersPearsonCorrelations_setCorrelations_getValue_getFilteredReturnsForFirstTicker( this.returnsManager.GetReturns(this.tickers[indexOfSecondTicker]), this.returnsManager.GetReturns(this.tickers[indexOfFirstTicker]) ); returnValue = BasicFunctions.PearsonCorrelationCoefficient( firstTickerSignificantReturns, secondTickerSignificantReturns ); if ( Double.IsNaN(returnValue) || Double.IsInfinity(returnValue) ) throw new Exception( "correlation can't be computed for these two tickers: "+ this.tickers[indexOfFirstTicker] + " and " + this.tickers[indexOfSecondTicker] + "!"); return returnValue; } protected void getOrderedTickersPearsonCorrelations_setCorrelations() { this.pearsonCorrelations = new TickersPearsonCorrelation[ this.numOfCombinationTwoByTwo ]; int index = 0; for (int i = 0; i < this.tickers.Length; i++) for (int j = i + 1; j < this.tickers.Length; j++) { this.pearsonCorrelations[index] = new TickersPearsonCorrelation( this.tickers[i], this.tickers[j], this.getOrderedTickersPearsonCorrelations_setCorrelations_getValue( i , j) ); index++; } Array.Sort(this.pearsonCorrelations); } public TickersPearsonCorrelation[] GetOrderedTickersPearsonCorrelations() { if( this.pearsonCorrelations == null ) this.getOrderedTickersPearsonCorrelations_setCorrelations(); return this.pearsonCorrelations; } public double GetPearsonCorrelation(string firstTicker, string secondTicker) { double returnValue = -2.0; if( this.pearsonCorrelations == null ) this.getOrderedTickersPearsonCorrelations_setCorrelations(); for(int i = 0; i<this.pearsonCorrelations.Length; i++) { if( (this.pearsonCorrelations[i].FirstTicker == firstTicker && this.pearsonCorrelations[i].SecondTicker == secondTicker) || (this.pearsonCorrelations[i].FirstTicker == secondTicker && this.pearsonCorrelations[i].SecondTicker == firstTicker) ) returnValue = this.pearsonCorrelations[i].CorrelationValue; } return returnValue; } } // end of class } |
|
From: Marco M. <mi...@us...> - 2008-01-14 22:58:19
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4256/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Added Files: GenomeManagerPVO_OTC.cs Log Message: Added Portfolio Value Oscillator strategy using Open To Close returns. Fitness is based on correlation; 2 tickers portfolio is opened at market open and closed at market close. --- NEW FILE: GenomeManagerPVO_OTC.cs --- /* QuantProject - Quantitative Finance Library GenomeManagerPVO_OTC.cs Copyright (C) 2008 Marco Milletti 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 System.Collections; using QuantProject.ADT; using QuantProject.ADT.Statistics; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Data; using QuantProject.Data.DataTables; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// Implements what needed to use the Genetic Optimizer /// for finding the portfolio that best suites /// the Portfolio Value Oscillator strategy, based on /// open to close returns /// </summary> [Serializable] public class GenomeManagerPVO_OTC : GenomeManagerPVO { public GenomeManagerPVO_OTC(DataTable setOfInitialTickers, DateTime firstQuoteDate, DateTime lastQuoteDate, int numberOfTickersInPortfolio, int minLevelForOversoldThreshold, int maxLevelForOversoldThreshold, int minLevelForOverboughtThreshold, int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, bool symmetricalThresholds, bool overboughtMoreThanOversoldForFixedPortfolio, PortfolioType inSamplePortfolioType, string benchmark) : base(setOfInitialTickers, firstQuoteDate, lastQuoteDate, numberOfTickersInPortfolio, 1, minLevelForOversoldThreshold, maxLevelForOversoldThreshold, minLevelForOverboughtThreshold, maxLevelForOverboughtThreshold, divisorForThresholdComputation, symmetricalThresholds, overboughtMoreThanOversoldForFixedPortfolio, inSamplePortfolioType, benchmark) { } protected override void setReturnsManager(DateTime firstQuoteDate, DateTime lastQuoteDate) { EndOfDayDateTime firstEndOfDayDateTime = new EndOfDayDateTime(firstQuoteDate, EndOfDaySpecificTime.MarketOpen); EndOfDayDateTime lastEndOfDayDateTime = new EndOfDayDateTime(lastQuoteDate, EndOfDaySpecificTime.MarketClose); this.returnsManager = new ReturnsManager( new DailyOpenToCloseIntervals( firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark), new HistoricalRawQuoteProvider() ); } //fitness is a sharpe-ratio based indicator for the equity line resulting //from applying the strategy public override double GetFitnessValue(Genome genome) { //NEW implementation: fitness is just the pearson correlation //applied to two tickers. This kind of fitness is only valid //for tests with 2-tickers portfolios double returnValue = -2.0; if(this.correlationProvider == null) this.correlationProvider = new OpenToCloseCorrelationProvider( QuantProject.ADT.ExtendedDataTable.GetArrayOfStringFromColumn(this.setOfTickers, 0), this.returnsManager, 0.0001f, 0.5f); string firstTicker = this.getFitnessValue_getFirstTickerFromGenome(genome); string secondTicker = this.getFitnessValue_getSecondTickerFromGenome(genome); if( ( firstTicker.StartsWith("-") && !secondTicker.StartsWith("-") ) || ( secondTicker.StartsWith("-") && !firstTicker.StartsWith("-") ) ) //tickers have to be opposite in sign { double correlationIndex = correlationProvider.GetPearsonCorrelation( SignedTicker.GetTicker(firstTicker), SignedTicker.GetTicker(secondTicker) ); if(correlationIndex < 0.96) // if correlation index is not too high to be // probably originated by the same instrument returnValue = correlationIndex; } return returnValue; } } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4256/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO Added Files: EndOfDayTimerHandlerBiasedPVO_OTC.cs RunBiasedPVO_OTC.cs Log Message: Added Portfolio Value Oscillator strategy using Open To Close returns. Fitness is based on correlation; 2 tickers portfolio is opened at market open and closed at market close. --- NEW FILE: EndOfDayTimerHandlerBiasedPVO_OTC.cs --- /* QuantProject - Quantitative Finance Library EndOfDayTimerHandlerBiasedPVO_OTC.cs Copyright (C) 2008 Marco Milletti 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 System.Collections; using QuantProject.ADT; using QuantProject.ADT.Statistics; using QuantProject.ADT.FileManaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Data; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Data.DataTables; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.WeightedPVO.WeightedBalancedPVO; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO { /// <summary> /// Implements MarketOpenEventHandler and MarketCloseEventHandler /// These handlers contain the core strategy for the Biased Portfolio Value /// Oscillator, using Open To Close returns /// </summary> [Serializable] public class EndOfDayTimerHandlerBiasedPVO_OTC : EndOfDayTimerHandlerBiasedPVO { public EndOfDayTimerHandlerBiasedPVO_OTC(string tickerGroupID, int numberOfEligibleTickers, double minPriceForTickersToBeChosen, double maxPriceForTickersToBeChosen, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, string pathOfFileContainingGenomes, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, int numOfDifferentGenomesToEvaluateOutOfSample, bool resetThresholdsBeforeCheckingOutOfSample, int numDaysForThresholdsReComputation, double numOfStdDevForThresholdsComputation, double maxCoefficientForDegreeComputationOfCrossingThreshold, bool buyOnlyPositionsThatAreMovingTogether, bool doNotOpenReversedPositionsThatHaveJustBeenClosed, int numDaysOfStayingOnTheMarket, int minLevelForOversoldThreshold, int maxLevelForOversoldThreshold, int minLevelForOverboughtThreshold, int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, bool symmetricalThresholds, bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, double minimumAcceptableGain): base(tickerGroupID, numberOfEligibleTickers, minPriceForTickersToBeChosen, maxPriceForTickersToBeChosen, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, account, pathOfFileContainingGenomes, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, numOfDifferentGenomesToEvaluateOutOfSample, resetThresholdsBeforeCheckingOutOfSample, numDaysForThresholdsReComputation, numOfStdDevForThresholdsComputation, maxCoefficientForDegreeComputationOfCrossingThreshold, buyOnlyPositionsThatAreMovingTogether, doNotOpenReversedPositionsThatHaveJustBeenClosed, 1, numDaysOfStayingOnTheMarket, minLevelForOversoldThreshold, maxLevelForOversoldThreshold, minLevelForOverboughtThreshold, maxLevelForOverboughtThreshold, divisorForThresholdComputation, symmetricalThresholds, overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, portfolioType, maxAcceptableCloseToCloseDrawdown, minimumAcceptableGain) { } #region MarketOpen public override void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( this.account.Portfolio.Count == 0 && this.weightedPositionsToEvaluateOutOfSample[0] != null ) //portfolio is empty and optimization has been already launched this.openPositions( (IndexBasedEndOfDayTimer)sender ); } protected override void openPositions_chooseGenome_resetThresholds(DateTime today) { for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) { this.currentOversoldThreshold[i] = (double)this.maxLevelForOversoldThreshold/ (double)this.divisorForThresholdComputation; this.currentOverboughtThreshold[i] = (double)this.maxLevelForOverboughtThreshold/ (double)this.divisorForThresholdComputation; } // UPDATE WITH DailyOpenToCloseIntervals // ReturnsManager returnsManager = new ReturnsManager( // new CloseToCloseIntervals(new EndOfDayDateTime(today.AddDays(-this.numDaysForThresholdsReComputation), EndOfDaySpecificTime.MarketClose), // new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketClose), // this.benchmark, // this.numDaysForOscillatingPeriod), // new HistoricalAdjustedQuoteProvider() ); // //double returnsAverage; // double returnsStdDev; // for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) // { //// returnsAverage = BasicFunctions.GetSimpleAverage( //// this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); // returnsStdDev = BasicFunctions.GetStdDev( // this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); // this.currentOversoldThreshold[i] = -this.numOfStdDevForThresholdsComputation * returnsStdDev; // this.currentOverboughtThreshold[i] = this.numOfStdDevForThresholdsComputation * returnsStdDev; // } } //NEW IMPLEMENTATION of chooseBestGenome, now named chooseGenome //sets currentGenomeIndex with the first genome's index that crosses an overbought/oversold threshold with the //"acceptable" degree and sets currentWeightedPositionsGainOrLoss accordingly protected override void openPositions_chooseGenome(IndexBasedEndOfDayTimer timer) { DateTime today = timer.GetCurrentTime().DateTime; DateTime previousTradingDay = timer.GetPreviousDateTime(1); ReturnsManager returnsManager = new ReturnsManager( new CloseToOpenIntervals(new EndOfDayDateTime(previousTradingDay, EndOfDaySpecificTime.MarketClose), new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketOpen), this.benchmark), new HistoricalAdjustedQuoteProvider() ); if(this.resetThresholdsBeforeCheckingOutOfSample) this.openPositions_chooseGenome_resetThresholds(today); this.currentWeightedPositionsGainOrLoss = double.MinValue; double currentWeightedPositionsGainOrLoss_temp = double.MinValue; for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) { currentWeightedPositionsGainOrLoss_temp = this.getCurrentWeightedPositionsGainOrLoss( timer, returnsManager, i); if( currentWeightedPositionsGainOrLoss_temp != double.MinValue && ( this.buyOnlyPositionsThatAreMovingTogether == false || ( this.buyOnlyPositionsThatAreMovingTogether == true && this.areAllTickersMovingTogetherUpOrDown(timer, returnsManager, i) == true ) ) ) //currentWeightedPositionsGainOrLoss_temp has been properly computed and //only positions that are moving together can be bought { if( (currentWeightedPositionsGainOrLoss_temp >= this.currentOverboughtThreshold[i] && currentWeightedPositionsGainOrLoss_temp <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * this.currentOverboughtThreshold[i] ) || (currentWeightedPositionsGainOrLoss_temp <= - this.currentOversoldThreshold[i] && Math.Abs(currentWeightedPositionsGainOrLoss_temp) <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * this.currentOversoldThreshold[i] ) ) // if the current genome matches the requested criteria { this.currentGenomeIndex = i; this.currentWeightedPositionsGainOrLoss = currentWeightedPositionsGainOrLoss_temp; i = this.numOfDifferentGenomesToEvaluateOutOfSample; //exit from for } } } } #endregion public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) { this.lastWeightedPositionsClosed = AccountManager.GetWeightedPositions(this.account); AccountManager.ClosePositions(this.account); } } #region OneHourAfterMarketCloseEventHandler protected override void setTickers(DateTime currentDate, bool setGenomeCounter) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); this.iGenomeManager = new GenomeManagerPVO_OTC(setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, this.numberOfTickersToBeChosen, this.minLevelForOversoldThreshold, this.maxLevelForOversoldThreshold, this.minLevelForOverboughtThreshold, this.maxLevelForOverboughtThreshold, this.divisorForThresholdComputation, this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, this.portfolioType, this.benchmark); GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, this.populationSizeForGeneticOptimizer, this.generationNumberForGeneticOptimizer, this.seedForRandomGenerator); // if(setGenomeCounter) // this.genomeCounter = new GenomeCounter(GO); GO.MutationRate = 0.1; GO.CrossoverRate = 0.85; GO.Run(false); this.setTickers_updateTickersWeightsAndThresholdsAndAddGenomesForLog(GO, setOfTickersToBeOptimized.Rows.Count); } #endregion } } --- NEW FILE: RunBiasedPVO_OTC.cs --- /* QuantProject - Quantitative Finance Library RunBiasedPVO_OTC.cs Copyright (C) 2008 Marco Milletti 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 System.IO; using QuantProject.ADT; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Testing; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.ADT.FileManaging; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO { /// <summary> /// Script that implements the PVO strategy using OTC returns, /// with this difference: /// when it is time to open new positions, /// the first genome (from a given set of genomes with a good fitness) that /// crosses a threshold is chosen /// </summary> [Serializable] public class RunBiasedPVO_OTC : RunBiasedPVO { public RunBiasedPVO_OTC(string tickerGroupID, int maxNumOfEligibleTickersForOptimization, double minPriceForTickersToBeChosen, double maxPriceForTickersToBeChosen, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, DateTime startDate, DateTime endDate, int numOfDifferentGenomesToEvaluateOutOfSample, bool resetThresholdsBeforeCheckingOutOfSample, int numDaysForThresholdsReComputation, double numOfStdDevForThresholdsComputation, double maxCoefficientForDegreeComputationOfCrossingThreshold, bool buyOnlyPositionsThatAreMovingTogether, bool doNotOpenReversedPositionsThatHaveJustBeenClosed, int numDaysOfStayingOnTheMarket, int minLevelForOversoldThreshold, int maxLevelForOversoldThreshold, int minLevelForOverboughtThreshold, int maxLevelForOverboughtThreshold, int divisorForThresholdComputation, bool symmetricalThresholds, bool overboughtMoreThanOversoldForFixedPortfolio, int numDaysBetweenEachOptimization, PortfolioType inSamplePortfolioType, double maxAcceptableCloseToCloseDrawdown, double minimumAcceptableGain, double maxRunningHours): base(tickerGroupID, maxNumOfEligibleTickersForOptimization, minPriceForTickersToBeChosen, maxPriceForTickersToBeChosen, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, startDate, endDate, numOfDifferentGenomesToEvaluateOutOfSample, resetThresholdsBeforeCheckingOutOfSample, numDaysForThresholdsReComputation, numOfStdDevForThresholdsComputation, maxCoefficientForDegreeComputationOfCrossingThreshold, buyOnlyPositionsThatAreMovingTogether, doNotOpenReversedPositionsThatHaveJustBeenClosed, 1, numDaysOfStayingOnTheMarket, minLevelForOversoldThreshold, maxLevelForOversoldThreshold, minLevelForOverboughtThreshold, maxLevelForOverboughtThreshold, divisorForThresholdComputation, symmetricalThresholds, overboughtMoreThanOversoldForFixedPortfolio, numDaysBetweenEachOptimization, inSamplePortfolioType, maxAcceptableCloseToCloseDrawdown, minimumAcceptableGain, maxRunningHours) { this.ScriptName = "PVO_OTC_Biased_NoWeightsPriceSel"; } // protected override void run_initializeHistoricalQuoteProvider() // { // this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); // } protected override void run_initializeAccount() { this.account = new Account( this.scriptName , this.endOfDayTimer , new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , this.historicalQuoteProvider, new FixedPercentageSlippageManager( this.historicalQuoteProvider, this.endOfDayTimer, 0.05 ) ), new IBCommissionManager() ); } // //no slippage, only commissions // protected override void run_initializeAccount() // { // this.account = new Account( this.scriptName , this.endOfDayTimer , // new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , // this.historicalQuoteProvider ) , // new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , // this.historicalQuoteProvider ), // new IBCommissionManager() ); // } protected override void run_initializeEndOfDayTimerHandler() { this.endOfDayTimerHandler = new EndOfDayTimerHandlerBiasedPVO_OTC(this.tickerGroupID, this.numberOfEligibleTickers, this.minPriceForTickersToBeChosen, this.maxPriceForTickersToBeChosen, this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, this.account, this.PathOfFileContainingGenomes, this.generationNumberForGeneticOptimizer, this.populationSizeForGeneticOptimizer, this.benchmark, this.numOfDifferentGenomesToEvaluateOutOfSample, this.resetThresholdsBeforeCheckingOutOfSample, this.numDaysForThresholdsReComputation, this.numOfStdDevForThresholdsComputation, this.maxCoefficientForDegreeComputationOfCrossingThreshold, this.buyOnlyPositionsThatAreMovingTogether, this.doNotOpenReversedPositionsThatHaveJustBeenClosed, this.numDaysOfStayingOnTheMarket, this.minLevelForOversoldThreshold, this.maxLevelForOversoldThreshold, this.minLevelForOverboughtThreshold, this.maxLevelForOverboughtThreshold, this.divisorForThresholdComputation, this.symmetricalThresholds, this.overboughtMoreThanOversoldForFixedPortfolio, this.numDaysBetweenEachOptimization, this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, this.minimumAcceptableGain); } } } |
|
From: Marco M. <mi...@us...> - 2008-01-14 22:49:28
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv459/TickersRelationships Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships added to the repository |
|
From: Marco M. <mi...@us...> - 2008-01-13 23:30:21
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Commissions In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27421 Modified Files: IBCommission.cs Log Message: Fixed bug in IBCommission: commission fees have been updated. Index: IBCommission.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Commissions/IBCommission.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IBCommission.cs 15 Feb 2005 19:09:01 -0000 1.3 --- IBCommission.cs 13 Jan 2008 23:30:14 -0000 1.4 *************** *** 41,46 **** else { ! returnValue = this.transaction.Quantity * 0.01; ! returnValue = Math.Max( returnValue , 1.0 ); } return returnValue; --- 41,49 ---- else { ! returnValue = this.transaction.Quantity * 0.005; ! //USD 0.005 per share ! returnValue = Math.Min( Math.Max( returnValue , 1.0 ), ! 0.005 * this.transaction.Amount); ! //0.5% of trade value plus exchange, ECN, and specialist fees } return returnValue; |
|
From: Glauco S. <gla...@us...> - 2007-12-30 00:14:47
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17905/b1_ADT/Optimizing/Genetic Modified Files: IGenomeManager.cs Log Message: Minor logical change: Decode is now declared before GetFitnessValue, because GetFitnessValue will probably require a decode, while Decode will not require the genome's fitness value. Index: IGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/IGenomeManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IGenomeManager.cs 3 Jan 2007 23:20:10 -0000 1.5 --- IGenomeManager.cs 30 Dec 2007 00:14:42 -0000 1.6 *************** *** 46,51 **** int GetMinValueForGenes(int genePosition); int GetNewGeneValue(Genome genome, int genePosition); - double GetFitnessValue(Genome genome); object Decode(Genome genome); Genome[] GetChilds(Genome parent1, Genome parent2); void Mutate(Genome genome); --- 46,51 ---- int GetMinValueForGenes(int genePosition); int GetNewGeneValue(Genome genome, int genePosition); object Decode(Genome genome); + double GetFitnessValue(Genome genome); Genome[] GetChilds(Genome parent1, Genome parent2); void Mutate(Genome genome); |
|
From: Marco M. <mi...@us...> - 2007-12-07 19:08:42
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27141/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: AverageNumberOfTransactionsPerDay.cs Log Message: Number of transactions is divided by number of market days, now. Index: AverageNumberOfTransactionsPerDay.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/AverageNumberOfTransactionsPerDay.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AverageNumberOfTransactionsPerDay.cs 10 Sep 2007 22:08:37 -0000 1.2 --- AverageNumberOfTransactionsPerDay.cs 7 Dec 2007 19:08:37 -0000 1.3 *************** *** 25,28 **** --- 25,29 ---- using QuantProject.ADT.Histories; using QuantProject.ADT.Statistics; + using QuantProject.Data.DataTables; using QuantProject.Business.Financial.Accounting.Reporting.Tables; *************** *** 37,49 **** public class AverageNumberOfTransactionsPerDay : DoubleSummaryRow { ! public AverageNumberOfTransactionsPerDay( Summary summary ) : base( 1 ) { ! this.rowDescription = "Average n. of transactions per day"; //int totalNumberOfTransactions = summary.AccountReport.Account.Transactions.Count; //there must be a mistake somewhere: why the previous line is not right? int totalNumberOfTransactions = summary.AccountReport.TransactionTable.DataTable.Rows.Count; ! TimeSpan timeSpanForScript = ! summary.AccountReport.EndDateTime.DateTime.Subtract(summary.AccountReport.StartDateTime); ! this.rowValue = (double)totalNumberOfTransactions / (double)timeSpanForScript.Days; } } --- 38,52 ---- public class AverageNumberOfTransactionsPerDay : DoubleSummaryRow { ! public AverageNumberOfTransactionsPerDay( Summary summary ) : base( 2 ) { ! this.rowDescription = "Average n. of transactions per market day"; //int totalNumberOfTransactions = summary.AccountReport.Account.Transactions.Count; //there must be a mistake somewhere: why the previous line is not right? int totalNumberOfTransactions = summary.AccountReport.TransactionTable.DataTable.Rows.Count; ! History marketDays = Quotes.GetMarketDays( ! summary.AccountReport.Benchmark, ! summary.AccountReport.StartDateTime, ! summary.AccountReport.EndDateTime.DateTime); ! this.rowValue = (double)totalNumberOfTransactions / (double)marketDays.Count; } } |
|
From: Marco M. <mi...@us...> - 2007-11-13 19:10:35
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20965/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Fixed bug in ReturnsManager's private method isReturnsStandardDeviationAlreadySet Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ReturnsManager.cs 4 Nov 2007 18:53:56 -0000 1.8 --- ReturnsManager.cs 13 Nov 2007 19:10:28 -0000 1.9 *************** *** 197,201 **** private bool isReturnsStandardDeviationAlreadySet( string ticker ) { ! return this.tickersReturns.ContainsKey( ticker ); } private void setReturnsStandardDeviation( --- 197,201 ---- private bool isReturnsStandardDeviationAlreadySet( string ticker ) { ! return this.tickersReturnsStandardDeviations.ContainsKey( ticker ); } private void setReturnsStandardDeviation( |
|
From: Glauco S. <gla...@us...> - 2007-11-08 17:48:41
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26026/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: RunSimpleLag.cs Log Message: Code has been added to test some optimal driving positions subsets Index: RunSimpleLag.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/RunSimpleLag.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunSimpleLag.cs 4 Nov 2007 18:51:09 -0000 1.1 --- RunSimpleLag.cs 8 Nov 2007 17:48:36 -0000 1.2 *************** *** 76,83 **** // bad driving positions, despite having two optimal tickers ! double[] drivingWeights = { -0.272826060576681 , 0.304736475342285 , -0.0953627582891244 , 0.32707470579191 }; ! string[] drivingTickers = { "^DJT" , "^OEX" , "BDH" , "EWJ" }; // Description "^DJT;-0.272826060576681--^OEX;0.304736475342285--BDH;-0.0953627582891244--EWJ;0.32707470579191--" string double[] portfolioWeights = { 0.442536856335084 , -0.557463143664916 }; --- 76,100 ---- // bad driving positions, despite having two optimal tickers ! // double[] drivingWeights = { -0.272826060576681 , 0.304736475342285 , -0.0953627582891244 , 0.32707470579191 }; ! // string[] drivingTickers = { "^DJT" , "^OEX" , "BDH" , "EWJ" }; // Description "^DJT;-0.272826060576681--^OEX;0.304736475342285--BDH;-0.0953627582891244--EWJ;0.32707470579191--" string + // two optimal driving positions + double[] drivingWeights = { 0.550560760218599 , -0.172289820708961 }; + string[] drivingTickers = { "^OEX" , "BDH" }; + + // three optimal driving positions + // double[] drivingWeights = { 0.550560760218599 , -0.172289820708961 , -0.16220520521007 }; + // string[] drivingTickers = { "^OEX" , "BDH" , "HHH" }; + + // two optimal driving with similar weights + // double[] drivingWeights = { 0.304736475342285 , -0.0953627582891244 }; + // string[] drivingTickers = { "^OEX" , "BDH" }; + + // single optimal driving + // double[] drivingWeights = { 1 }; + // string[] drivingTickers = { "IIH" }; + + double[] portfolioWeights = { 0.442536856335084 , -0.557463143664916 }; |
|
From: Glauco S. <gla...@us...> - 2007-11-08 17:47:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25461/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs has been added to the project Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Scripts_SD.csproj 4 Nov 2007 18:54:41 -0000 1.9 --- Scripts_SD.csproj 8 Nov 2007 17:47:16 -0000 1.10 *************** *** 64,67 **** --- 64,68 ---- <Compile Include="TickerSelectionTesting\RunEfficientCTOPortfolio.cs" /> <Compile Include="WalkForwardTesting\MSFTwalkForward\TsMSFTwalkForward.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding\IWFLagDecoder.cs" /> |
|
From: Glauco S. <gla...@us...> - 2007-11-08 17:46:55
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25036/b4_Business Modified Files: Business_SD.csproj Log Message: CVS related files have been removed from the project Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Business_SD.csproj 28 Oct 2007 22:28:26 -0000 1.5 --- Business_SD.csproj 8 Nov 2007 17:46:48 -0000 1.6 *************** *** 179,188 **** <Compile Include="a2_Strategies\EquityEvaluation\ExpectancyScore.cs" /> <Compile Include="a2_Strategies\EquityEvaluation\SharpeRatio.cs" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Entries" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Entries.Extra" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Entries.Extra.Old" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Entries.Old" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Repository" /> - <None Include="a2_Strategies\returnsManagement\time\CVS\Root" /> </ItemGroup> <ItemGroup> --- 179,182 ---- *************** *** 202,206 **** <Folder Include="a2_Strategies\returnsManagement" /> <Folder Include="a2_Strategies\returnsManagement\time" /> - <Folder Include="a2_Strategies\returnsManagement\time\CVS" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> --- 196,199 ---- |
|
From: Glauco S. <gla...@us...> - 2007-11-04 19:11:43
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Collections In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24247/b1_ADT/Collections Modified Files: IntArrayManager.cs Log Message: Bug fixed in the SubArray pubic static method: it should work fine now Index: IntArrayManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Collections/IntArrayManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IntArrayManager.cs 7 Oct 2007 10:25:10 -0000 1.1 --- IntArrayManager.cs 4 Nov 2007 19:11:38 -0000 1.2 *************** *** 71,75 **** subArray[ i ] = arrayOfInt[ currentPosition ]; } ! return arrayOfInt; } #endregion SubArray --- 71,75 ---- subArray[ i ] = arrayOfInt[ currentPosition ]; } ! return subArray; } #endregion SubArray |
|
From: Glauco S. <gla...@us...> - 2007-11-04 19:00:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17912/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagMain.cs Log Message: A small snippet of code has been added to invoke a RunSimpleLag backtest. Index: WFLagMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagMain.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** WFLagMain.cs 28 Oct 2007 22:23:02 -0000 1.14 --- WFLagMain.cs 4 Nov 2007 19:00:14 -0000 1.15 *************** *** 152,156 **** 4 , new SignedTickers( "IWM;-SPY" ) , 100 , "EWQ" , new QuantProject.Business.Strategies.EquityEvaluation.SharpeRatio() , ! 1000 , 3 ); // wFLagWeightedPositionsChooser = // new WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving( --- 152,156 ---- 4 , new SignedTickers( "IWM;-SPY" ) , 100 , "EWQ" , new QuantProject.Business.Strategies.EquityEvaluation.SharpeRatio() , ! 10000 , 30 ); // wFLagWeightedPositionsChooser = // new WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving( *************** *** 162,165 **** --- 162,167 ---- // new DateTime( 2001 , 1 , 8 ) , // 0.5 ).Run(); + + new RunSimpleLag().Run(); new RunWalkForwardLag( "DrvPstns" , 200 , wFLagWeightedPositionsChooser , 7 , |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:59:24
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17322/b4_Business/a2_Strategies Modified Files: WeightedPositions.cs Log Message: - the ToString() method has been overridden (useful for debugging) - a new static property WeightedPositions TestInstance has been added: it will be a good habit to add a TestInstance property to many classes, it will be useful whenever an istance is needed for testing anything - a new string property Description has been added: it is extremely useful in the debugging watch window (for copy and paste also) Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** WeightedPositions.cs 28 Oct 2007 18:54:06 -0000 1.11 --- WeightedPositions.cs 4 Nov 2007 18:59:19 -0000 1.12 *************** *** 100,103 **** --- 100,121 ---- } + public static WeightedPositions TestInstance + { + get + { + double[] weights = {1.0}; + string[] tickers = {"DUMMY"}; + WeightedPositions testInstance = new WeightedPositions( weights , tickers ); + return testInstance; + } + } + + /// <summary> + /// text description of these weighted positions. Useful for debugging + /// </summary> + public string Description + { + get { return this.ToString(); } + } private void weightedPositions_default( double[] normalizedWeightValues , string[] tickers ) *************** *** 120,135 **** } - public static WeightedPositions TestInstance - { - get - { - double[] weights = {1.0}; - string[] tickers = {"DUMMY"}; - WeightedPositions testInstance = new WeightedPositions( weights , tickers ); - return testInstance; - } - } - - public WeightedPositions( double[] normalizedUnsignedWeightValues, SignedTickers signedTickers ) --- 138,141 ---- *************** *** 694,697 **** --- 700,710 ---- weightedPosition.Weight = - weightedPosition.Weight; } + public override string ToString() + { + string toString = ""; + for ( int i = 0 ; i < this.Count ; i++ ) + toString += ((WeightedPosition)( this[ i ] )).ToString() + "--"; + return toString; + } } } |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:55:44
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15407/b4_Business/a2_Strategies Modified Files: WeightedPosition.cs Log Message: The ToString() method has been overridden (useful for debugging) Index: WeightedPosition.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPosition.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WeightedPosition.cs 30 Jul 2006 10:44:45 -0000 1.1 --- WeightedPosition.cs 4 Nov 2007 18:55:39 -0000 1.2 *************** *** 118,123 **** return dailyReturn; } ! ! } } --- 118,126 ---- return dailyReturn; } ! public override string ToString() ! { ! string toString = this.Ticker + ";" + this.Weight; ! return toString; ! } } } |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:54:45
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14846/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGenerationDebugger.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Scripts_SD.csproj 28 Oct 2007 22:29:44 -0000 1.8 --- Scripts_SD.csproj 4 Nov 2007 18:54:41 -0000 1.9 *************** *** 69,72 **** --- 69,73 ---- <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers\WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagFitnessEvaluator.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGenerationDebugger.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagLogItem.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableEncoded.cs" /> |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:53:59
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14343/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: - the method getMarketDaysForQuotes is useless and has been removed - some commented out code has been cleaned out Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ReturnsManager.cs 7 Oct 2007 13:15:55 -0000 1.7 --- ReturnsManager.cs 4 Nov 2007 18:53:56 -0000 1.8 *************** *** 64,80 **** get { return this.returnIntervals.Count; } } - // protected DateTime firstDateTime - // { - // get { return this.timeLineForQuotes.GetDateTime( 0 ); } - // } - // protected DateTime lastDateTime - // { - // get - // { - // int lastIndex = this.timeLineForQuotes.Count - 1; - // return this.timeLineForQuotes.GetDateTime( lastIndex ); - // } - // } - // /// <summary> /// Abstract class used to store and efficiently provide arrays of --- 64,67 ---- *************** *** 90,101 **** /// for the benchmark, each array of returns will have exactly /// n-1 elements</param> - // public ReturnsManager( DateTime firstDate , DateTime lastDate , - // string benchmark ) - // { - // // TO DO: let WFLagEligibleTickers use this class also!!! - // this.timeLineForQuotes = - // this.getMarketDaysForQuotes( firstDate , lastDate , benchmark ); - // this.commonInitialization(); - // } public ReturnsManager( ReturnIntervals returnIntervals , IHistoricalQuoteProvider historicalQuoteProvider ) --- 77,80 ---- *************** *** 112,121 **** this.tickersReturnsStandardDeviations = new Hashtable(); } - private History getMarketDaysForQuotes( DateTime firstDate , - DateTime lastDate , string benchmark ) - { - return Quotes.GetMarketDays( benchmark , - firstDate , lastDate ); - } private bool isAValidIndexForAReturn( int index ) --- 91,94 ---- *************** *** 129,133 **** return this.tickersReturns.ContainsKey( ticker ); } - // protected abstract History getQuotes( string ticker ); #region setReturns private float selectReturnWithRespectToTheGivenIterval( --- 102,105 ---- |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:51:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13367/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** b7_Scripts.csproj 28 Oct 2007 18:37:26 -0000 1.79 --- b7_Scripts.csproj 4 Nov 2007 18:51:54 -0000 1.80 *************** *** 794,797 **** --- 794,802 ---- /> <File + RelPath = "WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\WalkForwardLag\RunWalkForwardLag.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2007-11-04 18:51:14
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13248/b7_Scripts/WalkForwardTesting/WalkForwardLag Added Files: RunSimpleLag.cs Log Message: Tests a simple (non walk forward) lag strategy --- NEW FILE: RunSimpleLag.cs --- /* QuantProject - Quantitative Finance Library RunWalkForwardLag.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.Scripts.WalkForwardTesting.WalkForwardLag.WFLagDebugger; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { /// <summary> /// Tests a simple (non walk forward) lag strategy /// </summary> public class RunSimpleLag { public RunSimpleLag() { // // TODO: Add constructor logic here // } #region Run #region getWFLagWeightedPositions #region getDrivingWeightedPositions private WeightedPositions getWeightedPositions( double[] drivingWeights , string[] drivingTickers ) { double[] normalizedWeightValues = WeightedPositions.GetNormalizedWeights( drivingWeights ); WeightedPositions weightedPositions = new WeightedPositions( normalizedWeightValues , drivingTickers ); return weightedPositions; } #endregion getDrivingWeightedPositions private WFLagWeightedPositions getWFLagWeightedPositions( double[] drivingWeights , string[] drivingTickers , double[] portfolioWeights , string[] portfolioTickers ) { WeightedPositions drivingWeightedPositions = this.getWeightedPositions( drivingWeights , drivingTickers ); WeightedPositions portfolioWeightedPositions = this.getWeightedPositions( portfolioWeights , portfolioTickers ); WFLagWeightedPositions wFLagWeightedPositions = new WFLagWeightedPositions( drivingWeightedPositions , portfolioWeightedPositions); return wFLagWeightedPositions; } #endregion getWFLagWeightedPositions /// <summary> /// Executes the backtest /// </summary> public void Run() { // optimal driving positions // double[] drivingWeights = { 0.550560760218599 , -0.172289820708961 , -0.16220520521007 , 0.11494421386237 }; // string[] drivingTickers = { "^OEX" , "BDH" , "HHH" , "IIH" }; // bad driving positions, despite having two optimal tickers double[] drivingWeights = { -0.272826060576681 , 0.304736475342285 , -0.0953627582891244 , 0.32707470579191 }; string[] drivingTickers = { "^DJT" , "^OEX" , "BDH" , "EWJ" }; // Description "^DJT;-0.272826060576681--^OEX;0.304736475342285--BDH;-0.0953627582891244--EWJ;0.32707470579191--" string double[] portfolioWeights = { 0.442536856335084 , -0.557463143664916 }; string[] portfolioTickers = { "IWM" , "SPY" }; DateTime timeWhenOptimizationWasRequested = new DateTime( 2001 , 1 , 4 ); int numberDaysForInSampleOptimization = 100; string benchmark = "EWQ"; WFLagWeightedPositions wFLagWeightedPositions = this.getWFLagWeightedPositions( drivingWeights , drivingTickers , portfolioWeights , portfolioTickers ); WFLagDebugPositions wFLagDebugPositions = new WFLagDebugPositions( wFLagWeightedPositions , timeWhenOptimizationWasRequested , 0 , numberDaysForInSampleOptimization , 0 , benchmark ); wFLagDebugPositions.Run(); } #endregion Run } } |
|
From: Marco M. <mi...@us...> - 2007-10-30 19:06:53
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11488/b4_Business/a2_Strategies/returnsManagement/time Modified Files: ReturnIntervals.cs Log Message: Initialization of the class has been reorganized (parameters are checked in a specific method) Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReturnIntervals.cs 2 Oct 2007 14:40:06 -0000 1.3 --- ReturnIntervals.cs 30 Oct 2007 19:06:48 -0000 1.4 *************** *** 79,88 **** } ! private void returnIntervals_initialize(EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark, int intervalLength) { if(intervalLength < 1) throw new Exception("Interval length has to be greater than 0!"); this.intervalLength = intervalLength; this.firstEndOfDayDateTime = firstEndOfDayDateTime; --- 79,99 ---- } ! private void returnIntervals_initialize_checkParameters( ! EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark, int intervalLength) { + if(lastEndOfDayDateTime.CompareTo(firstEndOfDayDateTime) < 1) + throw new Exception("lastEndOfDayDateTime has to be greater than firstEndOfDayDateTime!"); if(intervalLength < 1) throw new Exception("Interval length has to be greater than 0!"); + } + + private void returnIntervals_initialize(EndOfDayDateTime firstEndOfDayDateTime , + EndOfDayDateTime lastEndOfDayDateTime , string benchmark, + int intervalLength) + { + this.returnIntervals_initialize_checkParameters( + firstEndOfDayDateTime, lastEndOfDayDateTime, benchmark, intervalLength); this.intervalLength = intervalLength; this.firstEndOfDayDateTime = firstEndOfDayDateTime; |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16198/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: - the property GenerationWhenChosenPositionsWereFound has been added - the property WFLagChosenPositions is a WFLagWeightedPositions now (it was a WFLagChosenPositions in the previous revision) - code for using a WFLagGenerationDebugger (if needed) has been added Index: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 7 Oct 2007 13:27:55 -0000 1.8 --- WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 28 Oct 2007 22:35:28 -0000 1.9 *************** *** 53,57 **** protected int generationNumberForGeneticOptimizer; ! protected WFLagChosenPositions wFLagChosenPositions; // // first in sample quote date for driving positions --- 53,59 ---- protected int generationNumberForGeneticOptimizer; ! protected GeneticOptimizer geneticOptimizer; ! protected WFLagWeightedPositions wFLagChosenPositions; ! private EndOfDayDateTime timeWhenChosePositionsIsRequested; // // first in sample quote date for driving positions *************** *** 83,86 **** --- 85,96 ---- } } + public int GenerationWhenChosenPositionsWereFound + { + get + { + return this.geneticOptimizer.BestGenome.Generation; + } + } + public string Benchmark *************** *** 92,96 **** } ! public WFLagChosenPositions WFLagChosenPositions { get --- 102,106 ---- } ! public WFLagWeightedPositions WFLagChosenPositions { get *************** *** 144,150 **** --- 154,169 ---- return returnIntervals; } + private void newGenerationEventHandler( object sender , NewGenerationEventArgs e ) { + // comment out this line if no debug is done + WFLagGenerationDebugger wFLagGenerationDebugger = + new WFLagGenerationDebugger( + e.Generation , + this.timeWhenChosePositionsIsRequested.DateTime , + this.NumberDaysForInSampleOptimization , + this.benchmark ); + wFLagGenerationDebugger.Debug(); this.NewProgress( sender , new NewProgressEventArgs( e.GenerationCounter , e.GenerationNumber ) ); *************** *** 173,182 **** EndOfDayDateTime now ) { ! WFLagWeightedPositions wFLagWeightedPositions = this.getWFLagWeightedPositions_FromDecodableGenome( genomeManager , genome ); ! this.wFLagChosenPositions = ! new WFLagChosenPositions( ! wFLagWeightedPositions , genome.Generation , now.DateTime ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = --- 192,204 ---- EndOfDayDateTime now ) { ! this.wFLagChosenPositions = this.getWFLagWeightedPositions_FromDecodableGenome( genomeManager , genome ); ! // WFLagWeightedPositions wFLagWeightedPositions = ! // this.getWFLagWeightedPositions_FromDecodableGenome( ! // genomeManager , genome ); ! // this.wFLagChosenPositions = ! // new WFLagChosenPositions( ! // wFLagWeightedPositions , genome.Generation , now.DateTime ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = *************** *** 202,206 **** QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); ! GeneticOptimizer geneticOptimizer = new GeneticOptimizer( 0.85 , 0.02 , --- 224,228 ---- QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); ! this.geneticOptimizer = new GeneticOptimizer( 0.85 , 0.02 , *************** *** 211,221 **** ConstantsProvider.SeedForRandomGenerator ); ! geneticOptimizer.NewGeneration += new NewGenerationEventHandler( this.newGenerationEventHandler ); ! geneticOptimizer.Run( false ); this.setChosenPositions_FromDecodableGenome( ! genomeManager , geneticOptimizer.BestGenome , now ); // this.generation = geneticOptimizer.BestGenome.Generation; --- 233,243 ---- ConstantsProvider.SeedForRandomGenerator ); ! this.geneticOptimizer.NewGeneration += new NewGenerationEventHandler( this.newGenerationEventHandler ); ! this.geneticOptimizer.Run( false ); this.setChosenPositions_FromDecodableGenome( ! genomeManager , this.geneticOptimizer.BestGenome , now ); // this.generation = geneticOptimizer.BestGenome.Generation; *************** *** 249,252 **** --- 271,275 ---- EndOfDayDateTime now ) { + this.timeWhenChosePositionsIsRequested = now; this.chosePositions_checkParameters( eligibleTickersForDrivingPositions , now ); |
|
From: Glauco S. <gla...@us...> - 2007-10-28 22:29:48
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13229/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: The Sharpdevelop project is aligned to the VSNet project, but a file should lack. I will check and fix it as soon as possible Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Scripts_SD.csproj 29 Aug 2007 10:34:59 -0000 1.7 --- Scripts_SD.csproj 28 Oct 2007 22:29:44 -0000 1.8 *************** *** 64,67 **** --- 64,74 ---- <Compile Include="TickerSelectionTesting\RunEfficientCTOPortfolio.cs" /> <Compile Include="WalkForwardTesting\MSFTwalkForward\TsMSFTwalkForward.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding\IWFLagDecoder.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding\WFLagDecoderForFixedPortfolioWithBalancedVolatilityAndDrivingWithBalancedVolatility.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers\WFLagBruteForceOptimizableParametersManagerForBalancedFixedPortfolioAndBalancedDriving.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagFitnessEvaluator.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagLogItem.cs" /> + <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableEncoded.cs" /> <Compile Include="WalkForwardTesting\WalkForwardOneRank\BestPerformingTickers.cs" /> <Compile Include="WalkForwardTesting\WalkForwardOneRank\ChosenTickers.cs" /> *************** *** 152,156 **** <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedPeriodOscillators\GenomeManagerForFPOscillatorCTC.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagRunDebugger.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagChosenPositions.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagReportDebugger.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagDebugger\WFLagDebugPositions\WFLagDebugPositionsEndOfDayTimerHandler.cs" /> --- 159,162 ---- *************** *** 185,189 **** <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\GenomeMeaningPVO.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\RunPVO.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagBruteForceOptimizableParametersManager.cs" /> <Compile Include="TickerSelectionTesting\TestingOTCTypes\BruteForceOptimization\RunEfficientOTCTypesBruteForce.cs" /> <Compile Include="TickerSelectionTesting\TestingOTCTypes\BruteForceOptimization\EndOfDayTimerHandlerOTCTypesBruteForce.cs" /> --- 191,194 ---- *************** *** 191,197 **** <Compile Include="WalkForwardTesting\WalkForwardLag\GeneticOptimizerTesting\WFLagGOTester.cs" /> <Compile Include="WalkForwardTesting\LinearCombination\FixedLevelOscillatorPVOStrategy.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptimizableParametersManager.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithPortfolioNormalizedVolatility.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagBruteForceOptimizableItemManager\WFLagFixedPortfolioBruteForceOptParamManagerWithNormalizedVolatility.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\BiasedPVO\EndOfDayTimerHandlerBiasedPVO.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\BiasedPVO\RunBiasedPVO.cs" /> --- 196,199 ---- *************** *** 213,217 **** <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagNewChosenPositionsEventArgs.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\IWFLagWeightedPositionsChooser.cs" /> - <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagBruteForceFixedPortfolioWeightedPositionsChooser.cs" /> <Compile Include="ArbitrageTesting\OverReactionHypothesis\SimpleOHTest\EndOfDayTimerHandlerSimpleOHTest.cs" /> <Compile Include="ArbitrageTesting\OverReactionHypothesis\SimpleOHTest\RunSimpleOHTest.cs" /> --- 215,218 ---- *************** *** 235,238 **** --- 236,242 ---- <Folder Include="EvaluatingOptimizationTechnique\EfficientPortfolio\" /> <Folder Include="TickerSelectionTesting\SimpleSelection\" /> + <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce" /> + <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\Decoding" /> + <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\OptimizableParametersManagers" /> <Folder Include="WalkForwardTesting\WalkForwardMultiOneRank\" /> <Folder Include="TechnicalAnalysisTesting\" /> |
|
From: Glauco S. <gla...@us...> - 2007-10-28 22:28:44
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12738 Modified Files: QuantProject_SD.sln Log Message: The Sharpdevelop project is aligned to the VSNet project Index: QuantProject_SD.sln =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject_SD.sln,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** QuantProject_SD.sln 8 Jul 2006 10:37:39 -0000 1.5 --- QuantProject_SD.sln 28 Oct 2007 22:28:41 -0000 1.6 *************** *** 1,4 **** ! Microsoft Visual Studio Solution File, Format Version 9.00 ! # SharpDevelop 2.0.0.1462 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b1_ADT", "b1_ADT\ADT_SD.csproj", "{6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}" EndProject --- 1,6 ---- !  ! Microsoft Visual Studio Solution File, Format Version 9.00 ! # Visual Studio 2005 ! # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b1_ADT", "b1_ADT\ADT_SD.csproj", "{6A426DC3-013E-4D38-A1AE-7BE128BF2DD7}" EndProject |