quantproject-developers Mailing List for QuantProject (Page 11)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:03:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28084/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Added Files: ILinearRegressionFitnessEvaluator.cs Log Message: Interface to be implemented by the linear regression fitness evaluators --- NEW FILE: ILinearRegressionFitnessEvaluator.cs --- /* QuantProject - Quantitative Finance Library IILinearRegressionFitnessEvaluator.cs Copyright (C) 2010 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.DataProviders; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Interface to be implemented by the linear regression fitness evaluators /// </summary> public interface ILinearRegressionFitnessEvaluator : IFitnessEvaluator { double[] GetIndependentVariablesValues( LinearRegressionTestingPositions linearRegressionTestingPositions , ReturnInterval outOfSampleReturnIntervalForSignaling , HistoricalMarketValueProvider historicalMarketValueProvider ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 16:02:55
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv27975/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding Added Files: DecoderForLinearRegressionTestingPositions.cs Log Message: Simple decoder for the Linear Regression strategy. The genome is decoded as follows: the first two tickers are used to decode a trading portfolio. For each of the other tickers is created a portfolio with that single ticker and such portfolio is used as a signaling portfolio. The first two tickers are decoded using the eligible tickers for trading, while the other tickers are decoded using the eligible tickers for signaling --- NEW FILE: DecoderForLinearRegressionTestingPositions.cs --- /* QuantProject - Quantitative Finance Library DecoderForLinearRegressionTestingPositionsWithCouples.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Collections; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Simple decoder for the Linear Regression strategy. /// The genome is decoded as follows: the first two tickers are used to decode /// a trading portfolio. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. /// The first two tickers are decoded using the eligible tickers /// for trading, while the other tickers are decoded using the eligible tickers /// for signaling /// </summary> [Serializable] public class DecoderForLinearRegressionTestingPositions // : IDecoderForTestingPositions { // private int numberOfTickersForTrading; // public int NumberOfTickersForTrading { // get { return this.numberOfTickersForTrading; } get { return 2; } } // private int numberOfSignalingPortfolios; // public int NumberOfSignalingPortfolios { get { return this.numberOfSignalingPortfolios; } } private BasicDecoderForTestingPositions basicDecoderForTestingPositions; public DecoderForLinearRegressionTestingPositions( int numberOfSignalingPortfolios ) // int numberOfTickersForTrading , int numberOfTickersForSignaling ) { // this.numberOfTickersForTrading = numberOfTickersForTrading; this.numberOfSignalingPortfolios = numberOfSignalingPortfolios; this.basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); } #region Decode private void decode_checkParameters( int[] genome ) { int numberOfExpectedGenes = this.numberOfSignalingPortfolios + 2; if ( genome.Length != numberOfExpectedGenes ) throw new Exception( "The given genom contains " + genome.Length + " genes, but " + numberOfExpectedGenes + " where expected!" ); } private int[] getSubGenome( int[] genome , int startingPosition , int length ) { int[] subGenome = new int[ length ]; for( int i = startingPosition ; i < startingPosition + length ; i++ ) subGenome[ i - startingPosition ] = genome[ i ]; return subGenome; } private WeightedPositions decodeWeightedPositionsForTrading( int[] encoded , EligibleTickers eligibleTickersForTrading , IReturnsManager returnsManager ) { int[] encodedForTradingTickers = // this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); this.getSubGenome( encoded , 0 , 2 ); WeightedPositions weightedPositionsForTrading = this.basicDecoderForTestingPositions.Decode( encodedForTradingTickers , eligibleTickersForTrading , returnsManager ).WeightedPositions; return weightedPositionsForTrading; } private WeightedPositions decodeWeightedPositionsForSignaling( int[] encoded , EligibleTickers eligibleTickersForSignaling , IReturnsManager returnsManager ) { int[] encodedForSignalingTickers = this.getSubGenome( // encoded , this.numberOfTickersForTrading , this.numberOfTickersForSignaling ); encoded , 2 , encoded.Length - 2 ); WeightedPositions weightedPositionsForSignaling = this.basicDecoderForTestingPositions.Decode( encodedForSignalingTickers , eligibleTickersForSignaling , returnsManager ).WeightedPositions; return weightedPositionsForSignaling; } #region getTestingPositions protected virtual WeightedPositions getBalancedPortfolio( SignedTickers signedTickers , IReturnsManager returnsManager ) { WeightedPositions balancedPortfolio = null; if ( !CollectionManager.ContainsDuplicates( signedTickers.Tickers ) ) { double[] balancedWeights = WeightedPositions.GetBalancedWeights( signedTickers , returnsManager ); balancedPortfolio = new WeightedPositions( balancedWeights , signedTickers.Tickers ); } return balancedPortfolio; } #region getTradingPortfolio protected virtual SignedTickers getSignedTickersForTradingPortfolio( WeightedPositions weightedPositionsForTrading , IReturnsManager returnsManager ) { SignedTickers signedTickersForTradingPortfolio = new SignedTickers( new SignedTicker[] { weightedPositionsForTrading.SignedTickers[ 0 ] , weightedPositionsForTrading.SignedTickers[ 1 ] } ); return signedTickersForTradingPortfolio; } private WeightedPositions getTradingPortfolio( WeightedPositions weightedPositionsForTrading , IReturnsManager returnsManager ) { SignedTickers signedTickers = this.getSignedTickersForTradingPortfolio( weightedPositionsForTrading , returnsManager ); WeightedPositions tradingPortfolio = this.getBalancedPortfolio( signedTickers , returnsManager ); return tradingPortfolio; } #endregion getTradingPortfolio #region getSignalingPortfolios protected virtual SignedTickers getSignedTickersForSignalingPortfolio( int portfolioIndex , WeightedPositions weightedPositionsForTrading , WeightedPositions weightedPositionsForSignaling , IReturnsManager returnsManager ) { SignedTickers signedTickersForSignalingPortfolio = new SignedTickers( new SignedTicker[] { // weightedPositionsForTrading.SignedTickers[ 0 ] , weightedPositionsForSignaling.SignedTickers[ portfolioIndex ] } ); return signedTickersForSignalingPortfolio; } private WeightedPositions getSignalingPortfolio( int portfolioIndex , WeightedPositions weightedPositionsForTrading , WeightedPositions weightedPositionsForSignaling , IReturnsManager returnsManager ) { SignedTickers signedTickers = this.getSignedTickersForSignalingPortfolio( portfolioIndex , weightedPositionsForTrading , weightedPositionsForSignaling , returnsManager ); WeightedPositions signalingPortfolio = this.getBalancedPortfolio( signedTickers , returnsManager ); return signalingPortfolio; } private WeightedPositions[] getSignalingPortfolios( WeightedPositions weightedPositionsForTrading , WeightedPositions weightedPositionsForSignaling , IReturnsManager returnsManager ) { bool containsSignalingPortfolioWithDuplicateTickers = false; WeightedPositions[] signalingPortfolios = new WeightedPositions[ weightedPositionsForSignaling.Count ]; for ( int j=0 ; j < weightedPositionsForSignaling.Count ; j++ ) { signalingPortfolios[ j ] = this.getSignalingPortfolio( j , weightedPositionsForTrading , weightedPositionsForSignaling , returnsManager ); if ( signalingPortfolios[ j ] == null ) containsSignalingPortfolioWithDuplicateTickers = true; } if ( containsSignalingPortfolioWithDuplicateTickers ) signalingPortfolios = null; return signalingPortfolios; } #endregion getSignalingPortfolios private TestingPositions getTestingPositions( WeightedPositions weightedPositionsForTrading , WeightedPositions weightedPositionsForSignaling , IReturnsManager returnsManagerForTradingTickers , IReturnsManager returnsManagerForSignalingTickers ) { TestingPositions testingPositions = new TestingPositionsForUndecodableEncoded(); WeightedPositions tradingPortfolio = this.getTradingPortfolio( weightedPositionsForTrading , returnsManagerForTradingTickers ); WeightedPositions[] signalingPortfolios = this.getSignalingPortfolios( weightedPositionsForTrading , weightedPositionsForSignaling , returnsManagerForSignalingTickers ); if ( tradingPortfolio != null && signalingPortfolios != null ) // all portfolios are valid, because none of them contained // duplicated tickers testingPositions = new LinearRegressionTestingPositions( signalingPortfolios , tradingPortfolio ); return testingPositions; } #endregion getTestingPositions /// <summary> /// The genome is decoded as follows: the first two tickers are used to decode /// a trading portfolio. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. /// The first two tickers are decoded using the eligible tickers /// for trading, while the other tickers are decoded using the eligible tickers /// for signaling /// </summary> /// <param name="encoded"></param> /// <param name="eligibleTickersForTrading"></param> /// <param name="eligibleTickersForSignaling"></param> /// <param name="returnsManagerForTradingTickers"></param> /// <param name="returnsManagerForSignalingTickers"></param> /// <returns></returns> public TestingPositions Decode( int[] encoded , EligibleTickers eligibleTickersForTrading , EligibleTickers eligibleTickersForSignaling , IReturnsManager returnsManagerForTradingTickers , IReturnsManager returnsManagerForSignalingTickers ) { this.decode_checkParameters( encoded ); WeightedPositions weightedPositionsForTrading = this.decodeWeightedPositionsForTrading( encoded , eligibleTickersForTrading , returnsManagerForTradingTickers ); WeightedPositions weightedPositionsForSignaling = this.decodeWeightedPositionsForSignaling( encoded , eligibleTickersForSignaling , returnsManagerForSignalingTickers ); TestingPositions meaning = new TestingPositionsForUndecodableEncoded(); if ( weightedPositionsForTrading != null && weightedPositionsForSignaling != null ) // there were not duplicated tickers in the encoded meaning = this.getTestingPositions( weightedPositionsForTrading , weightedPositionsForSignaling , returnsManagerForTradingTickers , returnsManagerForSignalingTickers ); return meaning; } #endregion Decode } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:57:37
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25429/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding Added Files: DecoderFirstTradingTickerInEachSignalingPortfolio.cs Log Message: ecoder for the Linear Regression strategy with ratios. The genome is decoded as follows: assume that the genome has n elements. Then it is decoded in an array of n-1 WeightedPositions: the i_th WeightedPositions contains the balanced portfolio with two positions: one for the ticker of the first gene and one for the ticker of the i+1_th gene; the first two ticker are decoded using the eligible tickers for trading, while the other tickers are decoded using the eligible tickers for signaling --- NEW FILE: DecoderFirstTradingTickerInEachSignalingPortfolio.cs --- /* QuantProject - Quantitative Finance Library DecoderFirstTradingTickerInEachSignalingPortfolio.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Collections; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Decoder for the Linear Regression strategy with ratios. The genome is decoded /// as follows: assume that the genome has n elements. Then it is decoded in an array /// of n-1 WeightedPositions: the i_th WeightedPositions contains the balanced portfolio /// with two positions: one for the ticker of the first gene and one for the ticker /// of the i+1_th gene; the first two ticker are decoded using the eligible tickers /// for trading, while the other tickers are decoded using the eligible tickers /// for signaling /// </summary> [Serializable] public class DecoderFirstTradingTickerInEachSignalingPortfolio : DecoderForLinearRegressionTestingPositions { //// private int numberOfTickersForTrading; //// // public int NumberOfTickersForTrading { //// get { return this.numberOfTickersForTrading; } // get { return 2; } // } //// // private int numberOfTickersForSignaling; //// // public int NumberOfTickersForSignaling { // get { return this.numberOfTickersForSignaling; } // } // private BasicDecoderForTestingPositions basicDecoderForTestingPositions; // public DecoderFirstTradingTickerInEachSignalingPortfolio( int numberOfTickersForSignaling ) : base( numberOfTickersForSignaling ) { } // int numberOfTickersForTrading , int numberOfTickersForSignaling ) // { // this.numberOfTickersForTrading = numberOfTickersForTrading; // this.numberOfTickersForSignaling = numberOfTickersForSignaling; // this.basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); // } // // #region Decode // private void decode_checkParameters( int[] genome ) // { // int numberOfExpectedGenes = this.numberOfTickersForSignaling + 2; // if ( genome.Length != numberOfExpectedGenes ) // throw new Exception( // "The given genom contains " + genome.Length + " genes, but " + // numberOfExpectedGenes + " where expected!" ); // } // private int[] getSubGenome( int[] genome , int startingPosition , int length ) // { // int[] subGenome = new int[ length ]; // for( int i = startingPosition ; i < startingPosition + length ; i++ ) // subGenome[ i - startingPosition ] = genome[ i ]; // return subGenome; // } // private WeightedPositions decodeWeightedPositionsForTrading( // int[] encoded , // EligibleTickers eligibleTickersForTrading , // IReturnsManager returnsManager ) // { // int[] encodedForTradingTickers = //// this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); // this.getSubGenome( encoded , 0 , 2 ); // WeightedPositions weightedPositionsForTrading = // this.basicDecoderForTestingPositions.Decode( // encodedForTradingTickers , // eligibleTickersForTrading , returnsManager ).WeightedPositions; // return weightedPositionsForTrading; // } // private WeightedPositions decodeWeightedPositionsForSignaling( // int[] encoded , // EligibleTickers eligibleTickersForSignaling , // IReturnsManager returnsManager ) // { // int[] encodedForSignalingTickers = // this.getSubGenome( //// encoded , this.numberOfTickersForTrading , this.numberOfTickersForSignaling ); // encoded , 2 , encoded.Length - 2 ); // WeightedPositions weightedPositionsForSignaling = // this.basicDecoderForTestingPositions.Decode( // encodedForSignalingTickers , // eligibleTickersForSignaling , returnsManager ).WeightedPositions; // return weightedPositionsForSignaling; // } // // #region getTestingPositions // protected virtual WeightedPositions getBalancedPortfolio( // SignedTickers signedTickers , // IReturnsManager returnsManager ) // { // WeightedPositions balancedPortfolio = null; // if ( !CollectionManager.ContainsDuplicates( signedTickers.Tickers ) ) // { // double[] balancedWeights = WeightedPositions.GetBalancedWeights( // signedTickers , returnsManager ); // balancedPortfolio = // new WeightedPositions( balancedWeights , signedTickers.Tickers ); // } // return balancedPortfolio; // } // // #region getTradingPortfolio // protected virtual SignedTickers getSignedTickersForTradingPortfolio( // WeightedPositions weightedPositionsForTrading , // IReturnsManager returnsManager ) // { // SignedTickers signedTickersForTradingPortfolio = new SignedTickers( // new SignedTicker[] { // weightedPositionsForTrading.SignedTickers[ 0 ] , // weightedPositionsForTrading.SignedTickers[ 1 ] } ); // return signedTickersForTradingPortfolio; // } // private WeightedPositions getTradingPortfolio( // WeightedPositions weightedPositionsForTrading , // IReturnsManager returnsManager ) // { // SignedTickers signedTickers = this.getSignedTickersForTradingPortfolio( // weightedPositionsForTrading , returnsManager ); // WeightedPositions tradingPortfolio = this.getBalancedPortfolio( // signedTickers , returnsManager ); // return tradingPortfolio; // } // #endregion getTradingPortfolio // // #region getSignalingPortfolios protected override SignedTickers getSignedTickersForSignalingPortfolio( int portfolioIndex , WeightedPositions weightedPositionsForTrading , WeightedPositions weightedPositionsForSignaling , IReturnsManager returnsManager ) { SignedTickers signedTickersForSignalingPortfolio = new SignedTickers( new SignedTicker[] { weightedPositionsForTrading.SignedTickers[ 0 ] , weightedPositionsForSignaling.SignedTickers[ portfolioIndex ] } ); return signedTickersForSignalingPortfolio; } // private WeightedPositions getSignalingPortfolio( // int portfolioIndex , // WeightedPositions weightedPositionsForTrading , // WeightedPositions weightedPositionsForSignaling , // IReturnsManager returnsManager ) // { // SignedTickers signedTickers = this.getSignedTickersForSignalingPortfolio( // portfolioIndex , weightedPositionsForTrading , weightedPositionsForSignaling , // returnsManager ); // WeightedPositions signalingPortfolio = this.getBalancedPortfolio( // signedTickers , returnsManager ); // return signalingPortfolio; // } // private WeightedPositions[] getSignalingPortfolios( // WeightedPositions weightedPositionsForTrading , // WeightedPositions weightedPositionsForSignaling , // IReturnsManager returnsManager ) // { // bool containsSignalingPortfolioWithDuplicateTickers = false; // WeightedPositions[] signalingPortfolios = new WeightedPositions[ // weightedPositionsForSignaling.Count ]; // for ( int j=0 ; j < weightedPositionsForSignaling.Count ; j++ ) // { // signalingPortfolios[ j ] = this.getSignalingPortfolio( // j , weightedPositionsForTrading , weightedPositionsForSignaling , // returnsManager ); // if ( signalingPortfolios[ j ] == null ) // containsSignalingPortfolioWithDuplicateTickers = true; // } // if ( containsSignalingPortfolioWithDuplicateTickers ) // signalingPortfolios = null; // return signalingPortfolios; // } // #endregion getSignalingPortfolios // // // // private TestingPositions getTestingPositions( // WeightedPositions weightedPositionsForTrading , // WeightedPositions weightedPositionsForSignaling , // IReturnsManager returnsManagerForTradingTickers , // IReturnsManager returnsManagerForSignalingTickers ) // { // TestingPositions testingPositions = new TestingPositionsForUndecodableEncoded(); // WeightedPositions tradingPortfolio = this.getTradingPortfolio( // weightedPositionsForTrading , returnsManagerForTradingTickers ); // WeightedPositions[] signalingPortfolios = this.getSignalingPortfolios( // weightedPositionsForTrading , weightedPositionsForSignaling , // returnsManagerForSignalingTickers ); // if ( tradingPortfolio != null && signalingPortfolios != null ) // // all portfolios are valid, because none of them contained // // duplicated tickers // testingPositions = new LinearRegressionTestingPositions( // signalingPortfolios , tradingPortfolio ); // return testingPositions; // } // #endregion getTestingPositions // // public TestingPositions Decode( // int[] encoded , // EligibleTickers eligibleTickersForTrading , // EligibleTickers eligibleTickersForSignaling , // IReturnsManager returnsManagerForTradingTickers , // IReturnsManager returnsManagerForSignalingTickers ) // { // this.decode_checkParameters( encoded ); // WeightedPositions weightedPositionsForTrading = // this.decodeWeightedPositionsForTrading( // encoded , eligibleTickersForTrading , returnsManagerForTradingTickers ); // WeightedPositions weightedPositionsForSignaling = // this.decodeWeightedPositionsForSignaling( // encoded , eligibleTickersForSignaling , returnsManagerForSignalingTickers ); // TestingPositions meaning = new TestingPositionsForUndecodableEncoded(); // if ( weightedPositionsForTrading != null && weightedPositionsForSignaling != null ) // // there were not duplicated tickers in the encoded // meaning = this.getTestingPositions( // weightedPositionsForTrading , weightedPositionsForSignaling , // returnsManagerForTradingTickers , returnsManagerForSignalingTickers ); // return meaning; // } // #endregion Decode } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:56:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ExitStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24719/WalkForwardTesting/LinearRegression/ExitStrategies Added Files: IExitStrategy.cs Log Message: Decides if current positions have to be closed --- NEW FILE: IExitStrategy.cs --- /* QuantProject - Quantitative Finance Library IExitStrategy.cs Copyright (C) 2010 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.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Decides if current positions have to be closed /// </summary> public interface IExitStrategy { bool ArePositionsToBeClosed( DateTime now , ReturnIntervals returnIntervals ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:55:29
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ExitStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24469/WalkForwardTesting/LinearRegression/ExitStrategies Added Files: ExitOnIntervalEnd.cs Log Message: Positions are closed when the current out of sample return interval ends. That is, if for instance close to close intervals are considered, then positions are closed on market close --- NEW FILE: ExitOnIntervalEnd.cs --- /* QuantProject - Quantitative Finance Library ExitOnIntervalEnd.cs Copyright (C) 2010 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.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Positions are closed when the current out of sample return interval ends. /// That is, if for instance close to close intervals are considered, then /// positions are closed on market close /// </summary> [Serializable] public class ExitOnIntervalEnd : IExitStrategy { // private bool haveParametersBeenSetAfterLastRequest; // private ReturnIntervals returnIntervals; public ExitOnIntervalEnd() { // this.haveParametersBeenSetAfterLastRequest = false; // this.returnIntervals = returnIntervals; } #region ArePositionsToBeClosed /// <summary> /// returns true iif now is at the end of the second last interval /// </summary> /// <param name="now"></param> /// <param name="returnIntervals"></param> /// <returns></returns> public bool ArePositionsToBeClosed( DateTime now , ReturnIntervals returnIntervals ) { bool areToBeClosed = false; if ( returnIntervals.Count >= 2 ) { ReturnInterval secondLastInterval = returnIntervals.SeconLastInterval; areToBeClosed = ( now == secondLastInterval.End ); } return areToBeClosed; } #endregion ArePositionsToBeClosed } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:53:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23617/WalkForwardTesting/LinearRegression/EntryStrategies Added Files: IEntryStrategy.cs Log Message: Returns the WeightedPositions to be opened out of sample. Returns null if none is suitable --- NEW FILE: IEntryStrategy.cs --- /* QuantProject - Quantitative Finance Library IEntryStrategy.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Returns the WeightedPositions to be opened out of sample. /// Returns null if none is suitable /// </summary> public interface IEntryStrategy { /// <summary> /// Returns the WeightedPositions to be opened out of sample. /// Returns null if none is suitable /// </summary> /// <returns>null if it finds no positions as required</returns> WeightedPositions GetPositionsToBeOpened( TestingPositions[] bestTestingPositionsInSample , ReturnIntervals outOfSampleReturnIntervals ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:51:48
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv22737/WalkForwardTesting/LinearRegression/EntryStrategies Added Files: EntryStrategyBasedOnForecastedReturn.cs Log Message: Two positions are chosen, if the forecasted return is at least a given threshold --- NEW FILE: EntryStrategyBasedOnForecastedReturn.cs --- /* QuantProject - Quantitative Finance Library EntryStrategyBasedOnForecastedReturn.cs Copyright (C) 2010 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.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Two positions are chosen, if the forecasted return is at least /// a given threshold /// </summary> [Serializable] public class EntryStrategyBasedOnForecastedReturn : IEntryStrategy { private double minAverageExpectedReturn; private ILinearRegressionFitnessEvaluator fitnessEvaluator; private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; private HistoricalMarketValueProvider historicalMarketValueProvider; // private bool haveParametersBeenSetAfterLastGetPositions; // TestingPositions[] bestTestingPositionsInSample; /// <summary> /// Two positions are chosen, if the forecasted return is at least /// a given threshold /// </summary> /// <param name="minAverageExpectedReturn"></param> public EntryStrategyBasedOnForecastedReturn( double minAverageExpectedReturn , ILinearRegressionFitnessEvaluator fitnessEvaluator , IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , HistoricalMarketValueProvider historicalMarketValueProvider ) { this.minAverageExpectedReturn = minAverageExpectedReturn; this.fitnessEvaluator = fitnessEvaluator; this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; this.historicalMarketValueProvider = historicalMarketValueProvider; // this.haveParametersBeenSetAfterLastGetPositions = false; } // public void SetParametersForGetPositionsToBeOpened( // TestingPositions[] bestTestingPositionsInSample ) // { // this.bestTestingPositionsInSample = bestTestingPositionsInSample; // this.haveParametersBeenSetAfterLastGetPositions = true; // } #region GetPositionsToBeOpened #region getPositionsToBeOpened #region tryThisCandidate private bool wereAllSignalingTickersExchanged( LinearRegressionTestingPositions candidate , ReturnInterval outOfSampleReturnIntervalForSignaling ) { bool wereExchanged = ( this.historicalMarketValueProvider.WereAllExchanged( candidate.SignalingTickers , outOfSampleReturnIntervalForSignaling.Begin ) && this.historicalMarketValueProvider.WereAllExchanged( candidate.SignalingTickers , outOfSampleReturnIntervalForSignaling.End ) ); return wereExchanged; } #region computeForecastedReturn private double[] getOutOfSampleValuesForSignalingPortfolios( LinearRegressionTestingPositions candidate , ReturnInterval outOfSampleReturnIntervalForSignaling ) { // ReturnInterval outOfSampleReturnIntervalSignaling = // this.returnIntervalSelectorForSignaling.GetReturnIntervalUsedForSignaling( // outOfSampleReturnIntervalForTrading ); double[] outOfSampleValuesForIndependentVariables = this.fitnessEvaluator.GetIndependentVariablesValues( candidate , outOfSampleReturnIntervalForSignaling , this.historicalMarketValueProvider ); return outOfSampleValuesForIndependentVariables; } private double computeForecastedReturnOnValidReturnIntervalForSignaling( LinearRegressionTestingPositions candidate , double[] outOfSampleValuesForSignalingPortfolios ) { double forecastedReturn = 0; // the first coefficient is for the constant regressor // and it has no return for ( int i = 1; i < candidate.LinearRegression.EstimatedCoefficients.Length ; i++ ) forecastedReturn += candidate.LinearRegression.EstimatedCoefficients[ i ] * outOfSampleValuesForSignalingPortfolios[ i ]; return forecastedReturn; } private double computeForecastedReturn( LinearRegressionTestingPositions candidate , ReturnInterval outOfSampleReturnIntervalForSignaling ) { double forecastedReturn = double.MinValue;; double[] outOfSampleValuesForSignalingPortfolios = this.getOutOfSampleValuesForSignalingPortfolios( candidate , outOfSampleReturnIntervalForSignaling ); if ( outOfSampleValuesForSignalingPortfolios != null ) // all signaling tickers where actually exchanged on the // given outOfSampleReturnIntervalForSignaling forecastedReturn = this.computeForecastedReturnOnValidReturnIntervalForSignaling( candidate , outOfSampleValuesForSignalingPortfolios ); return forecastedReturn; } #endregion computeForecastedReturn private WeightedPositions tryThisCandidate( LinearRegressionTestingPositions candidate , ReturnInterval outOfSampleReturnIntervalForSignaling ) { WeightedPositions weightedPositionsToBeOpened = null; if ( this.wereAllSignalingTickersExchanged ( candidate , outOfSampleReturnIntervalForSignaling ) ) { double expectedReturn = this.computeForecastedReturn( candidate , outOfSampleReturnIntervalForSignaling ); if ( expectedReturn >= this.minAverageExpectedReturn ) weightedPositionsToBeOpened = candidate.WeightedPositions; } return weightedPositionsToBeOpened; } private WeightedPositions tryThisCandidate( int indexOfTheCurrentCandidate , TestingPositions[] bestTestingPositionsInSample , ReturnInterval outOfSampleReturnIntervalForSignaling ) { LinearRegressionTestingPositions candidate = (LinearRegressionTestingPositions)bestTestingPositionsInSample[ indexOfTheCurrentCandidate ]; WeightedPositions weightedPositionsToBeOpened = this.tryThisCandidate( candidate , outOfSampleReturnIntervalForSignaling ); return weightedPositionsToBeOpened; } #endregion tryThisCandidate private WeightedPositions getPositionsToBeOpened( TestingPositions[] bestTestingPositionsInSample , ReturnInterval outOfSampleReturnIntervalForSignaling ) { WeightedPositions weightedPositionsToBeOpened = null; int indexOfTheCurrentCandidate = 0; while ( ( weightedPositionsToBeOpened == null ) && ( indexOfTheCurrentCandidate < bestTestingPositionsInSample.Length ) ) { weightedPositionsToBeOpened = this.tryThisCandidate( indexOfTheCurrentCandidate , bestTestingPositionsInSample , outOfSampleReturnIntervalForSignaling ); indexOfTheCurrentCandidate++; } return weightedPositionsToBeOpened; } #endregion getPositionsToBeOpened public WeightedPositions GetPositionsToBeOpened( TestingPositions[] bestTestingPositionsInSample , ReturnIntervals outOfSampleReturnIntervals ) { ReturnInterval outOfSampleReturnIntervalForTrading = outOfSampleReturnIntervals.LastInterval; ReturnInterval outOfSampleReturnIntervalForSignaling = this.returnIntervalSelectorForSignaling.GetReturnIntervalUsedForSignaling( outOfSampleReturnIntervalForTrading ); // if ( !this.haveParametersBeenSetAfterLastGetPositions ) // throw new Exception( // "The method SetParametersForGetPositionsToBeOpened() has to be called " + // "before calling the method GetPositionsToBeOpened() ! " ); // else WeightedPositions positionsToBeOpened = this.getPositionsToBeOpened( bestTestingPositionsInSample , outOfSampleReturnIntervalForSignaling ); // this.haveParametersBeenSetAfterLastGetPositions = false; return positionsToBeOpened; } #endregion GetPositionsToBeOpened } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:50:52
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv22326/WalkForwardTesting/LinearRegression/eligibles Added Files: EligiblesSelectorForLinearRegression.cs Log Message: Eligibles selector to be used by the Linear Regression strategy --- NEW FILE: EligiblesSelectorForLinearRegression.cs --- /* QuantProject - Quantitative Finance Library EligiblesSelectorForLinearRegression.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Data.Selectors; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Eligibles selector to be used by the Linear Regression strategy /// </summary> [Serializable] public class EligiblesSelectorForLinearRegression : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private string groupIdForTradingTickers; private string groupIdForAdditionalSignalingTickers; private ITickerSelectorByGroup tickerSelectorByGroup; private Benchmark benchmark; private HistoricalMarketValueProvider historicalMarketValueProvider; private double minPercentageOfDateTimesWithMarketValues; private double minPriceForTradingTicker; private double maxPriceForTradingTicker; private int maxNumberOfEligiblesForTrading; private EligibleTickers eligibleTickersForTrading; private EligibleTickers eligibleTickersForSignaling; public EligibleTickers EligibleTickersForTrading { get { return eligibleTickersForTrading; } } public EligibleTickers EligibleTickersForSignaling { get { return this.eligibleTickersForSignaling; } } public string Description { get{ string description = "TradingGroup_" + this.groupIdForTradingTickers + "\n" + "SignalingGroup_" + this.groupIdForAdditionalSignalingTickers + "\n" + "MaxNumberOfTrdingTickers_" + this.maxNumberOfEligiblesForTrading + "\n" + "MinPrercentageOfAvailableMarketValues_" + this.minPercentageOfDateTimesWithMarketValues + "\n" + "From_" + this.minPriceForTradingTicker + "_to_" + this.maxPriceForTradingTicker + "\n" + "Eligibles For Linear Regression"; return description; } } public EligiblesSelectorForLinearRegression( string groupIdForTradingTickers , string groupIdForAdditionalSignalingTickers , ITickerSelectorByGroup tickerSelectorByGroup , Benchmark benchmark , HistoricalMarketValueProvider historicalMarketValueProvider , double minPercentageOfDateTimesWithMarketValues , double minPriceForTradingTicker , double maxPriceForTradingTicker , int maxNumberOfEligiblesForTrading ) { this.eligiblesSelectorForLinearRegression_checkParameters ( minPercentageOfDateTimesWithMarketValues ); this.groupIdForTradingTickers = groupIdForTradingTickers; this.groupIdForAdditionalSignalingTickers = groupIdForAdditionalSignalingTickers; this.tickerSelectorByGroup = tickerSelectorByGroup; this.benchmark = benchmark; this.historicalMarketValueProvider = historicalMarketValueProvider; this.minPercentageOfDateTimesWithMarketValues = minPercentageOfDateTimesWithMarketValues; this.minPriceForTradingTicker = minPriceForTradingTicker; this.maxPriceForTradingTicker = maxPriceForTradingTicker; this.maxNumberOfEligiblesForTrading = maxNumberOfEligiblesForTrading; } private void eligiblesSelectorForLinearRegression_checkParameters( double minPercentageOfDateTimesWithMarketValues ) { if ( minPercentageOfDateTimesWithMarketValues < 0 ) throw new Exception( "minPercentageOfDateTimesWithMarketValues cannot be less than zero!" ); if ( minPercentageOfDateTimesWithMarketValues > 1 ) throw new Exception( "minPercentageOfDateTimesWithMarketValues cannot be more than 1!" ); } #region GetEligibleTickers #region setEligibleTickers private EligibleTickers getTickersWithEnoughTradingDays( string groupId , History history ) { IEligiblesSelector oftenExchanged = new OftenExchanged( this.groupIdForTradingTickers , this.tickerSelectorByGroup , this.historicalMarketValueProvider , this.minPercentageOfDateTimesWithMarketValues ); EligibleTickers tickersFromTradingGroupWithEnoughTradingDays = oftenExchanged.GetEligibleTickers( history ); // DateTime currentDateTime = history.LastDateTime; // SelectorByGroup tradingGroup = new SelectorByGroup( // this.groupIdForTradingTickers , currentDate); // DataTable tickersFromTheTradingGroup = group.GetTableOfSelectedTickers(); return tickersFromTradingGroupWithEnoughTradingDays; } private EligibleTickers getEligibleTickersForTrading( EligibleTickers tickersFromTradingGroupWithEnoughTradingDays , History history ) { DataTable tickersWithEnoughTradingDays = TickerSelector.GetDataTableForTickerSelectors( tickersFromTradingGroupWithEnoughTradingDays.Tickers ); DateTime dateTime = history.LastDateTime; SelectorByAverageRawOpenPrice byPrice = new SelectorByAverageRawOpenPrice( tickersWithEnoughTradingDays , false , dateTime.AddDays( -15 ) , dateTime , this.maxNumberOfEligiblesForTrading * 10 , this.minPriceForTradingTicker , this.maxPriceForTradingTicker , 0.000001 , 10000000 ); DataTable tickersWithinPriceRange = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity byLiquidity = new SelectorByLiquidity( tickersWithinPriceRange , true, dateTime.AddDays( -15 ) , dateTime , this.maxNumberOfEligiblesForTrading ); DataTable liquidTickers = byLiquidity.GetTableOfSelectedTickers(); EligibleTickers eligibleTickersForTrading = new EligibleTickers( liquidTickers ); return eligibleTickersForTrading; } private EligibleTickers getEligibleTickersForSignaling( EligibleTickers tickersFromTradingGroupWithEnoughTradingDays , History history ) { EligibleTickers eligibleTickers = this.getTickersWithEnoughTradingDays( this.groupIdForAdditionalSignalingTickers , history ); eligibleTickers.AddAdditionalEligibles( tickersFromTradingGroupWithEnoughTradingDays ); return eligibleTickers; } private void setEligibleTickers( History history ) { EligibleTickers tickersFromTradingGroupWithEnoughTradingDays = this.getTickersWithEnoughTradingDays( this.groupIdForTradingTickers , history ); this.eligibleTickersForTrading = this.getEligibleTickersForTrading( tickersFromTradingGroupWithEnoughTradingDays , history ); this.eligibleTickersForSignaling = this.getEligibleTickersForSignaling( tickersFromTradingGroupWithEnoughTradingDays , history ); } #endregion setEligibleTickers private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers for trading, but it sets also /// the eligibles tickers for signaling /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( History history ) { this.setEligibleTickers( history ); this.getEligibleTickers_sendNewMessage( this.eligibleTickersForTrading ); return this.eligibleTickersForTrading; } #endregion GetEligibleTickers } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:49:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv21590/WalkForwardTesting/LinearRegression Added Files: LinearRegressionTestingPositions.cs Log Message: TestingPositions for the linear regressin strategy --- NEW FILE: LinearRegressionTestingPositions.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionTestingPositions.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using QuantProject.ADT.Econometrics; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// TestingPositions for the linear regressin strategy /// </summary> [Serializable] public class LinearRegressionTestingPositions : TestingPositions , IGeneticallyOptimizable { private ILinearRegression linearRegression; private WeightedPositions[] signalingPortfolios; public virtual ILinearRegression LinearRegression { get { return this.linearRegression; } set { this.linearRegression = value; } } public WeightedPositions[] SignalingPortfolios { get { return this.signalingPortfolios; } set { signalingPortfolios = value; } } public WeightedPositions TradingPortfolio { get { return this.WeightedPositions; } } private int generation; public int Generation { get { return this.generation; } set { this.generation = value; } } public List<string> SignalingTickers { get { List<string> signalingTickers = new List<string>(); foreach( WeightedPositions signalingPortfolio in this.SignalingPortfolios ) foreach( string ticker in signalingPortfolio.SignedTickers.Tickers ) if ( !signalingTickers.Contains( ticker ) ) signalingTickers.Add( ticker ); return signalingTickers; } } /// <summary> /// testing positions to be used by the linear regression strategy /// </summary> /// <param name="signalingPortfolios">the return /// of each portfolio is a regressor</param> /// <param name="tradingPortfolio">the regressand is the return of this /// portfolio</param> public LinearRegressionTestingPositions( WeightedPositions[] signalingPortfolios , WeightedPositions tradingPortfolio ) : base( tradingPortfolio ) { this.signalingPortfolios = signalingPortfolios; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:48:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv21189/WalkForwardTesting/LinearRegression Added Files: LinearRegressionMain.cs Log Message: Entry point for the LinearRegression strategy. If any strategy parameter had to be changed, this is the place where it should be done --- NEW FILE: LinearRegressionMain.cs --- /* QuantProject - Quantitative Finance Library LinearRegressionMain.cs Copyright (C) 2010 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using QuantProject.ADT.Timing; using QuantProject.Data.Selectors; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; using QuantProject.Scripts.General; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression { /// <summary> /// Entry point for the LinearRegression strategy. If any strategy /// parameter had to be changed, this is the place where it should /// be done /// </summary> public class LinearRegressionMain : BasicScriptForBacktesting { private Benchmark benchmark; private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; private HistoricalMarketValueProvider historicalMarketValueProviderForChosingPositionsOutOfSample; private HistoricalMarketValueProvider historicalMarketValueProviderForTheBacktesterAccount; private LinearRegressionFitnessEvaluator fitnessEvaluator; private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; // protected IEligiblesSelector eligiblesSelectorForSignalingTickers; public LinearRegressionMain() { this.benchmark = new Benchmark( "CCE" ); this.historicalMarketValueProviderForInSample = new HistoricalAdjustedQuoteProvider(); this.historicalMarketValueProviderForChosingPositionsOutOfSample = this.historicalMarketValueProviderForInSample; this.historicalMarketValueProviderForTheBacktesterAccount = this.historicalMarketValueProviderForChosingPositionsOutOfSample; this.returnIntervalSelectorForSignaling = new ShiftedTimeIntervalSelectorForSignaling( new TimeSpan( -24 , 0 , 0 ) ); } protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() { string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = @"T:\senzaBackup\qpReports\linearRegression\"; return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } protected override string getCustomSmallTextForFolderName() { return "lnrRgrssn"; } protected override string getFullPathFileNameForMain() { string fullPathFileNameForMain = @"T:\QuantProject\QuantProject\b7_Scripts\WalkForwardTesting\LinearRegression\LinearRegressionMain.cs"; return fullPathFileNameForMain; } protected override IEligiblesSelector getEligiblesSelector() { string groupIdForTradingTickers = "SP500"; string groupIdForAdditionalSignalingTickers = "usIndxs"; ITickerSelectorByGroup tickerSelectorByGroup = new TickerSelectorByGroup(); // double minPercentageOfAvailableValues = 0.8; double minPercentageOfAvailableValues = 0.9; double minPriceForTradingTicker = 1; double maxPriceForTradingTicker = 9000; int maxNumberOfEligiblesForTrading = 150; // uncomment the followings line for a faster script // groupIdForTradingTickers = "fastTest"; // groupIdForAdditionalSignalingTickers = "fastTest"; // maxNumberOfEligiblesForTrading = 8; IEligiblesSelector eligiblesSelector = new EligiblesSelectorForLinearRegression( groupIdForTradingTickers , groupIdForAdditionalSignalingTickers , tickerSelectorByGroup , this.benchmark , this.historicalMarketValueProviderForInSample , minPercentageOfAvailableValues , minPriceForTradingTicker , maxPriceForTradingTicker , maxNumberOfEligiblesForTrading ); // this.eligiblesSelectorForSignalingTickers = // new SP550andIndexes(); // uncomment the following line for a (logbased) log based in sample chooser // eligiblesSelector = new DummyEligibleSelector(); return eligiblesSelector; } protected override IInSampleChooser getInSampleChooser() { int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script // numberOfBestTestingPositionsToBeReturned = 20; // numberOfBestTestingPositionsToBeReturned = 5; // int numberOfTickersForTrading = 2; int numberOfSignalingPortfolios = 4; DecoderForLinearRegressionTestingPositions decoderForWeightedPositions = new DecoderForLinearRegressionTestingPositions( numberOfSignalingPortfolios ); // numberOfTickersForTrading , numberOfTickersForSignaling ); // double maxCorrelationAllowed = 0.96; copypasted // IReturnIntervalFilter returnIntervalFilterForTrading = // new ReturnIntervalFilterForDaysOfTheWeek( // new List<DayOfWeek>( new DayOfWeek[] { // DayOfWeek.Tuesday , DayOfWeek.Wednesday , // DayOfWeek.Thursday , DayOfWeek.Friday } ) ); // IReturnIntervalFilter returnIntervalFilterForSignaling = // new ReturnIntervalFilterForDaysOfTheWeek( // new List<DayOfWeek>( new DayOfWeek[] { // DayOfWeek.Monday , DayOfWeek.Tuesday , // DayOfWeek.Wednesday , DayOfWeek.Thursday } ) ); IReturnIntervalsBuilderForTradingAndForSignaling returnIntervalsBuilderForTradingAndForSignaling = new ReturnIntervalsBuilderForTradingAndForSignaling(); // returnIntervalFilterForTrading , // returnIntervalFilterForSignaling ); this.fitnessEvaluator = new LinearRegressionFitnessEvaluator( new LinearRegressionSetupManager() ); // parameters for the genetic optimizer double crossoverRate = 0.85; double mutationRate = 0.02; double elitismRate = 0.001; int populationSizeForGeneticOptimizer = 60000; int generationNumberForGeneticOptimizer = 15; // uncomment the followings line for a faster script // populationSizeForGeneticOptimizer = 300; // generationNumberForGeneticOptimizer = 4; int seedForRandomGeneratorForTheGeneticOptimizer = QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; int seedForRandomGeneratorForGenomeManagerForTradingTickers = seedForRandomGeneratorForTheGeneticOptimizer + 1; int seedForRandomGeneratorForGenomeManagerForSignalingTickers = seedForRandomGeneratorForTheGeneticOptimizer + 2; IInSampleChooser inSampleChooser = new LinearRegressionGeneticChooser( numberOfBestTestingPositionsToBeReturned , this.benchmark , decoderForWeightedPositions , this.returnIntervalSelectorForSignaling , returnIntervalsBuilderForTradingAndForSignaling , fitnessEvaluator , this.historicalMarketValueProviderForInSample , this.eligiblesSelector , crossoverRate , mutationRate , elitismRate , populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , seedForRandomGeneratorForTheGeneticOptimizer , seedForRandomGeneratorForGenomeManagerForTradingTickers , seedForRandomGeneratorForGenomeManagerForSignalingTickers ); // uncomment the following line for a (logbased) log based in sample chooser // inSampleChooser = // new PairsTradingChooserFromSavedBackTestLog( // @"C:\qpReports\pairsTrading\2008_05_08_23_49_18_pairsTrdng_from_2005_01_01_to_2008_04_30_annlRtrn_90.70_maxDD_5.43\2008_05_08_23_49_18_pairsTrdng_from_2005_01_01_to_2008_04_30_annlRtrn_90.70_maxDD_5.43.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; } protected override IStrategyForBacktester getStrategyForBacktester() { int inSampleDays = 180; inSampleDays = 360; // uncomment the following line for a faster script // inSampleDays = 5; // inSampleDays = 60; // IIntervalsSelector intervalsSelectorForOutOfSample = // new OddIntervalsSelector( 1 , 1 , this.benchmark ); Time timeForTrading = new Time( HistoricalEndOfDayTimer.GetMarketClose( DateTime.Now ) ); List<DayOfWeek> acceptableDaysOfTheWeekForTheEndOfEachInterval = new List<DayOfWeek>( new DayOfWeek[] { DayOfWeek.Wednesday , DayOfWeek.Thursday , DayOfWeek.Friday } ); TimeSpan maxTimeSpanToLookAhead = TimeSpan.FromDays( 20 ); IIntervalsSelector intervalsSelectorForOutOfSample = new SingleDayIntervalsSelector( this.benchmark , timeForTrading , acceptableDaysOfTheWeekForTheEndOfEachInterval , maxTimeSpanToLookAhead ); // IIntervalsSelector intervalsSelectorForInSample = // new OddIntervalsSelector( 1 , 1 , this.benchmark ); IIntervalsSelector intervalsSelectorForInSample = new SingleDayIntervalsSelector( this.benchmark , timeForTrading , acceptableDaysOfTheWeekForTheEndOfEachInterval , maxTimeSpanToLookAhead ); double minForecastedReturn = 0.01F; IEntryStrategy longAndShortBasedOnAverageExpectedReturn = new EntryStrategyBasedOnForecastedReturn( minForecastedReturn , this.fitnessEvaluator , this.returnIntervalSelectorForSignaling , this.historicalMarketValueProviderForChosingPositionsOutOfSample ); IExitStrategy exitStrategy = new ExitOnIntervalEnd(); IStrategyForBacktester strategyForBacktester = new LinearRegressionStrategy( 7 , inSampleDays , intervalsSelectorForInSample , intervalsSelectorForOutOfSample , eligiblesSelector , // eligible selector for trading tickers // this.eligiblesSelectorForSignalingTickers , this.inSampleChooser , this.historicalMarketValueProviderForInSample , this.historicalMarketValueProviderForChosingPositionsOutOfSample , longAndShortBasedOnAverageExpectedReturn , exitStrategy ); return strategyForBacktester; } #region getEndOfDayStrategyBackTester private Timer getTimer( DateTime firstDateTime , DateTime lastDateTime) { // List< Time > dailyTimes = this.getDailyTimes(); // IndexBasedHistoricalTimer indexBasedTimer = // new IndexBasedHistoricalTimer( // this.benchmark.Ticker , // firstDateTime , lastDateTime , dailyTimes , 60 ); IndexBasedEndOfDayTimer timer = new IndexBasedEndOfDayTimer( firstDateTime , this.benchmark.Ticker ); return timer; } protected override EndOfDayStrategyBackTester getEndOfDayStrategyBackTester() { string backTestId = "LinearRegression"; IAccountProvider accountProvider = new SimpleAccountProvider(); double cashToStart = 30000; DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); firstDateTime = new DateTime( 2003 , 1 , 1 ); firstDateTime = new DateTime( 2004 , 1 , 1 ); DateTime lastDateTime = new DateTime( 2005 , 1 , 1 ); lastDateTime = new DateTime( 2006 , 1 , 1 ); // uncomment the following two lines for a faster script // firstDateTime = new DateTime( 2006 , 1 , 2 ); // lastDateTime = new DateTime( 2006 , 1 , 10 ); double maxRunningHours = 12; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( backTestId , this.getTimer( firstDateTime , lastDateTime ) , this.strategyForBacktester , this.historicalMarketValueProviderForTheBacktesterAccount , accountProvider , firstDateTime , lastDateTime , this.benchmark , cashToStart , maxRunningHours ); return endOfDayStrategyBackTester; } #endregion getEndOfDayStrategyBackTester } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:38:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16931/Strategies Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:38:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ReturnIntervals In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16870/ReturnIntervals Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ReturnIntervals added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:38:08
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16787/Logging Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:37:27
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16503/Genetic Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:37:19
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16440/FitnessEvaluation Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:37:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16351/Decoding Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:37:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16302/InSampleChoosers Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:36:23
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ExitStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16091/ExitStrategies Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/ExitStrategies added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:36:14
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16035/EntryStrategies Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/EntryStrategies added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:36:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15981/eligibles Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/eligibles added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:33:51
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15288/LinearRegression Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression added to the repository |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:29:56
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv13791/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGenerationDebugger.cs Log Message: The code has been changed because now WeightedPositions is a List<WeightedPosition>, while in the previous version they it was a SortedList Index: WFLagGenerationDebugger.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGenerationDebugger.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagGenerationDebugger.cs 28 Oct 2007 18:42:45 -0000 1.1 --- WFLagGenerationDebugger.cs 28 Mar 2010 15:29:48 -0000 1.2 *************** *** 64,77 **** WeightedPositions drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; ! if ( drivingWeightedPositions.ContainsKey( "^OEX" ) && drivingWeightedPositions.GetWeightedPosition( "^OEX" ).IsLong ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsKey( "BDH" ) && drivingWeightedPositions.GetWeightedPosition( "BDH" ).IsShort ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsKey( "HHH" ) && drivingWeightedPositions.GetWeightedPosition( "HHH" ).IsShort ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsKey( "IIH" ) && drivingWeightedPositions.GetWeightedPosition( "IIH" ).IsLong ) optimalPositionsContained++; --- 64,77 ---- WeightedPositions drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; ! if ( drivingWeightedPositions.ContainsTicker( "^OEX" ) && drivingWeightedPositions.GetWeightedPosition( "^OEX" ).IsLong ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsTicker( "BDH" ) && drivingWeightedPositions.GetWeightedPosition( "BDH" ).IsShort ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsTicker( "HHH" ) && drivingWeightedPositions.GetWeightedPosition( "HHH" ).IsShort ) optimalPositionsContained++; ! if ( drivingWeightedPositions.ContainsTicker( "IIH" ) && drivingWeightedPositions.GetWeightedPosition( "IIH" ).IsLong ) optimalPositionsContained++; |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:28:49
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv13153/WalkForwardTesting/WalkForwardLag Modified Files: WFLagEndOfDayTimerHandler.cs Log Message: The code has been changed because now WeightedPositions is a List<WeightedPosition>, while in the previous version they it was a SortedList Index: WFLagEndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagEndOfDayTimerHandler.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** WFLagEndOfDayTimerHandler.cs 29 Sep 2008 21:21:41 -0000 1.10 --- WFLagEndOfDayTimerHandler.cs 28 Mar 2010 15:28:41 -0000 1.11 *************** *** 144,148 **** double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn < 0; --- 144,148 ---- double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn < 0; *************** *** 183,187 **** bool isToReverse = this.isToReverse(); foreach ( WeightedPosition weightedPosition ! in this.wFLagWeightedPositionsChooser.WFLagChosenPositions.PortfolioWeightedPositions.Values ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( weightedPosition , isToReverse ); --- 183,187 ---- bool isToReverse = this.isToReverse(); foreach ( WeightedPosition weightedPosition ! in this.wFLagWeightedPositionsChooser.WFLagChosenPositions.PortfolioWeightedPositions ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( weightedPosition , isToReverse ); *************** *** 197,201 **** double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn; --- 197,201 ---- double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn; |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:28:37
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv13063/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions Modified Files: WFLagDebugPositionsEndOfDayTimerHandler.cs Log Message: The code has been changed because now WeightedPositions is a List<WeightedPosition>, while in the previous version they it was a SortedList Index: WFLagDebugPositionsEndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions/WFLagDebugPositionsEndOfDayTimerHandler.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFLagDebugPositionsEndOfDayTimerHandler.cs 29 Sep 2008 21:20:54 -0000 1.4 --- WFLagDebugPositionsEndOfDayTimerHandler.cs 28 Mar 2010 15:28:28 -0000 1.5 *************** *** 54,58 **** DateTime today = this.account.Timer.GetCurrentDateTime(); foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositions.DrivingWeightedPositions.Values ) todayTotalGain += weightedPosition.GetCloseToCloseDailyReturn( today ); --- 54,58 ---- DateTime today = this.account.Timer.GetCurrentDateTime(); foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositions.DrivingWeightedPositions ) todayTotalGain += weightedPosition.GetCloseToCloseDailyReturn( today ); *************** *** 153,157 **** // this.chosenTickers.SetTickers( this.bestPerformingTickers , this.account ); foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositions.PortfolioWeightedPositions.Values ) this.marketCloseEventHandler_openPosition( weightedPosition ); --- 153,157 ---- // this.chosenTickers.SetTickers( this.bestPerformingTickers , this.account ); foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositions.PortfolioWeightedPositions ) this.marketCloseEventHandler_openPosition( weightedPosition ); |
|
From: Glauco S. <gla...@us...> - 2010-03-28 15:28:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12948/WalkForwardTesting/WalkForwardLag/WFLagDebugger Modified Files: WFLagDebugGenome.cs Log Message: The code has been changed because now WeightedPositions is a List<WeightedPosition>, while in the previous version they it was a SortedList Index: WFLagDebugGenome.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugGenome.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WFLagDebugGenome.cs 28 Oct 2007 19:06:59 -0000 1.5 --- WFLagDebugGenome.cs 28 Mar 2010 15:28:16 -0000 1.6 *************** *** 333,337 **** { ArrayList drivingWeightedPositions = ! new ArrayList( this.wFLagWeightedPositions.DrivingWeightedPositions.Values ); this.dataGridDrivingPositions.DataSource = drivingWeightedPositions; } --- 333,337 ---- { ArrayList drivingWeightedPositions = ! new ArrayList( this.wFLagWeightedPositions.DrivingWeightedPositions ); this.dataGridDrivingPositions.DataSource = drivingWeightedPositions; } *************** *** 339,343 **** { ArrayList portfolioWeightedPositions = ! new ArrayList( this.wFLagWeightedPositions.PortfolioWeightedPositions.Values ); this.dataGridPortfolioPositions.DataSource = portfolioWeightedPositions; } --- 339,343 ---- { ArrayList portfolioWeightedPositions = ! new ArrayList( this.wFLagWeightedPositions.PortfolioWeightedPositions ); this.dataGridPortfolioPositions.DataSource = portfolioWeightedPositions; } |