[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/Drive
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider In directory vz-cvs-3.sog:/tmp/cvs-serv21606/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider Modified Files: DrivenByFVProviderLogItem.cs DrivenByFVProviderMain.cs DrivenByFVProviderStrategy.cs Log Message: Updated script files Index: DrivenByFVProviderStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/DrivenByFVProviderStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DrivenByFVProviderStrategy.cs 16 Jan 2011 19:35:50 -0000 1.1 --- DrivenByFVProviderStrategy.cs 21 Aug 2011 14:21:05 -0000 1.2 *************** *** 22,59 **** using System; using System.Data; - using System.Collections; - using System.Collections.Generic; using System.IO; - using QuantProject.ADT; - using QuantProject.ADT.Statistics; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; ! using QuantProject.ADT.Timing; using QuantProject.Business.Financial.Accounting; - using QuantProject.Business.Financial.Instruments; - using QuantProject.Business.Financial.Ordering; - using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.InSample; - using QuantProject.Business.Strategies.InSample.InSampleFitnessDistributionEstimation; - using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.ReturnsManagement; - //using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors using QuantProject.Business.Strategies.ReturnsManagement.Time; ! using QuantProject.Business.DataProviders; ! using QuantProject.Business.Strategies.TickersRelationships; ! using QuantProject.Business.Strategies.Eligibles; ! using QuantProject.Business.Strategies.Optimizing.Decoding; ! using QuantProject.Data; ! using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; ! using QuantProject.Data.DataTables; ! using QuantProject.ADT.Optimizing.Genetic; ! using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; ! using QuantProject.Scripts.TickerSelectionTesting.OTC; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; - using QuantProject.Scripts.WalkForwardTesting.LinearCombination; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider --- 22,40 ---- using System; using System.Data; using System.IO; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; ! using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Strategies; + using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; + using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; ! using QuantProject.Business.Timing; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider *************** *** 68,73 **** public event NewLogItemEventHandler NewLogItem; public event NewMessageEventHandler NewMessage; ! ! protected int numDaysForFundamentalAnalysis; protected int inSamplePeriodLengthInDays; protected int numDaysBetweenEachOptimization; --- 49,56 ---- public event NewLogItemEventHandler NewLogItem; public event NewMessageEventHandler NewMessage; ! ! protected int numDaysForFundamentalDataAvailability; ! // protected int numDaysForFundamentalAnalysis; ! protected int numOfMaximumConsecutiveDaysWithSomeMissingQuotes; protected int inSamplePeriodLengthInDays; protected int numDaysBetweenEachOptimization; *************** *** 83,86 **** --- 66,70 ---- protected ReturnsManager returnsManager; protected TestingPositions[] chosenPositions; + protected TestingPositions positionsToOpen; //chosen in sample by the chooser or passed //directly by the user using a form: *************** *** 111,114 **** --- 95,100 ---- //the portfolio is sold, no matter what the current value //of percentageOfTheoreticalProfit is + protected string hedgingTicker; + protected double hedgingTickerWeight = 0.0; private string description_GetDescriptionForChooser() *************** *** 140,154 **** public DrivenByFVProviderStrategy(IEligiblesSelector eligiblesSelector , int minNumOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser , ! int numDaysForFundamentalAnalysis , int numDaysForPortfolioVolatilityAnalysis , Benchmark benchmark , int numDaysBetweenEachOptimization , HistoricalMarketValueProvider historicalMarketValueProviderForInSample , HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample , PortfolioType portfolioType, double stopLoss, double percentageOfTheoreticalProfit, ! double takeProfitLevelInAnyCase) { this.eligiblesSelector = eligiblesSelector; this.minimumNumberOfEligiblesForValidOptimization = minNumOfEligiblesForValidOptimization; this.inSampleChooser = inSampleChooser; ! this.numDaysForFundamentalAnalysis = numDaysForFundamentalAnalysis; this.inSamplePeriodLengthInDays = numDaysForPortfolioVolatilityAnalysis; this.benchmark = benchmark; --- 126,142 ---- public DrivenByFVProviderStrategy(IEligiblesSelector eligiblesSelector , int minNumOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser , ! int numDaysForFundamentalDataAvailability, int numDaysForPortfolioVolatilityAnalysis , Benchmark benchmark , int numDaysBetweenEachOptimization , HistoricalMarketValueProvider historicalMarketValueProviderForInSample , HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample , PortfolioType portfolioType, double stopLoss, double percentageOfTheoreticalProfit, ! double takeProfitLevelInAnyCase, ! string hedgingTicker, double hedgingTickerWeight) { this.eligiblesSelector = eligiblesSelector; this.minimumNumberOfEligiblesForValidOptimization = minNumOfEligiblesForValidOptimization; this.inSampleChooser = inSampleChooser; ! this.numDaysForFundamentalDataAvailability = numDaysForFundamentalDataAvailability; ! // this.numDaysForFundamentalAnalysis = numDaysForFundamentalAnalysis; this.inSamplePeriodLengthInDays = numDaysForPortfolioVolatilityAnalysis; this.benchmark = benchmark; *************** *** 160,163 **** --- 148,193 ---- this.percentageOfTheoreticalProfit = percentageOfTheoreticalProfit; this.takeProfitLevelInAnyCase = takeProfitLevelInAnyCase; + this.numOfMaximumConsecutiveDaysWithSomeMissingQuotes = 10; + this.hedgingTicker = hedgingTicker; + this.hedgingTickerWeight = hedgingTickerWeight; + } + + private bool someTickersHaveNotBeenTradedForTooManyDays(DateTime dateTime, + string[] tickers) + { + bool returnValue = false; + DateTime firstDateToCheck = + dateTime.AddDays(-this.numOfMaximumConsecutiveDaysWithSomeMissingQuotes); + DateTime currentDateToCheck; + double currentQuote; + for( int i = 0; i < tickers.Length; i++ ) + { + if(returnValue == true) + return returnValue; + else + returnValue = true; + for(int idxDay = 0; + idxDay < this.numOfMaximumConsecutiveDaysWithSomeMissingQuotes; + idxDay++) + { + currentDateToCheck = firstDateToCheck.AddDays(idxDay); + currentQuote = double.MinValue; + try{ + currentQuote = + QuantProject.DataAccess.Tables.Quotes.GetAdjustedClose( tickers[i], currentDateToCheck ); + } + catch(Exception ex){ + string forBreakpoint = ex.Message; + forBreakpoint = forBreakpoint + ""; + } + if( currentQuote != double.MinValue ) + { + returnValue = false; + idxDay = this.numOfMaximumConsecutiveDaysWithSomeMissingQuotes; + } + } + } + + return returnValue; } *************** *** 184,187 **** --- 214,244 ---- } + private bool allTickersHaveAtLeastOneQuoteInTheLastPeriod(DateTime lastPeriodDay, + int periodLengthInDays, + string[] tickers) + { + bool returnValue = true; + int currentNumberOfQuotes; + DateTime firstPeriodDay = lastPeriodDay.AddDays(-periodLengthInDays); + try{ + for( int i = 0; i < tickers.Length; i++ ) + { + currentNumberOfQuotes = + QuantProject.DataAccess.Tables.Quotes.GetNumberOfDaysWithQuotes(tickers[i], firstPeriodDay, lastPeriodDay); + if( currentNumberOfQuotes == 0 ) + { + returnValue = false; + i = tickers.Length; //exit from for + } + } + } + catch(Exception ex){ + string forBreakpoint = ex.Message; + forBreakpoint = forBreakpoint + ""; + returnValue = false; + } + return returnValue; + } + #region newDateTimeEventHandler_closePositions *************** *** 189,193 **** { DateTime currentDateTime = this.now(); ! if( allTickersAreExchanged( currentDateTime, AccountManager.GetTickersInOpenedPositions(this.account) ) ) { AccountManager.ClosePositions( this.account ); --- 246,250 ---- { DateTime currentDateTime = this.now(); ! if( allTickersHaveAtLeastOneQuoteInTheLastPeriod( currentDateTime, 180, AccountManager.GetTickersInOpenedPositions(this.account) ) ) { AccountManager.ClosePositions( this.account ); *************** *** 198,212 **** #region newDateTimeEventHandler_openPositions ! private void newDateTimeEventHandler_openPositions() { ! if( this.chosenPositions != null && ! this.allTickersAreExchanged( this.now(), this.chosenPositions[0].WeightedPositions.SignedTickers.Tickers) ! ) { try { ! AccountManager.OpenPositions( this.chosenPositions[0].WeightedPositions, ! this.account ); this.lastEntryTime = this.now(); this.previousAccountValue = this.account.GetMarketValue(); --- 255,325 ---- #region newDateTimeEventHandler_openPositions ! ! private WeightedPositions newDateTimeEventHandler_openPositions_getPositions() ! { ! WeightedPositions returnValue = ! new WeightedPositions(this.positionsToOpen.WeightedPositions.SignedTickers); ! returnValue.Clear(); ! for(int i = 0; ! i < this.positionsToOpen.WeightedPositions.Count; ! i++) ! { ! if(this.portfolioType == PortfolioType.ShortAndLong) ! returnValue.Add(this.positionsToOpen.WeightedPositions[i]); ! else if( this.positionsToOpen.WeightedPositions[i].IsLong && ! this.portfolioType == PortfolioType.OnlyLong ) ! returnValue.Add(this.positionsToOpen.WeightedPositions[i]); ! else if( this.positionsToOpen.WeightedPositions[i].IsShort && ! this.portfolioType == PortfolioType.OnlyShort ) ! returnValue.Add(this.positionsToOpen.WeightedPositions[i]); ! } ! return returnValue; ! } ! ! private TestingPositions newDateTimeEventHandler_openPositions_setPositionsToOpen_addHedging(int currentIdxOfTestingPosition) ! { ! TestingPositions returnValue = this.chosenPositions[currentIdxOfTestingPosition].Copy(); ! returnValue.AddWeightedPosition(new WeightedPosition( ! this.hedgingTickerWeight, this.hedgingTicker)); ! ! return returnValue; ! } ! ! private void newDateTimeEventHandler_openPositions_setPositionsToOpen() ! { ! if( this.chosenPositions != null ) ! { ! //the first positions with all tickers exchanged are set ! for(int i = 0; i < this.chosenPositions.Length; i++) ! { ! if(this.allTickersAreExchanged( this.now(), this.chosenPositions[i].WeightedPositions.SignedTickers.Tickers)) ! { ! if( this.hedgingTicker != null && ! this.historicalMarketValueProviderForOutOfSample.WasExchanged( this.hedgingTicker, this.now() ) ) ! { ! this.positionsToOpen = ! this.newDateTimeEventHandler_openPositions_setPositionsToOpen_addHedging( i ); ! i = this.chosenPositions.Length; ! } ! else // no hedging ticker provided or hedging ticker not exchanged ! { ! this.positionsToOpen = this.chosenPositions[i]; ! i = this.chosenPositions.Length; ! } ! } ! } ! } ! } ! private void newDateTimeEventHandler_openPositions() { ! this.newDateTimeEventHandler_openPositions_setPositionsToOpen(); ! if( this.positionsToOpen != null ) { try { ! WeightedPositions weightedPositionsToOpen = ! this.newDateTimeEventHandler_openPositions_getPositions(); ! AccountManager.OpenPositions( weightedPositionsToOpen, this.account ); this.lastEntryTime = this.now(); this.previousAccountValue = this.account.GetMarketValue(); *************** *** 256,271 **** Object sender , DateTime dateTime ) { ! this.newDateTimeEventHandler_updateStopLossAndTakeProfitConditions(); ! bool timeToProfitOrToStopLoss = this.takeProfitConditionReached || ! this.stopLossConditionReached; ! ! if( this.account.Portfolio.Count == 0 ) ! this.newDateTimeEventHandler_openPositions(); ! if( (this.account.Portfolio.Count > 0 && timeToProfitOrToStopLoss) || ! this.optimalTestingPositionsAreToBeUpdated() ) ! this.newDateTimeEventHandler_closePositions(); ! ! this.newDateTimeEventHandler_updateTestingPositions( dateTime ); } --- 369,389 ---- Object sender , DateTime dateTime ) { ! if(HistoricalEndOfDayTimer.IsMarketClose( dateTime ) || ! HistoricalEndOfDayTimer.IsMarketOpen( dateTime ) ) ! { ! this.newDateTimeEventHandler_updateStopLossAndTakeProfitConditions(); ! bool timeToProfitOrToStopLoss = this.takeProfitConditionReached || ! this.stopLossConditionReached; ! ! if( this.account.Portfolio.Count == 0 ) ! this.newDateTimeEventHandler_openPositions(); ! ! if( (this.account.Portfolio.Count > 0 && timeToProfitOrToStopLoss) || ! this.optimalTestingPositionsAreToBeUpdated() || ! this.someTickersHaveNotBeenTradedForTooManyDays(this.now(), AccountManager.GetTickersInOpenedPositions(this.account) ) ) ! this.newDateTimeEventHandler_closePositions(); ! this.newDateTimeEventHandler_updateTestingPositions( dateTime ); ! } } *************** *** 280,284 **** w.WriteLine ("\n----------------------------------------------\r\n"); w.Write("\r\nPositions for PositionsForDrivenByFVProviderStrategy on date: {0}\r", today.ToLongDateString() ); - w.Write("\r\nNum days for fundamental analysis {0}\r", this.numDaysForFundamentalAnalysis.ToString()); w.Write("\r\nNum days for portofolio analysis for volatility {0}\r", this.inSamplePeriodLengthInDays.ToString()); w.Write("\r\nEligibles: {0}\r", eligibles.Count.ToString() ); --- 398,401 ---- *************** *** 335,346 **** protected void updateTestingPositions(DateTime currentDateTime) { ! History historyForEligiblesSelector = ! this.benchmark.GetEndOfDayHistory( ! HistoricalEndOfDayTimer.GetMarketClose( ! currentDateTime.AddDays( -this.numDaysForFundamentalAnalysis ) ) , ! HistoricalEndOfDayTimer.GetMarketClose( ! currentDateTime.AddDays(-1) ) ); ! History historyForReturnsManager = this.benchmark.GetEndOfDayHistory( HistoricalEndOfDayTimer.GetMarketClose( --- 452,463 ---- protected void updateTestingPositions(DateTime currentDateTime) { ! // History historyForEligiblesSelector = ! // this.benchmark.GetEndOfDayHistory( ! // HistoricalEndOfDayTimer.GetMarketClose( ! // currentDateTime.AddDays( -this.numDaysForFundamentalAnalysis ) ) , ! // HistoricalEndOfDayTimer.GetMarketClose( ! // currentDateTime.AddDays(-1) ) ); ! History history = this.benchmark.GetEndOfDayHistory( HistoricalEndOfDayTimer.GetMarketClose( *************** *** 350,357 **** this.currentEligibles = ! this.eligiblesSelector.GetEligibleTickers(historyForEligiblesSelector); ! this.updateReturnsManager(historyForReturnsManager.FirstDateTime, ! historyForReturnsManager.LastDateTime); if( ( this.eligiblesSelector is DummyEligibleSelector && --- 467,474 ---- this.currentEligibles = ! this.eligiblesSelector.GetEligibleTickers(history); ! this.updateReturnsManager(history.FirstDateTime, ! history.LastDateTime); if( ( this.eligiblesSelector is DummyEligibleSelector && *************** *** 384,388 **** DateTime dateTime ) { ! if ( this.optimalTestingPositionsAreToBeUpdated() ) { this.chosenPositions = null; --- 501,506 ---- DateTime dateTime ) { ! if ( this.account.Portfolio.Count == 0 || ! this.optimalTestingPositionsAreToBeUpdated() ) { this.chosenPositions = null; *************** *** 416,421 **** { DrivenByFVProviderLogItem logItem = ! new DrivenByFVProviderLogItem( this.now(), this.numDaysForFundamentalAnalysis, ! this.inSamplePeriodLengthInDays); logItem.BestPositionsInSample = this.chosenPositions; --- 534,541 ---- { DrivenByFVProviderLogItem logItem = ! new DrivenByFVProviderLogItem( this.now(), ! this.inSamplePeriodLengthInDays, ! this.historicalMarketValueProviderForInSample, ! this.benchmark); logItem.BestPositionsInSample = this.chosenPositions; Index: DrivenByFVProviderMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/DrivenByFVProviderMain.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DrivenByFVProviderMain.cs 17 Jan 2011 23:03:51 -0000 1.2 --- DrivenByFVProviderMain.cs 21 Aug 2011 14:21:05 -0000 1.3 *************** *** 22,59 **** using System; - using System.Collections; - using System.Collections.Generic; using System.IO; - - using QuantProject.ADT; - using QuantProject.ADT.Statistics.Combinatorial; - using QuantProject.ADT.FileManaging; using QuantProject.ADT.Timing; using QuantProject.Business.DataProviders; - //using QuantProject.Data.DataProviders.Bars.Caching; - using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Financial.Fundamentals.FairValueProviders; using QuantProject.Business.Financial.Fundamentals.RatioProviders; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.InSample; - using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.Optimizing.Decoding; - using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; ! using QuantProject.Business.Strategies.ReturnsManagement; ! using QuantProject.Business.Strategies.ReturnsManagement.Time; ! using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; ! using QuantProject.Presentation; using QuantProject.Scripts.General; - using QuantProject.Scripts.General.Logging; - using QuantProject.Scripts.General.Reporting; - using QuantProject.Scripts.General.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider.InSampleChoosers.Genetic; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! //using QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.Genetic; ! //using QuantProject.Scripts.TickerSelectionTesting.OTC.InSampleChoosers.BruteForce; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider --- 22,46 ---- using System; using System.IO; using QuantProject.ADT.Timing; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting.AccountProviding; + using QuantProject.Business.Financial.Fundamentals; using QuantProject.Business.Financial.Fundamentals.FairValueProviders; + using QuantProject.Business.Financial.Fundamentals.FairValueProviders.LinearRegression; using QuantProject.Business.Financial.Fundamentals.RatioProviders; + using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; ! using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Timing; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.General; using QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider.InSampleChoosers.Genetic; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! using QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider.InSampleChoosers; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider *************** *** 64,67 **** --- 51,55 ---- /// be done /// </summary> + [Serializable] public class DrivenByFVProviderMain : BasicScriptForBacktesting { *************** *** 73,79 **** private int maxNumberOfEligiblesToBeChosen; private IFairValueProvider fairValueProvider; - private int numDaysForFundamentalAnalysis; private int numDaysForPortfolioVolatilityAnalysis; private int numDaysForFundamentalDataAvailability; private Benchmark benchmark; private DateTime firstDateTime; --- 61,67 ---- private int maxNumberOfEligiblesToBeChosen; private IFairValueProvider fairValueProvider; private int numDaysForPortfolioVolatilityAnalysis; private int numDaysForFundamentalDataAvailability; + private string tickersGroupId; private Benchmark benchmark; private DateTime firstDateTime; *************** *** 83,98 **** private HistoricalMarketValueProvider historicalMarketValueProviderForTheBackTester; private Timer timerForBackTester; ! private GenomeManagerType genomeManagerType; #region main public DrivenByFVProviderMain() { ! this.numberOfPortfolioPositions = 4; this.benchmark = new Benchmark( "^GSPC" ); ! this.portfolioType = PortfolioType.OnlyLong;//filter for out of sample ! this.genomeManagerType = GenomeManagerType.OnlyLong;//filter for the genetic chooser // this.benchmark = new Benchmark( "ENI.MI" ); ! this.firstDateTime = new DateTime( 2002 , 4 , 1 ); ! this.lastDateTime = new DateTime( 2009 , 3, 31 ); this.historicalMarketValueProviderForInSample = --- 71,125 ---- private HistoricalMarketValueProvider historicalMarketValueProviderForTheBackTester; private Timer timerForBackTester; ! // private GenomeManagerType genomeManagerType; ! private ITickerSelectorByDate tickerSelectorByDate; ! private bool temporizedGroup; ! // private int numDayForAveragePriceComputation; ! private string hedgingTicker; ! private double hedgingTickerWeight; #region main public DrivenByFVProviderMain() { ! this.numberOfPortfolioPositions = 6; ! this.hedgingTicker = "SH"; ! // this.hedgingTicker ="MYY"; ! // this.hedgingTicker = null; ! this.hedgingTickerWeight = 0.5; this.benchmark = new Benchmark( "^GSPC" ); ! // this.benchmark = new Benchmark( "FTSEMIB.MI" ); ! this.tickersGroupId = "SP500"; ! // this.tickersGroupId = "ticUSFin"; ! // this.tickersGroupId = "STOCKMI"; ! this.temporizedGroup = true; ! this.numDaysForPortfolioVolatilityAnalysis = 90; ! this.maxNumberOfEligiblesToBeChosen = 500; ! // int numOfTopRowsToDelete = 500; ! // this.numDayForAveragePriceComputation = 10; ! // double minPriceForTickersToBeSelected = 0.5; ! // string benchmarkForCorrelation = "C"; //citigroup ! int numOfDaysForCorrelation = this.numDaysForPortfolioVolatilityAnalysis; ! this.tickerSelectorByDate = ! // new SelectorByGroupLiquidityAndPrice(this.tickersGroupId, temporizedGroup, ! // false, this.numDaysForPortfolioVolatilityAnalysis, ! // this.maxNumberOfEligiblesToBeChosen, ! // numOfTopRowsToDelete, ! // numDayForAveragePriceComputation, ! // minPriceForTickersToBeSelected); ! new SelectorByGroup(this.tickersGroupId, temporizedGroup); ! // new SelectorByCloseToCloseCorrelationToBenchmark( ! // new SelectorByGroupLiquidityAndPrice(this.tickersGroupId, temporizedGroup, ! // false, numOfDaysForCorrelation, ! // 3000, numDayForAveragePriceComputation, ! // minPriceForTickersToBeSelected), ! // new SelectorByGroup(this.tickersGroupId, temporizedGroup), ! // numOfDaysForCorrelation, ! // benchmarkForCorrelation, false, ! // this.maxNumberOfEligiblesToBeChosen, false); ! ! this.portfolioType = PortfolioType.ShortAndLong;//filter for out of sample ! // this.genomeManagerType = GenomeManagerType.ShortAndLong;//filter for the genetic chooser // this.benchmark = new Benchmark( "ENI.MI" ); ! this.firstDateTime = new DateTime( 2003 , 1 , 1 ); ! this.lastDateTime = new DateTime( 2009 , 12, 31 ); this.historicalMarketValueProviderForInSample = *************** *** 105,126 **** //ricordarsi di togliere - mettere //commento nel gestore evento tempo ! this.numDaysForFundamentalDataAvailability = 30; // double optimalDebtEquityRatioLevel = 0.1; // int maxNumOfGrowthRatesToTakeIntoAccount = 4; ! IGrowthRateProvider growthProvider = // new AverageAndDebtAdjustedGrowthRateProvider(numDaysForFundamentalDataAvailability, // maxNumOfGrowthRatesToTakeIntoAccount, // optimalDebtEquityRatioLevel); ! new LastAvailableGrowthRateProvider(numDaysForFundamentalDataAvailability); ! IRatioProvider_PE PEProvider = ! new LastAvailablePEProvider(this.historicalMarketValueProviderForInSample, ! numDaysForFundamentalDataAvailability); ! double fairPEGRatioLevel = 1.0; this.fairValueProvider = ! new PEGRatioFairValueProvider(fairPEGRatioLevel,PEProvider, ! growthProvider,this.historicalMarketValueProviderForInSample); ! this.numDaysForFundamentalAnalysis = 365; ! this.numDaysForPortfolioVolatilityAnalysis = 90; this.timerForBackTester = --- 132,165 ---- //ricordarsi di togliere - mettere //commento nel gestore evento tempo ! this.numDaysForFundamentalDataAvailability = 60; // double optimalDebtEquityRatioLevel = 0.1; // int maxNumOfGrowthRatesToTakeIntoAccount = 4; ! // IGrowthRateProvider growthProvider = // new AverageAndDebtAdjustedGrowthRateProvider(numDaysForFundamentalDataAvailability, // maxNumOfGrowthRatesToTakeIntoAccount, // optimalDebtEquityRatioLevel); ! // new LastAvailableGrowthRateProvider(numDaysForFundamentalDataAvailability); ! FundamentalDataProvider[] fundamentalDataProviders = ! new FundamentalDataProvider[1]{ ! new BookValueProvider(numDaysForFundamentalDataAvailability) ! }; ! ! ILinearRegressionValuesProvider linearRegressionValuesProvider = ! new BasicLinearRegressionValuesProvider(this.tickerSelectorByDate, ! fundamentalDataProviders, ! new DayOfMonth(12, 31) ); ! IIndipendentValuesProvider indipendentValuesProvider = ! new BasicIndipendentValuesProvider(fundamentalDataProviders); ! // IRatioProvider_PE PEProvider = ! // new LastAvailablePEProvider(this.historicalMarketValueProviderForInSample, ! // numDaysForFundamentalDataAvailability); ! // double fairPEGRatioLevel = 1.0; this.fairValueProvider = ! // new PEGRatioFairValueProvider(fairPEGRatioLevel,PEProvider, ! // growthProvider,this.historicalMarketValueProviderForInSample); ! new LinearRegressionFairValueProvider(linearRegressionValuesProvider, ! indipendentValuesProvider); ! // this.genomeManagerType = GenomeManagerType.ShortAndLong; this.timerForBackTester = *************** *** 141,166 **** protected override IEligiblesSelector getEligiblesSelector() { ! this.maxNumberOfEligiblesToBeChosen = 800; ! string tickersGroupId = "ticUSFin"; ! // string tickersGroupId = "SP500"; ! // string tickersGroupId = "STOCKMI"; ! ! bool temporizedGroup = true;//Attenzione! ! double minimumIncome = 10000000.0;//10 mln ! int numOfMinIncomeInARow = 4; ! double minimumRelativeDifferenceBetweenFairAndAverageMarketPrice = 0.05; ! int numDaysForAveragePriceComputation = 10; IEligiblesSelector eligiblesSelector = ! new ByMostDiscountedPrices( this.fairValueProvider , ! tickersGroupId , temporizedGroup , ! maxNumberOfEligiblesToBeChosen , this.numDaysForFundamentalAnalysis, ! this.numDaysForFundamentalDataAvailability, ! minimumIncome, numOfMinIncomeInARow, ! minimumRelativeDifferenceBetweenFairAndAverageMarketPrice, ! numDaysForAveragePriceComputation); ! // new ByLiquidity ( tickersGroupId , temporizedGroup , ! // maxNumberOfEligiblesToBeChosen ); ! // eligiblesSelector = --- 180,202 ---- protected override IEligiblesSelector getEligiblesSelector() { ! // double minimumIncome = 10000000.0;//10 mln ! // int numOfMinIncomeInARow = 3; ! // double minimumRelativeDifferenceBetweenFairAndAverageMarketPrice = 0.01; ! int numDaysForAveragePriceComputation = 5; ! int firstPercentileOfMostDiscountedToExclude = 0; ! int firstPercentileOfMostExpensiveToExclude = 100; ! //the strategy is only long: over-valued tickers are discarded IEligiblesSelector eligiblesSelector = ! new ByRelativeDifferenceBetweenPriceAndFairValue( this.fairValueProvider, ! this.tickerSelectorByDate , ! maxNumberOfEligiblesToBeChosen , ! firstPercentileOfMostDiscountedToExclude , ! firstPercentileOfMostExpensiveToExclude , ! numDaysForAveragePriceComputation ); ! ! // new ByPriceMostLiquidAlwaysQuoted(tickersGroupId, ! // temporizedGroup, maxNumberOfEligiblesToBeChosen, ! // numDaysForAveragePriceComputation, 1.0, 5000.0); // eligiblesSelector = *************** *** 174,210 **** protected override IInSampleChooser getInSampleChooser() { ! int numberOfBestTestingPositionsToBeReturned = 1; // parameters for the genetic optimizer ! double crossoverRate = 0.85; ! double mutationRate = 0.02; ! double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 40000; ! int generationNumberForGeneticOptimizer = 50; ! int seedForRandomGenerator = ! QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; ! BuyAndHoldFitnessEvaluator fitnessEvaluator = // new BuyAndHoldFitnessEvaluator( new Variance() ); ! new BuyAndHoldFitnessEvaluator( new SharpeRatio() ); ! bool mixPastReturnsEvaluationWithFundamentalEvaluation = ! false; ! BasicDecoderForGeneticallyOptimizableTestingPositions basicGenOptDecoder = ! new BasicDecoderForGeneticallyOptimizableTestingPositions(); IInSampleChooser inSampleChooser = ! new DrivenByFVProviderInSampleChooser(this.numberOfPortfolioPositions, ! numberOfBestTestingPositionsToBeReturned, ! benchmark, basicGenOptDecoder, this.genomeManagerType , ! fitnessEvaluator , mixPastReturnsEvaluationWithFundamentalEvaluation, ! historicalMarketValueProviderForInSample, this.timerForBackTester, ! crossoverRate, mutationRate, elitismRate , ! populationSizeForGeneticOptimizer, generationNumberForGeneticOptimizer, ! seedForRandomGenerator); - // new SelectTopEligiblesInSampleChooser( this.numberOfPortfolioPositions, - // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; --- 210,248 ---- protected override IInSampleChooser getInSampleChooser() { ! int numberOfBestTestingPositionsToBeReturned = 5; // parameters for the genetic optimizer ! // double crossoverRate = 0.85; ! // double mutationRate = 0.02; ! // double elitismRate = 0.001; ! // int populationSizeForGeneticOptimizer = 1000; ! // int generationNumberForGeneticOptimizer = 10; ! // int seedForRandomGenerator = ! // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; ! // BuyAndHoldFitnessEvaluator fitnessEvaluator = // new BuyAndHoldFitnessEvaluator( new Variance() ); ! // new BuyAndHoldFitnessEvaluator( new SharpeRatio() ); ! // bool mixPastReturnsEvaluationWithFundamentalEvaluation = true; ! BasicDecoderForGeneticallyOptimizableTestingPositions decoderForFVProvider = ! new DecoderForFVProviderStrategy(); IInSampleChooser inSampleChooser = ! // new DrivenByFVProviderInSampleChooser(this.numberOfPortfolioPositions, ! // numberOfBestTestingPositionsToBeReturned, ! // benchmark, decoderForFVProvider, this.genomeManagerType , ! // fitnessEvaluator , mixPastReturnsEvaluationWithFundamentalEvaluation, ! // historicalMarketValueProviderForInSample, this.timerForBackTester, ! // crossoverRate, mutationRate, elitismRate , ! // populationSizeForGeneticOptimizer, generationNumberForGeneticOptimizer, ! // seedForRandomGenerator); ! ! new SelectTopBottomEligiblesWithSignInSampleChooser( this.numberOfPortfolioPositions, ! numberOfBestTestingPositionsToBeReturned, ! this.historicalMarketValueProviderForInSample, ! this.timerForBackTester); return inSampleChooser; *************** *** 215,230 **** protected override IStrategyForBacktester getStrategyForBacktester() { ! int numDaysBetweenEachOptimization = 60; ! int minNumOfEligiblesForValidOptimization = 10; IStrategyForBacktester strategyForBacktester = new DrivenByFVProviderStrategy(eligiblesSelector , minNumOfEligiblesForValidOptimization, inSampleChooser , ! numDaysForFundamentalAnalysis , numDaysForPortfolioVolatilityAnalysis , benchmark , numDaysBetweenEachOptimization , historicalMarketValueProviderForInSample , historicalMarketValueProviderForOutOfSample , this.portfolioType, this.stopLoss, this.percentageOfTheoreticalProfitForExit, ! this.takeProfitLevelInAnyCase); return strategyForBacktester; --- 253,268 ---- protected override IStrategyForBacktester getStrategyForBacktester() { ! int numDaysBetweenEachOptimization = 180; ! int minNumOfEligiblesForValidOptimization = 20; IStrategyForBacktester strategyForBacktester = new DrivenByFVProviderStrategy(eligiblesSelector , minNumOfEligiblesForValidOptimization, inSampleChooser , ! this.numDaysForFundamentalDataAvailability, numDaysForPortfolioVolatilityAnalysis , benchmark , numDaysBetweenEachOptimization , historicalMarketValueProviderForInSample , historicalMarketValueProviderForOutOfSample , this.portfolioType, this.stopLoss, this.percentageOfTheoreticalProfitForExit, ! this.takeProfitLevelInAnyCase, this.hedgingTicker, this.hedgingTickerWeight); return strategyForBacktester; Index: DrivenByFVProviderLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/DrivenByFundamentals/DrivenByFairValueProvider/DrivenByFVProviderLogItem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DrivenByFVProviderLogItem.cs 16 Jan 2011 19:35:50 -0000 1.1 --- DrivenByFVProviderLogItem.cs 21 Aug 2011 14:21:05 -0000 1.2 *************** *** 22,46 **** using System; - using System.Collections.Generic; using System.Windows.Forms; ! using QuantProject.ADT; using QuantProject.ADT.Timing; using QuantProject.Data.DataProviders.Bars.Caching; - using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies.Eligibles; ! using QuantProject.Business.Strategies.InSample; ! using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Logging; ! using QuantProject.Business.Strategies.ReturnsManagement.Time; ! using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; ! using QuantProject.Scripts.TickerSelectionTesting.OTC.OTC_Intraday; using QuantProject.Business.Timing; using QuantProject.Presentation; ! using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! using QuantProject.Scripts.General.Reporting; using QuantProject.Scripts.General.Logging; namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider --- 22,51 ---- using System; using System.Windows.Forms; ! using System.Collections.Generic; using QuantProject.ADT; using QuantProject.ADT.Timing; using QuantProject.Data.DataProviders.Bars.Caching; using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies.Eligibles; ! using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.Logging; ! using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Timing; using QuantProject.Presentation; ! using QuantProject.Scripts.General; using QuantProject.Scripts.General.Logging; + using QuantProject.Scripts.General.Reporting; + // + // + //using QuantProject.Business.Strategies.InSample; + //using QuantProject.Business.Strategies.Logging; + //using QuantProject.Business.Strategies.ReturnsManagement.Time; + //using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; + // + //using QuantProject.Presentation; + //using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; + // namespace QuantProject.Scripts.TickerSelectionTesting.DrivenByFundamentals.DrivenByFairValueProvider *************** *** 52,63 **** public class DrivenByFVProviderLogItem : LogItem { ! protected DummyTesterForTestingPositions[] ! dummyTestersForBestTestingPositionsInSample; protected TestingPositions[] bestPositionsInSample; protected int numberOfEligibleTickers; protected double fitness; protected int generation; protected string tickers; - protected int numberOfDaysForFundamentalAnalysis; protected int numberOfDaysForVolatilityAnalysis; --- 57,69 ---- public class DrivenByFVProviderLogItem : LogItem { ! protected BuyAndHoldTesterForTestingPositions[] ! buyAndHoldTestersForBestTestingPositionsInSample; protected TestingPositions[] bestPositionsInSample; + protected HistoricalMarketValueProvider historicalMarketValueProvider; + protected Benchmark benchmark; protected int numberOfEligibleTickers; protected double fitness; protected int generation; protected string tickers; protected int numberOfDaysForVolatilityAnalysis; *************** *** 109,123 **** } public DrivenByFVProviderLogItem(DateTime dateTime, ! int numberOfDaysForFundamentalAnalysis, ! int numberOfDaysForVolatilityAnalysis) : base( dateTime ) { - this.numberOfDaysForFundamentalAnalysis = numberOfDaysForFundamentalAnalysis; this.numberOfDaysForVolatilityAnalysis = numberOfDaysForVolatilityAnalysis; this.numberOfEligibleTickers = int.MinValue; this.fitness = double.MinValue; } ! #region runStrategyClickEventHandler protected virtual void runStrategyClickEventHandler(object sender, System.EventArgs e) { --- 115,131 ---- } public DrivenByFVProviderLogItem(DateTime dateTime, ! int numberOfDaysForVolatilityAnalysis, ! HistoricalMarketValueProvider historicalMarketValueProvider, ! Benchmark benchmark) : base( dateTime ) { this.numberOfDaysForVolatilityAnalysis = numberOfDaysForVolatilityAnalysis; + this.benchmark = benchmark; + this.historicalMarketValueProvider = historicalMarketValueProvider; this.numberOfEligibleTickers = int.MinValue; this.fitness = double.MinValue; } ! #region runStrategyClickEventHandler OLD protected virtual void runStrategyClickEventHandler(object sender, System.EventArgs e) { *************** *** 186,196 **** #endregion runStrategyClickEventHandler ! private void showTestingPositionsClickEventHandler_setDummyTesters_setTester( int currentIndex , TestingPositions testingPositions , DateTime simulatedCreationDateTime ) { ! this.dummyTestersForBestTestingPositionsInSample[ currentIndex ] = ! new DummyTesterForTestingPositions( testingPositions , this.numberOfDaysForVolatilityAnalysis , --- 194,323 ---- #endregion runStrategyClickEventHandler ! #region runStrategyClickEventHandlerInAndOutOfSample ! protected virtual void runStrategyClickEventHandlerInAndOutOfSample(object sender, System.EventArgs e) ! { ! DateTime firstDateTime = this.SimulatedCreationDateTime.AddDays(-this.numberOfDaysForVolatilityAnalysis); ! DateTime lastDateTime = this.SimulatedCreationDateTime; ! double maxRunningHours = 1; ! int numberOfPortfolioPositions = this.bestPositionsInSample[0].WeightedPositions.Count; ! //cash and portfolio type ! double cashToStart = 10000; ! HistoricalMarketValueProvider historicalQuoteProviderForBackTester, ! historicalQuoteProviderForInSampleChooser, ! historicalQuoteProviderForStrategy; ! historicalQuoteProviderForBackTester = this.historicalMarketValueProvider; ! historicalQuoteProviderForInSampleChooser = historicalQuoteProviderForBackTester; ! historicalQuoteProviderForStrategy = historicalQuoteProviderForInSampleChooser; ! //strategyParameters ! TestingPositions positionsToTest = this.BestPositionsInSample[0]; ! ! BuyAndHoldStrategy strategy = new BuyAndHoldStrategy(positionsToTest); ! ! QuantProject.Business.Timing.Timer timer = ! new IndexBasedEndOfDayTimer( firstDateTime, ! lastDateTime.AddDays(this.numberOfDaysForVolatilityAnalysis), ! this.benchmark.Ticker); ! ! EndOfDayStrategyBackTester endOfDayStrategyBackTester = ! new EndOfDayStrategyBackTester( ! "BuyAndHold" , timer , strategy, ! historicalQuoteProviderForBackTester , ! new SimpleAccountProvider(), firstDateTime , ! lastDateTime.AddDays(this.numberOfDaysForVolatilityAnalysis) , ! this.benchmark , cashToStart , maxRunningHours ); ! ! endOfDayStrategyBackTester.Run(); ! BackTesterReportViewer.ShowReport( lastDateTime.AddDays(this.numberOfDaysForVolatilityAnalysis) , ! endOfDayStrategyBackTester ); ! ! } ! #endregion runStrategyClickEventHandlerInAndOutOfSample ! ! #region runStrategyClickEventHandlerOnlyInSample ! protected virtual void runStrategyClickEventHandlerOnlyInSample(object sender, System.EventArgs e) ! { ! DateTime firstDateTime = this.SimulatedCreationDateTime.AddDays(-this.numberOfDaysForVolatilityAnalysis); ! DateTime lastDateTime = this.SimulatedCreationDateTime; ! double maxRunningHours = 1; ! int numberOfPortfolioPositions = this.bestPositionsInSample[0].WeightedPositions.Count; ! //cash and portfolio type ! double cashToStart = 10000; ! HistoricalMarketValueProvider historicalQuoteProviderForBackTester, ! historicalQuoteProviderForInSampleChooser, ! historicalQuoteProviderForStrategy; ! historicalQuoteProviderForBackTester = this.historicalMarketValueProvider; ! historicalQuoteProviderForInSampleChooser = historicalQuoteProviderForBackTester; ! historicalQuoteProviderForStrategy = historicalQuoteProviderForInSampleChooser; ! //strategyParameters ! TestingPositions positionsToTest = this.BestPositionsInSample[0]; ! ! BuyAndHoldStrategy strategy = new BuyAndHoldStrategy(positionsToTest); ! QuantProject.Business.Timing.Timer timer = ! new IndexBasedEndOfDayTimer( firstDateTime, ! lastDateTime, ! this.benchmark.Ticker); ! ! EndOfDayStrategyBackTester endOfDayStrategyBackTester = ! new EndOfDayStrategyBackTester( ! "BuyAndHold" , timer , strategy, ! historicalQuoteProviderForBackTester , ! new SimpleAccountProvider(), firstDateTime , ! lastDateTime , ! this.benchmark , cashToStart , maxRunningHours ); ! ! endOfDayStrategyBackTester.Run(); ! BackTesterReportViewer.ShowReport( lastDateTime , ! endOfDayStrategyBackTester ); ! } ! #endregion runStrategyClickEventHandlerOnlyInSample ! ! #region runStrategyClickEventHandlerOnlyOutOfSample ! protected virtual void runStrategyClickEventHandlerOnlyOutOfSample(object sender, System.EventArgs e) ! { ! DateTime firstDateTime = this.SimulatedCreationDateTime; ! DateTime lastDateTime = this.SimulatedCreationDateTime.AddDays(this.numberOfDaysForVolatilityAnalysis); ! double maxRunningHours = 1; ! int numberOfPortfolioPositions = this.bestPositionsInSample[0].WeightedPositions.Count; ! //cash and portfolio type ! double cashToStart = 10000; ! HistoricalMarketValueProvider historicalQuoteProviderForBackTester, ! historicalQuoteProviderForInSampleChooser, ! historicalQuoteProviderForStrategy; ! historicalQuoteProviderForBackTester = this.historicalMarketValueProvider; ! historicalQuoteProviderForInSampleChooser = historicalQuoteProviderForBackTester; ! historicalQuoteProviderForStrategy = historicalQuoteProviderForInSampleChooser; ! //strategyParameters ! TestingPositions positionsToTest = this.BestPositionsInSample[0]; ! ! BuyAndHoldStrategy strategy = new BuyAndHoldStrategy(positionsToTest); ! ! QuantProject.Business.Timing.Timer timer = ! new IndexBasedEndOfDayTimer( firstDateTime, ! lastDateTime, ! this.benchmark.Ticker); ! ! EndOfDayStrategyBackTester endOfDayStrategyBackTester = ! new EndOfDayStrategyBackTester( ! "BuyAndHold" , timer , strategy, ! historicalQuoteProviderForBackTester , ! new SimpleAccountProvider(), firstDateTime , ! lastDateTime , ! this.benchmark , cashToStart , maxRunningHours ); ! ! endOfDayStrategyBackTester.Run(); ! BackTesterReportViewer.ShowReport( lastDateTime , ! endOfDayStrategyBackTester ); ! ! } ! #endregion runStrategyClickEventHandlerOnlyOutOfSample ! ! private void showTestingPositionsClickEventHandler_setTesters_setTester( int currentIndex , TestingPositions testingPositions , DateTime simulatedCreationDateTime ) { ! this.buyAndHoldTestersForBestTestingPositionsInSample[ currentIndex ] = ! new BuyAndHoldTesterForTestingPositions(this.historicalMarketValueProvider, ! this.benchmark, testingPositions , this.numberOfDaysForVolatilityAnalysis , *************** *** 198,207 **** } ! private void showTestingPositionsClickEventHandler_setDummyTesters() { ! this.dummyTestersForBestTestingPositionsInSample = ! new DummyTesterForTestingPositions[this.BestPositionsInSample.Length]; for ( int i = 0 ; i < BestPositionsInSample.Length; i++ ) ! this.showTestingPositionsClickEventHandler_setDummyTesters_setTester( i , BestPositionsInSample[ i ] , --- 325,334 ---- } ! private void showTestingPositionsClickEventHandler_setTesters() { ! this.buyAndHoldTestersForBestTestingPositionsInSample = ! new BuyAndHoldTesterForTestingPositions[this.BestPositionsInSample.Length]; for ( int i = 0 ; i < BestPositionsInSample.Length; i++ ) ! this.showTestingPositionsClickEventHandler_setTesters_setTester( i , BestPositionsInSample[ i ] , *************** *** 211,229 **** protected virtual void showTestingPositionsClickEventHandler(object sender, System.EventArgs e) { ! this.showTestingPositionsClickEventHandler_setDummyTesters(); QuantProject.Presentation.ExecutablesListViewer executablesListViewer = new ExecutablesListViewer( ! this.dummyTestersForBestTestingPositionsInSample ); executablesListViewer.Show(); } protected virtual void createAndShowContextMenu() { ! MenuItem[] menuItems = new MenuItem[2]; ! menuItems[0] = new MenuItem("Run Strategy"); ! menuItems[1] = new MenuItem("Show TestingPositions"); menuItems[0].Click += ! new System.EventHandler(this.runStrategyClickEventHandler); menuItems[1].Click += new System.EventHandler(this.showTestingPositionsClickEventHandler); ContextMenu contextMenu = new ContextMenu(menuItems); --- 338,375 ---- protected virtual void showTestingPositionsClickEventHandler(object sender, System.EventArgs e) { ! this.showTestingPositionsClickEventHandler_setTesters(); QuantProject.Presentation.ExecutablesListViewer executablesListViewer = new ExecutablesListViewer( ! this.buyAndHoldTestersForBestTestingPositionsInSample ); executablesListViewer.Show(); } + //OLD protected virtual void createAndShowContextMenu() + // { + // MenuItem[] menuItems = new MenuItem[2]; + // menuItems[0] = new MenuItem("Run Strategy"); + // menuItems[1] = new MenuItem("Show TestingPositions"); + // menuItems[0].Click += + // new System.EventHandler(this.runStrategyClickEventHandler); + // menuItems[1].Click += + // new System.EventHandler(this.showTestingPositionsClickEventHandler); + // ContextMenu contextMenu = new ContextMenu(menuItems); + // contextMenu.Show(Form.ActiveForm, Form.MousePosition); + // } + protected virtual void createAndShowContextMenu() { ! MenuItem[] menuItems = new MenuItem[4]; ! menuItems[0] = new MenuItem("Run Strategy In Sample And Out of S."); ! menuItems[1] = new MenuItem("Run Strategy Only In Sample"); ! menuItems[2] = new MenuItem("Run Strategy Only Out of S."); ! menuItems[3] = new MenuItem("Show TestingPositions"); menuItems[0].Click += ! new System.EventHandler(this.runStrategyClickEventHandlerInAndOutOfSample); menuItems[1].Click += + new System.EventHandler(this.runStrategyClickEventHandlerOnlyInSample); + menuItems[2].Click += + new System.EventHandler(this.runStrategyClickEventHandlerOnlyOutOfSample); + menuItems[3].Click += new System.EventHandler(this.showTestingPositionsClickEventHandler); ContextMenu contextMenu = new ContextMenu(menuItems); |