[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDeb
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2006-07-22 20:45:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5450/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger Modified Files: WFLagChosenPositionsDebugInfo.cs Log Message: The following additional information are available now (as public properties, displayed into the debug DataGrid): - InSampleExpectancyScore (self explaining) - MaxPreSampleDays (the max number of days for which the genome can be tested pre sample) - PreSampleMaxSharpeRatio (the sharpe ratio for the MaxPreSampleDays pre sample) - PreSample30SharpeRatio (the sharpe ratio for 150 days pre sample) - PreSample150SharpeRatio (the sharpe ratio for 150 days pre sample) - PostSample30SharpeRatio (the sharpe ratio for 30 days post sample) - PostSample150SharpeRatio (the sharpe ratio for 150 post sample) Furthermore, some methods have been added: - the new static method GetDrivingAndPortfolioTickers( WFLagChosenPositions wFLagChosenPositions ) - the new method GetChosenPositions Index: WFLagChosenPositionsDebugInfo.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomesDebugger/WFLagChosenPositionsDebugInfo.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFLagChosenPositionsDebugInfo.cs 29 Jun 2006 17:46:49 -0000 1.2 --- WFLagChosenPositionsDebugInfo.cs 22 Jul 2006 20:45:14 -0000 1.3 *************** *** 22,25 **** --- 22,28 ---- using System; + using System.Collections; + + using QuantProject.Business.Strategies; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WFLagDebugger *************** *** 30,38 **** --- 33,47 ---- public class WFLagChosenPositionsDebugInfo { + private double dummyValue; + private int maxPreSampleDays; private WFLagChosenPositions wFLagChosenPositions; private WFLagLog wFLagLog; private double inSampleSharpeRatio; private double preSampleSharpeRatio30; + private double preSampleSharpeRatio150; + private double preSampleMaxSharpeRatio; private double postSampleSharpeRatio30; + private double postSampleSharpeRatio150; + private double inSampleExpectancyScore; public string DrivingPositions *************** *** 56,67 **** get { return this.inSampleSharpeRatio; } } ! public double PreSampleSharpeRatio30 { get { return this.preSampleSharpeRatio30; } } ! public double PostSampleSharpeRatio30 { get { return this.postSampleSharpeRatio30; } } public WFLagChosenPositionsDebugInfo( WFLagChosenPositions wFLagChosenPositions , --- 65,101 ---- get { return this.inSampleSharpeRatio; } } ! public double InSampleExpectancyScore ! { ! get { return this.inSampleExpectancyScore; } ! } ! public int MaxPreSampleDays ! { ! get ! { ! if ( this.maxPreSampleDays == int.MinValue ) ! this.setMaxPreSampleDays(); ! return this.maxPreSampleDays; ! } ! } ! public double PreSample30SharpeRatio { get { return this.preSampleSharpeRatio30; } } ! public double PreSampleMaxSharpeRatio ! { ! get { return this.preSampleMaxSharpeRatio; } ! } ! public double PreSample150SharpeRatio ! { ! get { return this.preSampleSharpeRatio150; } ! } ! public double PostSample30SharpeRatio { get { return this.postSampleSharpeRatio30; } } + public double PostSample150SharpeRatio + { + get { return this.postSampleSharpeRatio150; } + } public WFLagChosenPositionsDebugInfo( WFLagChosenPositions wFLagChosenPositions , *************** *** 71,79 **** --- 105,172 ---- // TODO: Add constructor logic here // + this.dummyValue = -999; + this.wFLagChosenPositions = wFLagChosenPositions; this.wFLagLog = wFLagLog; this.inSampleSharpeRatio = this.getInSampleSharpeRatio(); + this.inSampleExpectancyScore = this.getInSampleExpectancyScore(); + this.setMaxPreSampleDays(); this.preSampleSharpeRatio30 = this.getPreSampleSharpeRatio( 30 ); + this.preSampleSharpeRatio150 = this.getPreSampleSharpeRatio( 150 ); + this.preSampleMaxSharpeRatio = this.getPreSampleSharpeRatio( + this.MaxPreSampleDays ); this.postSampleSharpeRatio30 = this.getPostSampleSharpeRatio( 30 ); + this.postSampleSharpeRatio150 = this.getPostSampleSharpeRatio( 150 ); + } + public static string[] GetDrivingAndPortfolioTickers( + WFLagChosenPositions wFLagChosenPositions ) + { + int size = wFLagChosenPositions.DrivingPositions.Count + + wFLagChosenPositions.PortfolioPositions.Count; + string[] drivingAndPortfolioTickers = new string[ size ]; + int i = 0; + foreach ( string signedTicker in wFLagChosenPositions.DrivingPositions.Keys ) + { + drivingAndPortfolioTickers[ i ] = SignedTicker.GetTicker( signedTicker ); + i++; + } + foreach ( string signedTicker in wFLagChosenPositions.PortfolioPositions.Keys ) + { + drivingAndPortfolioTickers[ i ] = SignedTicker.GetTicker( signedTicker ); + i++; + } + return drivingAndPortfolioTickers; + } + /// <summary> + /// returns the chosen positions. A method is used instead of a property, because + /// we don't want this as a column displayed in the grid + /// </summary> + public WFLagChosenPositions GetChosenPositions() + { + return this.wFLagChosenPositions; + } + private ArrayList getMinDatesForTickers() + { + string[] tickers = GetDrivingAndPortfolioTickers( this.wFLagChosenPositions ); + ArrayList minDatesForTickers = new ArrayList(); + foreach ( string ticker in tickers ) + minDatesForTickers.Add( + QuantProject.Data.DataTables.Quotes.GetFirstQuoteDate( ticker ) ); + return minDatesForTickers; + } + private DateTime getFirstCommonDateForTickers() + { + ArrayList minDatesForTickers = + this.getMinDatesForTickers(); + minDatesForTickers.Sort(); + return (DateTime)minDatesForTickers[ minDatesForTickers.Count - 1 ]; + } + private void setMaxPreSampleDays() + { + DateTime firstCommonDateForTickers = + this.getFirstCommonDateForTickers(); + TimeSpan timeSpan = this.getInSampleFirstDate() - + firstCommonDateForTickers; + this.maxPreSampleDays = timeSpan.Days - 1; // I subtract one, so I have the number of daily returns } private DateTime getInSampleFirstDate() *************** *** 90,100 **** this.LastOptimization ); } ! private double getPreSampleSharpeRatio( int days ) { ! DateTime lastDateTime = this.getInSampleFirstDate(); ! DateTime firstDateTime = lastDateTime.AddDays( -days - 1 ); // I subtract one more day, so I have days daily returns ! return WFLagSharpeRatioComputer.GetSharpeRatio( this.wFLagChosenPositions , firstDateTime , ! lastDateTime ); } private double getPostSampleSharpeRatio( int days ) --- 183,205 ---- this.LastOptimization ); } ! private double getInSampleExpectancyScore() { ! DateTime firstDateTime = this.getInSampleFirstDate(); ! return WFLagSharpeRatioComputer.GetExpectancyScore( this.wFLagChosenPositions , firstDateTime , ! this.LastOptimization ); ! } ! private double getPreSampleSharpeRatio( int days ) ! { ! double preSampleSharpeRatio = this.dummyValue; ! if ( this.MaxPreSampleDays >= days ) ! { ! DateTime lastDateTime = this.getInSampleFirstDate(); ! DateTime firstDateTime = lastDateTime.AddDays( -days - 1 ); // I subtract one more day, so I have days daily returns ! preSampleSharpeRatio = WFLagSharpeRatioComputer.GetSharpeRatio( ! this.wFLagChosenPositions , firstDateTime , ! lastDateTime ); ! } ! return preSampleSharpeRatio; } private double getPostSampleSharpeRatio( int days ) |