Thread: [Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOs
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-08-15 04:53:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19183/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVO_OTCLogItem.cs PVO_OTCMain.cs PVO_OTCStrategy.cs PVO_OTCStrategyLessCorrelated.cs PVOLogItem.cs PVOMain.cs PVOPositions.cs PVOPositionsStatus.cs PVOStrategy.cs Log Message: Minor changes for the some files implementing the PVO strategy Index: PVOStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategy.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVOStrategy.cs 8 Apr 2008 21:59:09 -0000 1.4 --- PVOStrategy.cs 14 Aug 2008 23:28:06 -0000 1.5 *************** *** 92,96 **** protected double currentAccountValue; protected double previousAccountValue; ! private string description_GetDescriptionForChooser() { --- 92,100 ---- protected double currentAccountValue; protected double previousAccountValue; ! protected double oversoldThreshold; ! protected double overboughtThreshold; ! protected double oversoldThresholdMAX; ! protected double overboughtThresholdMAX; ! private string description_GetDescriptionForChooser() { *************** *** 129,132 **** --- 133,140 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 142,146 **** this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.minimumAcceptableGain = minimumAcceptableGain; ! this.stopLossConditionReached = false; this.currentAccountValue = 0.0; --- 150,157 ---- this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.minimumAcceptableGain = minimumAcceptableGain; ! this.oversoldThreshold = oversoldThreshold; ! this.overboughtThreshold = overboughtThreshold; ! this.oversoldThresholdMAX = oversoldThresholdMAX; ! this.overboughtThresholdMAX = overboughtThresholdMAX; this.stopLossConditionReached = false; this.currentAccountValue = 0.0; *************** *** 157,160 **** --- 168,175 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 164,167 **** --- 179,184 ---- this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); *************** *** 170,173 **** --- 187,213 ---- public PVOStrategy(IEligiblesSelector eligiblesSelector, + IInSampleChooser inSampleChooser, + int inSampleDays, + int numDaysForOscillatingPeriod, + int numberOfTickersToBeChosen, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider, + double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain) + + { + this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , + numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, + historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , + minimumAcceptableGain ); + this.inSampleChooser = inSampleChooser; + } + + public PVOStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, *************** *** 176,179 **** --- 216,223 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 183,186 **** --- 227,255 ---- this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, + historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , + minimumAcceptableGain ); + this.chosenPVOPositions = chosenPVOPositions; + } + + public PVOStrategy(IEligiblesSelector eligiblesSelector, + TestingPositions[] chosenPVOPositions, + int inSampleDays, + int numDaysForOscillatingPeriod, + int numberOfTickersToBeChosen, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider, + double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain) + + { + this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , + numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + double.MaxValue , double.MaxValue , historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); *************** *** 233,237 **** EndOfDayDateTime beginOfOscillatingPeriod = this.getBeginOfOscillatingPeriod(timer); PVOPositionsStatus pvoPositionsStatus = ! this.pvoPositionsForOutOfSample.GetStatus(beginOfOscillatingPeriod, today , this.benchmark.Ticker, this.historicalQuoteProvider); if(pvoPositionsStatus == PVOPositionsStatus.Overbought && this.portfolioHasBeenOversold) --- 302,307 ---- EndOfDayDateTime beginOfOscillatingPeriod = this.getBeginOfOscillatingPeriod(timer); PVOPositionsStatus pvoPositionsStatus = ! this.pvoPositionsForOutOfSample.GetStatus(beginOfOscillatingPeriod, today , this.benchmark.Ticker, this.historicalQuoteProvider, ! double.MaxValue, double.MaxValue); if(pvoPositionsStatus == PVOPositionsStatus.Overbought && this.portfolioHasBeenOversold) *************** *** 258,262 **** currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) --- 328,333 ---- currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider, ! double.MaxValue, double.MaxValue); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) *************** *** 363,367 **** try{ this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! this.marketCloseEventHandler_closePositionsIfNeeded(); if( this.chosenPVOPositions != null ) //PVOPositions have been chosen by the chooser --- 434,438 ---- try{ this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! //this.marketCloseEventHandler_closePositionsIfNeeded(); if( this.chosenPVOPositions != null ) //PVOPositions have been chosen by the chooser *************** *** 371,375 **** //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender); } } --- 442,447 ---- //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_closePositionsIfNeeded(); ! //this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender); } } *************** *** 436,439 **** --- 508,521 ---- this.NewMessage( this , newMessageEventArgs ); } + private void updateTestingPositions_updateThresholds() + { + for(int i = 0; i<this.chosenPVOPositions.Length; i++) + { + ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = + this.oversoldThreshold; + ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = + this.overboughtThreshold; + } + } private void logOptimizationInfo( EligibleTickers eligibleTickers ) { *************** *** 456,459 **** --- 538,542 ---- if(this.inSampleChooser != null) this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager ); + this.updateTestingPositions_updateThresholds(); this.logOptimizationInfo(eligibles); } Index: PVO_OTCLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCLogItem.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVO_OTCLogItem.cs 26 Apr 2008 09:52:44 -0000 1.3 --- PVO_OTCLogItem.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 84,88 **** positionsToTest = this.bestPVOPositionsInSample; PVO_OTCStrategy strategy = ! new PVO_OTCStrategy(eligiblesSelector, positionsToTest, inSampleDays, benchmark , --- 84,88 ---- positionsToTest = this.bestPVOPositionsInSample; PVO_OTCStrategy strategy = ! new PVO_OTCStrategy(eligiblesSelector, 1, positionsToTest, inSampleDays, benchmark , Index: PVO_OTCMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCMain.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PVO_OTCMain.cs 26 Apr 2008 09:53:54 -0000 1.5 --- PVO_OTCMain.cs 14 Aug 2008 23:28:06 -0000 1.6 *************** *** 63,67 **** public PVO_OTCMain() { ! this.benchmark = new Benchmark( "BMC" ); this.historicalQuoteProvider = --- 63,67 ---- public PVO_OTCMain() { ! this.benchmark = new Benchmark( "^GSPC" ); this.historicalQuoteProvider = *************** *** 74,87 **** protected override IEligiblesSelector getEligiblesSelector() { - int maxNumberOfEligiblesToBeChosen = 100; string tickersGroupId = "SP500"; - // uncomment the following line for a faster script - //tickersGroupId = "fastTest"; - - // this.eligiblesSelector = - // new MostLiquidAndLessVolatile( - // tickersGroupId , - // maxNumberOfEligiblesToBeChosen ); bool temporizedGroup = true; --- 74,81 ---- protected override IEligiblesSelector getEligiblesSelector() { + int maxNumberOfEligiblesToBeChosen = 100; + string tickersGroupId = "SP500"; bool temporizedGroup = true; *************** *** 90,93 **** --- 84,97 ---- double maxPrice = 75; + int maxNumberOfMostLiquidTickersToBeChosen = 150; + int numDaysForVolatility = 10; + IEligiblesSelector eligiblesSelector = + new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( + tickersGroupId , temporizedGroup , + maxNumberOfEligiblesToBeChosen , + maxNumberOfMostLiquidTickersToBeChosen , + numDaysForAverageRawOpenPriceComputation , + numDaysForVolatility , + minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceMostLiquidAlwaysQuoted( *************** *** 96,108 **** // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); ! IEligiblesSelector eligiblesSelector = ! new ByPriceLessVolatileOTCAlwaysQuoted( ! tickersGroupId , temporizedGroup , ! maxNumberOfEligiblesToBeChosen , ! numDaysForAverageRawOpenPriceComputation , ! minPrice , maxPrice ); // eligiblesSelector = // new DummyEligibleSelector(); ! return eligiblesSelector; } --- 100,112 ---- // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); ! // IEligiblesSelector eligiblesSelector = ! // new ByPriceLessVolatileOTCAlwaysQuoted( ! // tickersGroupId , temporizedGroup , ! // maxNumberOfEligiblesToBeChosen , ! // numDaysForAverageRawOpenPriceComputation , ! // minPrice , maxPrice ); // eligiblesSelector = // new DummyEligibleSelector(); ! // return eligiblesSelector; } *************** *** 123,128 **** double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 200; ! numberOfBestTestingPositionsToBeReturned = 200; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; --- 127,132 ---- double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 100; ! numberOfBestTestingPositionsToBeReturned = 100; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; *************** *** 130,150 **** //correlation is computed only for returns //between minimum and maximum - IInSampleChooser inSampleChooser = - new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, - maxCorrelationAllowed , balancedWeightsOnVolatilityBase, - minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // IInSampleChooser inSampleChooser = ! // new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_04_14_18_21_45_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_182,80_maxDD_8,57\2008_04_14_18_21_45_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_182,80_maxDD_8,57.qpL", // numberOfBestTestingPositionsToBeReturned); //home // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_04_13_12_03_16_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_183.39_maxDD_8.71\2008_04_13_12_03_16_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_183.39_maxDD_8.71.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; --- 134,154 ---- //correlation is computed only for returns //between minimum and maximum // IInSampleChooser inSampleChooser = ! // new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); ! IInSampleChooser inSampleChooser = ! new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36.qpL", // numberOfBestTestingPositionsToBeReturned); //home // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; *************** *** 153,163 **** protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { ! int inSampleDays = 180; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 5; int numOfClosingsBeforeExit = 0; ! double oversoldThreshold = 0.01; ! double overboughtThreshold = 0.01; IEndOfDayStrategyForBacktester endOfDayStrategy // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , --- 157,170 ---- protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { ! int inSampleDays = 25; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 1; int numOfClosingsBeforeExit = 0; ! int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0025; ! double overboughtThreshold = 0.0025; ! double oversoldThresholdMAX = 0.05; ! double overboughtThresholdMAX = 0.05; IEndOfDayStrategyForBacktester endOfDayStrategy // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , *************** *** 165,171 **** // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); // ! = new PVO_OTCStrategy(eligiblesSelector ,inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsBeforeExit, oversoldThreshold , overboughtThreshold , historicalQuoteProvider); return endOfDayStrategy; } --- 172,180 ---- // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); // ! = new PVO_OTCStrategy(eligiblesSelector , ! minNumOfEligiblesForValidOptimization, inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsBeforeExit, oversoldThreshold , overboughtThreshold , ! oversoldThresholdMAX , overboughtThresholdMAX , historicalQuoteProvider); return endOfDayStrategy; } *************** *** 173,181 **** { string backTestId = "PVO_OTC"; ! IAccountProvider accountProvider = new SimpleAccountProvider(); ! double cashToStart = 30000; ! DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2004 , 12, 31 ); double maxRunningHours = 10; HistoricalQuoteProvider quoteProviderForBackTester = --- 182,194 ---- { string backTestId = "PVO_OTC"; ! IAccountProvider accountProvider; ! accountProvider = new SimpleAccountProvider(); ! // double fixedPercentageSlippage = 0.05; ! // accountProvider = ! // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); ! double cashToStart = 25000; ! DateTime firstDateTime = new DateTime( 2004 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2008 , 4, 28 ); double maxRunningHours = 10; HistoricalQuoteProvider quoteProviderForBackTester = Index: PVOLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOLogItem.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVOLogItem.cs 8 Apr 2008 21:55:33 -0000 1.3 --- PVOLogItem.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 191,194 **** --- 191,196 ---- numberOfPortfolioPositions , benchmark , int.MaxValue , + ((PVOPositions)positionsToTest[0]).OversoldThreshold, + ((PVOPositions)positionsToTest[0]).OverboughtThreshold, historicalQuoteProviderForStrategy , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); Index: PVOPositionsStatus.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositionsStatus.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVOPositionsStatus.cs 9 Mar 2008 22:49:24 -0000 1.1 --- PVOPositionsStatus.cs 14 Aug 2008 23:28:06 -0000 1.2 *************** *** 35,39 **** InTheMiddle, Overbought, ! TooDistantFromThresholds } } --- 35,39 ---- InTheMiddle, Overbought, ! OverMaximumThresholds } } Index: PVO_OTCStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCStrategy.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVO_OTCStrategy.cs 26 Apr 2008 09:51:23 -0000 1.4 --- PVO_OTCStrategy.cs 14 Aug 2008 23:28:06 -0000 1.5 *************** *** 71,74 **** --- 71,76 ---- protected double oversoldThreshold; protected double overboughtThreshold; + protected double oversoldThresholdMAX; + protected double overboughtThresholdMAX; //initialized after constructor's call protected int numDaysElapsedSinceLastOptimization; *************** *** 88,91 **** --- 90,95 ---- private int numOfClosingsToCrossBeforeExit; private int numOfClosingsWithOpenPositions; + private int minimumNumberOfEligiblesForValidOptimization; + private bool optimalPositionsHaveBeenUpdated; private string description_GetDescriptionForChooser() *************** *** 123,127 **** private void pvo_otcStrategy(IEligiblesSelector eligiblesSelector, ! int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, --- 127,132 ---- private void pvo_otcStrategy(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, *************** *** 129,136 **** --- 134,145 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { this.numOfClosingsWithOpenPositions = 0; this.eligiblesSelector = eligiblesSelector; + this.minimumNumberOfEligiblesForValidOptimization = + minimumNumberOfEligiblesForValidOptimization; this.inSampleDays = inSampleDays; this.benchmark = benchmark; *************** *** 139,146 **** --- 148,159 ---- this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; + this.oversoldThresholdMAX = oversoldThresholdMAX; + this.overboughtThresholdMAX = overboughtThresholdMAX; this.historicalQuoteProvider = historicalQuoteProvider; + this.optimalPositionsHaveBeenUpdated = false; } public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser, int inSampleDays, *************** *** 150,163 **** double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } - public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, --- 163,200 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, + historicalQuoteProvider); + this.inSampleChooser = inSampleChooser; + } + + public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, + IInSampleChooser inSampleChooser, + int inSampleDays, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider) + + { + this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, + inSampleDays , benchmark , numDaysBetweenEachOptimization , + numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, TestingPositions[] chosenPVOPositions, int inSampleDays, *************** *** 167,177 **** double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } #region MarketOpenEventHandler --- 204,241 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } + public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, + TestingPositions[] chosenPVOPositions, + int inSampleDays, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider) + + { + this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, + inSampleDays , benchmark , numDaysBetweenEachOptimization , + numOfClosingsToCrossBeforeExit, + oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, + historicalQuoteProvider); + this.chosenPVOPositions = chosenPVOPositions; + } + #region MarketOpenEventHandler *************** *** 195,199 **** currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) --- 259,264 ---- currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider, ! this.oversoldThresholdMAX, this.overboughtThresholdMAX); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) *************** *** 257,263 **** { if ( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null ) //portfolio is empty and optimization has ! //been already launched { try{ --- 322,329 ---- { if ( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null && ! this.optimalPositionsHaveBeenUpdated == true) //portfolio is empty and optimization has ! //been already successfully launched { try{ *************** *** 308,322 **** switch ( ((PVOCorrelationChooser)this.inSampleChooser).IntervalsType ) { ! case IntervalsType.CloseToCloseIntervals_OneDay: ! returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, 1); ! break; ! case IntervalsType.CloseToCloseIntervals_TwoDays: returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOf... [truncated message content] |