[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag WFLagEndOfDayT
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2007-02-18 01:34:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11381/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagEndOfDayTimerHandler.cs Log Message: Better OO approach now: an IWFLagWeightedPositionChooser interface has been introduced. Now it will be easier to move both from a strategy to another, and from an optimization technique to another Index: WFLagEndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagEndOfDayTimerHandler.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WFLagEndOfDayTimerHandler.cs 3 Nov 2006 16:38:47 -0000 1.6 --- WFLagEndOfDayTimerHandler.cs 18 Feb 2007 01:00:11 -0000 1.7 *************** *** 36,41 **** namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { ! public delegate void NewChosenTickersEventHandler( ! Object sender , WFLagNewChosenTickersEventArgs eventArgs ); /// <summary> --- 36,41 ---- namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardLag { ! public delegate void NewChosenPositionsEventHandler( ! Object sender , WFLagNewChosenPositionsEventArgs eventArgs ); /// <summary> *************** *** 49,63 **** private string benchmark; private int numberEligibleTickers; ! private int numberOfPositionsToBeChosen; ! private int numberOfDrivingPositions; ! private int inSampleWindowDays; private int outOfSampleWindowDays; private Account account; ! private int generationNumberForGeneticOptimizer; ! private int populationSizeForGeneticOptimizer; ! private IEquityEvaluator equityEvaluator; private WFLagEligibleTickers eligibleTickers; ! private WFLagChosenTickers chosenTickers; private HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider; --- 49,59 ---- private string benchmark; private int numberEligibleTickers; ! IWFLagWeightedPositionsChooser wFLagWeightedPositionsChooser; private int outOfSampleWindowDays; private Account account; ! // private IEquityEvaluator equityEvaluator; private WFLagEligibleTickers eligibleTickers; ! // private WFLagChosenTickers chosenTickers; private HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider; *************** *** 67,71 **** public event InSampleNewProgressEventHandler InSampleNewProgress; ! public event NewChosenTickersEventHandler NewChosenTickers; public WFLagEndOfDayTimerHandler( --- 63,67 ---- public event InSampleNewProgressEventHandler InSampleNewProgress; ! public event NewChosenPositionsEventHandler NewChosenPositions; public WFLagEndOfDayTimerHandler( *************** *** 73,97 **** string benchmark , int numberEligibleTickers , ! int numberOfPositionsToBeChosen , ! int numberOfDrivingPositions , ! int inSampleWindowDays , int outOfSampleWindowDays , ! Account account , ! int generationNumberForGeneticOptimizer , ! int populationSizeForGeneticOptimizer , ! IEquityEvaluator equityEvaluator ) { this.tickerGroupID = tickerGroupID; this.benchmark = benchmark; this.numberEligibleTickers = numberEligibleTickers; ! this.numberOfPositionsToBeChosen = numberOfPositionsToBeChosen; ! this.numberOfDrivingPositions = numberOfDrivingPositions; ! this.inSampleWindowDays = inSampleWindowDays; this.outOfSampleWindowDays = outOfSampleWindowDays; this.account = account; - this.generationNumberForGeneticOptimizer = - generationNumberForGeneticOptimizer; - this.populationSizeForGeneticOptimizer = - populationSizeForGeneticOptimizer; - this.equityEvaluator = equityEvaluator; this.eligibleTickers = new WFLagEligibleTickers( --- 69,82 ---- string benchmark , int numberEligibleTickers , ! IWFLagWeightedPositionsChooser wFLagWeightedPositionsChooser , ! int outOfSampleWindowDays , ! Account account ) { this.tickerGroupID = tickerGroupID; this.benchmark = benchmark; this.numberEligibleTickers = numberEligibleTickers; ! this.wFLagWeightedPositionsChooser = wFLagWeightedPositionsChooser; this.outOfSampleWindowDays = outOfSampleWindowDays; this.account = account; this.eligibleTickers = new WFLagEligibleTickers( *************** *** 99,114 **** this.benchmark , this.numberEligibleTickers , ! this.inSampleWindowDays , this.account.EndOfDayTimer ); ! this.chosenTickers = new WFLagChosenTickers( ! this.numberOfDrivingPositions , ! this.numberOfPositionsToBeChosen , ! this.inSampleWindowDays , ! this.account.EndOfDayTimer , ! this.generationNumberForGeneticOptimizer , ! this.populationSizeForGeneticOptimizer , ! this.equityEvaluator ); ! this.chosenTickers.NewProgress += new NewProgressEventHandler( this.bestPerformingNewProgress ); --- 84,93 ---- this.benchmark , this.numberEligibleTickers , ! this.wFLagWeightedPositionsChooser.NumberDaysForInSampleOptimization , this.account.EndOfDayTimer ); ! // this.chosenTickers = new WFLagChosenTickers( ! // this.wFLagWeightedPositionsChooser ); ! this.wFLagWeightedPositionsChooser.NewProgress += new NewProgressEventHandler( this.bestPerformingNewProgress ); *************** *** 177,181 **** double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.chosenTickers.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn < 0; --- 156,160 ---- double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn < 0; *************** *** 207,211 **** weightedPosition , isToReverse ); double maxPositionValue = this.account.GetMarketValue() / ! this.numberOfPositionsToBeChosen; long sharesToBeTraded = this.getMaxBuyableShares( weightedPosition ); this.account.AddOrder( new Order( orderType , --- 186,190 ---- weightedPosition , isToReverse ); double maxPositionValue = this.account.GetMarketValue() / ! this.wFLagWeightedPositionsChooser.NumberOfPortfolioPositions; long sharesToBeTraded = this.getMaxBuyableShares( weightedPosition ); this.account.AddOrder( new Order( orderType , *************** *** 216,220 **** bool isToReverse = this.isToReverse(); foreach ( WeightedPosition weightedPosition ! in this.chosenTickers.PortfolioWeightedPositions.Values ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( weightedPosition , isToReverse ); --- 195,199 ---- bool isToReverse = this.isToReverse(); foreach ( WeightedPosition weightedPosition ! in this.wFLagWeightedPositionsChooser.WFLagChosenPositions.PortfolioWeightedPositions.Values ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( weightedPosition , isToReverse ); *************** *** 223,227 **** private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { ! if ( this.chosenTickers.DrivingWeightedPositions != null ) this.fiveMinutesBeforeMarketCloseEventHandler_openPositions_actually(); } --- 202,206 ---- private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { ! if ( this.wFLagWeightedPositionsChooser.WFLagChosenPositions != null ) this.fiveMinutesBeforeMarketCloseEventHandler_openPositions_actually(); } *************** *** 230,234 **** double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.chosenTickers.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn; --- 209,213 ---- double totalReturn = 0; foreach ( WeightedPosition weightedPosition in ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions.DrivingWeightedPositions.Values ) totalReturn += this.getTodayReturn( weightedPosition ); return totalReturn; *************** *** 317,321 **** private WeightedPosition getWeightedPosition( string ticker ) { ! return this.chosenTickers.PortfolioWeightedPositions.GetWeightedPosition( ticker ); } --- 296,300 ---- private WeightedPosition getWeightedPosition( string ticker ) { ! return this.wFLagWeightedPositionsChooser.WFLagChosenPositions.PortfolioWeightedPositions.GetWeightedPosition( ticker ); } *************** *** 398,405 **** // Console.WriteLine( "Number of Eligible tickers: " + // this.eligibleTickers.EligibleTickers.Rows.Count ); ! this.chosenTickers.SetWeightedPositions( this.eligibleTickers ); this.arePositionsUpToDateWithChosenTickers = false; ! this.NewChosenTickers( this , ! new WFLagNewChosenTickersEventArgs( this.chosenTickers ) ); this.lastOptimizationDate = this.now().DateTime; } --- 377,390 ---- // Console.WriteLine( "Number of Eligible tickers: " + // this.eligibleTickers.EligibleTickers.Rows.Count ); ! // this.chosenTickers.SetWeightedPositions( this.eligibleTickers , ! // this.account.EndOfDayTimer.GetCurrentTime() ); ! this.wFLagWeightedPositionsChooser.ChosePositions( ! this.eligibleTickers , ! this.eligibleTickers , ! this.account.EndOfDayTimer.GetCurrentTime() ); this.arePositionsUpToDateWithChosenTickers = false; ! this.NewChosenPositions( this , ! new WFLagNewChosenPositionsEventArgs( ! this.wFLagWeightedPositionsChooser.WFLagChosenPositions ) ); this.lastOptimizationDate = this.now().DateTime; } |