[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting/OTC/OTC_Intraday OTCIntra
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2009-10-30 23:14:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/OTC_Intraday In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11220/TickerSelectionTesting/OTC/OTC_Intraday Modified Files: OTCIntradayLogItem.cs OTCIntradayMain.cs OTCIntradayStrategy.cs Log Message: Updated old script files for the OTC strategy Index: OTCIntradayStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/OTC_Intraday/OTCIntradayStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTCIntradayStrategy.cs 31 Aug 2009 20:40:30 -0000 1.1 --- OTCIntradayStrategy.cs 30 Oct 2009 23:14:23 -0000 1.2 *************** *** 119,122 **** --- 119,123 ---- protected double stopLoss; protected double takeProfit; + protected object[] daysForPlayingTheStrategy; private string description_GetDescriptionForChooser() *************** *** 174,178 **** double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength) { this.eligiblesSelector = eligiblesSelector; --- 175,180 ---- double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength, ! object[] daysForPlayingTheStrategy) { this.eligiblesSelector = eligiblesSelector; *************** *** 202,205 **** --- 204,208 ---- this.estimator = estimator; this.sampleLength = sampleLength; + this.daysForPlayingTheStrategy = daysForPlayingTheStrategy; } *************** *** 224,228 **** double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength) { --- 227,232 ---- double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength, ! object[] daysForPlayingTheStrategy) { *************** *** 245,249 **** numberOfMinimumStdDeviationForOpeningPositions, numberOfMaxStdDeviationForOpeningPositions, ! estimator, sampleLength); } --- 249,254 ---- numberOfMinimumStdDeviationForOpeningPositions, numberOfMaxStdDeviationForOpeningPositions, ! estimator, sampleLength, ! daysForPlayingTheStrategy); } *************** *** 260,264 **** double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength) { --- 265,269 ---- double numberOfMaxStdDeviationForOpeningPositions, IInSampleFitnessDistributionEstimator estimator, ! int sampleLength, object[] daysForPlayingTheStrategy) { *************** *** 280,284 **** numberOfMinimumStdDeviationForOpeningPositions, numberOfMaxStdDeviationForOpeningPositions, ! estimator, sampleLength); } private bool allTickersAreExchanged(DateTime dateTime, --- 285,289 ---- numberOfMinimumStdDeviationForOpeningPositions, numberOfMaxStdDeviationForOpeningPositions, ! estimator, sampleLength, daysForPlayingTheStrategy); } private bool allTickersAreExchanged(DateTime dateTime, *************** *** 345,348 **** --- 350,367 ---- #region newDateTimeEventHandler_openPositions + private bool newDateTimeEventHandler_openPositions_isTheRightDay() + { + bool returnValue = false; + for(int i = 0; i<this.daysForPlayingTheStrategy.Length; i++) + { + if(this.daysForPlayingTheStrategy[i] != null && + this.now().DayOfWeek == (DayOfWeek)this.daysForPlayingTheStrategy[i]) + { + returnValue = true; + i = this.daysForPlayingTheStrategy.Length; + } + } + return returnValue; + } private bool newDateTimeEventHandler_openPositions_bestFitnessIsSignificantlyHigh() { *************** *** 371,376 **** if( this.chosenOTCPositions != null && this.allTickersAreExchanged( this.now(), this.chosenOTCPositions[idxForBestPositionsCompatibleWithPortfolioType].WeightedPositions.SignedTickers.Tickers) ! && ! this.newDateTimeEventHandler_openPositions_bestFitnessIsSignificantlyHigh() ) // && // this.allTickersAreExchangedInTheLastFiveMinutelyBars( this.now(), this.chosenOTCPositions[idxForBestPositionsCompatibleWithPortfolioType].WeightedPositions.SignedTickers.Tickers ) --- 390,397 ---- if( this.chosenOTCPositions != null && this.allTickersAreExchanged( this.now(), this.chosenOTCPositions[idxForBestPositionsCompatibleWithPortfolioType].WeightedPositions.SignedTickers.Tickers) ! // && ! // this.newDateTimeEventHandler_openPositions_bestFitnessIsSignificantlyHigh() ! && this.newDateTimeEventHandler_openPositions_isTheRightDay() ! ) // && // this.allTickersAreExchangedInTheLastFiveMinutelyBars( this.now(), this.chosenOTCPositions[idxForBestPositionsCompatibleWithPortfolioType].WeightedPositions.SignedTickers.Tickers ) Index: OTCIntradayMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/OTC_Intraday/OTCIntradayMain.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTCIntradayMain.cs 31 Aug 2009 20:40:30 -0000 1.1 --- OTCIntradayMain.cs 30 Oct 2009 23:14:23 -0000 1.2 *************** *** 92,96 **** public OTCIntradayMain() { ! this.numberOfPortfolioPositions = 2; // this.benchmark = new Benchmark( "CCE" ); this.portfolioType = PortfolioType.ShortAndLong;//filter for out of sample --- 92,96 ---- public OTCIntradayMain() { ! this.numberOfPortfolioPositions = 3; // this.benchmark = new Benchmark( "CCE" ); this.portfolioType = PortfolioType.ShortAndLong;//filter for out of sample *************** *** 99,103 **** this.benchmark = new Benchmark( "ENI.MI" ); this.firstDateTime = new DateTime( 2000 , 1 , 1 ); ! this.lastDateTime = new DateTime( 2009 , 8, 27 ); //this.stepInMinutesForTimer = 1; this.intervalFrameInSeconds = 60; --- 99,103 ---- this.benchmark = new Benchmark( "ENI.MI" ); this.firstDateTime = new DateTime( 2000 , 1 , 1 ); ! this.lastDateTime = new DateTime( 2009 , 8, 15 ); //this.stepInMinutesForTimer = 1; this.intervalFrameInSeconds = 60; *************** *** 158,163 **** bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 0.10; ! double maxPrice = 2000; // int maxNumberOfMostLiquidTickersToBeChosen = 150; --- 158,163 ---- bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 4; ! double maxPrice = 200; // int maxNumberOfMostLiquidTickersToBeChosen = 150; *************** *** 211,223 **** // int numberOfBestTestingPositionsToBeReturned = // (int)combinations.TotalNumberOfCombinations; ! int numberOfBestTestingPositionsToBeReturned = 20; // parameters for the genetic optimizer ! // double crossoverRate = 0.85; ! // double mutationRate = 0.02; ! // double elitismRate = 0.001; ! // int populationSizeForGeneticOptimizer = 5000; ! // int generationNumberForGeneticOptimizer = 0; ! // int seedForRandomGenerator = ! // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; IDecoderForTestingPositions decoderForTestingPositions = --- 211,223 ---- // int numberOfBestTestingPositionsToBeReturned = // (int)combinations.TotalNumberOfCombinations; ! int numberOfBestTestingPositionsToBeReturned = 50; // parameters for the genetic optimizer ! double crossoverRate = 0.85; ! double mutationRate = 0.02; ! double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 10000; ! int generationNumberForGeneticOptimizer = 30; ! int seedForRandomGenerator = ! QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; IDecoderForTestingPositions decoderForTestingPositions = *************** *** 233,237 **** // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); ! // IInSampleChooser inSampleChooser = // new OTCEndOfDayGeneticChooser(this.numberOfPortfolioPositions, numberOfBestTestingPositionsToBeReturned, // benchmark, decoderForTestingPositions , --- 233,238 ---- // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); ! ADT.ConstantsProvider.AmountOfVariableWeightToBeAssignedToTickers = 0.40; ! IInSampleChooser inSampleChooser = // new OTCEndOfDayGeneticChooser(this.numberOfPortfolioPositions, numberOfBestTestingPositionsToBeReturned, // benchmark, decoderForTestingPositions , *************** *** 241,250 **** // mutationRate, elitismRate , populationSizeForGeneticOptimizer, // generationNumberForGeneticOptimizer, seedForRandomGenerator); ! IInSampleChooser inSampleChooser = ! new OTCEndOfDayBruteForceChooser(this.portfolioType, ! this.numberOfPortfolioPositions, ! numberOfBestTestingPositionsToBeReturned, ! this.benchmark, decoderForTestingPositions , fitnessEvaluator, ! historicalMarketValueProviderForInSample); // //office // inSampleChooser = --- 242,259 ---- // mutationRate, elitismRate , populationSizeForGeneticOptimizer, // generationNumberForGeneticOptimizer, seedForRandomGenerator); ! new OTCEndOfDayGeneticChooserWithWeights(this.numberOfPortfolioPositions, numberOfBestTestingPositionsToBeReturned, ! benchmark, ! this.genomeManagerType , ! fitnessEvaluator , ! historicalMarketValueProviderForInSample, crossoverRate, ! mutationRate, elitismRate , populationSizeForGeneticOptimizer, ! generationNumberForGeneticOptimizer, seedForRandomGenerator); ! ! // IInSampleChooser inSampleChooser = ! // new OTCEndOfDayBruteForceChooser(this.portfolioType, ! // this.numberOfPortfolioPositions, ! // numberOfBestTestingPositionsToBeReturned, ! // this.benchmark, decoderForTestingPositions , fitnessEvaluator, ! // historicalMarketValueProviderForInSample); // //office // inSampleChooser = *************** *** 265,280 **** { //int inSampleDays = 90; ! int inSampleDays = 45; ! int numDaysBetweenEachOptimization = 1; ! int numDaysBeforeCurrentDateForRetrievingInSampleData = 0; int minNumOfEligiblesForValidOptimization = 10; ! int sampleLengthForFitnessDistributionEstimation = 100; double minimumNumberOfStdDevForSignificantFitness = 0.0; ! double maximumNumberOfStdDevForSignificantFitness = 8.0; ! IInSampleFitnessDistributionEstimator estimator = new BasicInSampleFitnessDistributionEstimator(); GeneticChooser geneticChooserForEstimator = ! new OTCEndOfDayGeneticChooser(this.numberOfPortfolioPositions, 50, ! this.benchmark, new BasicDecoderForOTCPositions(), this.genomeManagerType , new OTCCTOFitnessEvaluator( new SharpeRatio() ) , --- 274,292 ---- { //int inSampleDays = 90; ! int inSampleDays = 90; ! int numDaysBetweenEachOptimization = 5; ! int numDaysBeforeCurrentDateForRetrievingInSampleData = 1; int minNumOfEligiblesForValidOptimization = 10; ! //disabilitato il controllo della fitness double minimumNumberOfStdDevForSignificantFitness = 0.0; ! double maximumNumberOfStdDevForSignificantFitness = 0.0; ! int sampleLengthForFitnessDistributionEstimation = 150; ! //disabilitato il controllo della fitness ! ! IInSampleFitnessDistributionEstimator estimator = new BasicInSampleFitnessDistributionEstimator(); GeneticChooser geneticChooserForEstimator = ! new OTCEndOfDayGeneticChooser(this.numberOfPortfolioPositions, 50, ! this.benchmark, new BasicDecoderForOTCPositions(), this.genomeManagerType , new OTCCTOFitnessEvaluator( new SharpeRatio() ) , *************** *** 283,287 **** double stopLoss = 0.015; double takeProfit = 0.03; ! IStrategyForBacktester strategyForBacktester // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , --- 295,301 ---- double stopLoss = 0.015; double takeProfit = 0.03; ! object[] daysForPlayingTheStrategy = ! new object[5]{ DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, ! DayOfWeek.Thursday, DayOfWeek.Friday}; IStrategyForBacktester strategyForBacktester // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , *************** *** 304,311 **** maximumNumberOfStdDevForSignificantFitness, estimator, ! sampleLengthForFitnessDistributionEstimation); ! ((OTCIntradayStrategy)strategyForBacktester).FindPositionsForToday( ! new DateTime(2009,8,31), new DateTime(2009,8,28) ); return strategyForBacktester; --- 318,325 ---- maximumNumberOfStdDevForSignificantFitness, estimator, ! sampleLengthForFitnessDistributionEstimation, daysForPlayingTheStrategy); ! // ((OTCIntradayStrategy)strategyForBacktester).FindPositionsForToday( ! // new DateTime(2009,9,1), new DateTime(2009,8,28) ); return strategyForBacktester; Index: OTCIntradayLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/OTC/OTC_Intraday/OTCIntradayLogItem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTCIntradayLogItem.cs 31 Aug 2009 20:40:30 -0000 1.1 --- OTCIntradayLogItem.cs 30 Oct 2009 23:14:23 -0000 1.2 *************** *** 145,150 **** // numDaysForOscillatingPeriodForOutOfSample * 24 *60, // new MarketDateTimeManager(benchmark, firstDateTime, lastDateTime, 60) ); OTCIntradayStrategy strategy = ! new OTCIntradayStrategy(eligiblesSelector, positionsToTest, benchmark, historicalQuoteProviderForInSampleChooser, --- 145,154 ---- // numDaysForOscillatingPeriodForOutOfSample * 24 *60, // new MarketDateTimeManager(benchmark, firstDateTime, lastDateTime, 60) ); + + object[] days = new object[5]{DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, + DayOfWeek.Thursday, DayOfWeek.Friday}; + OTCIntradayStrategy strategy = ! new OTCIntradayStrategy(eligiblesSelector, positionsToTest, benchmark, historicalQuoteProviderForInSampleChooser, *************** *** 152,156 **** Time.GetIntermediateTimes(new Time("09:30:00"), new Time("16:00:00"), 1 ), ! 0.5, 0.5, PortfolioType.ShortAndLong, null, 2, 3, null, 100); QuantProject.Business.Timing.Timer timer = --- 156,160 ---- Time.GetIntermediateTimes(new Time("09:30:00"), new Time("16:00:00"), 1 ), ! 0.5, 0.5, PortfolioType.ShortAndLong, null, 2, 3, null, 100, days); QuantProject.Business.Timing.Timer timer = |