[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOs
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-04-26 09:51:27
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32398/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVO_OTCStrategy.cs Log Message: The updateReturnsManager method's implementation now depends on ReturnIntervalsType property. It is now possible to choose how many MarketClosings are to be crossed before closing all positions. Index: PVO_OTCStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCStrategy.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVO_OTCStrategy.cs 8 Apr 2008 22:03:00 -0000 1.3 --- PVO_OTCStrategy.cs 26 Apr 2008 09:51:23 -0000 1.4 *************** *** 45,48 **** --- 45,49 ---- using QuantProject.Data.DataTables; using QuantProject.ADT.Optimizing.Genetic; + using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; *************** *** 85,89 **** set { this.account = value; } } ! private string description_GetDescriptionForChooser() { --- 86,92 ---- set { this.account = value; } } ! private int numOfClosingsToCrossBeforeExit; ! private int numOfClosingsWithOpenPositions; ! private string description_GetDescriptionForChooser() { *************** *** 123,134 **** --- 126,140 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { + this.numOfClosingsWithOpenPositions = 0; this.eligiblesSelector = eligiblesSelector; this.inSampleDays = inSampleDays; this.benchmark = benchmark; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; + this.numOfClosingsToCrossBeforeExit = numOfClosingsToCrossBeforeExit; this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; *************** *** 141,144 **** --- 147,151 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, *************** *** 147,151 **** { this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; --- 154,158 ---- { this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; *************** *** 157,160 **** --- 164,168 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, *************** *** 163,167 **** { this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } --- 171,175 ---- { this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } *************** *** 278,282 **** { if(this.account.Portfolio.Count > 0) ! AccountManager.ClosePositions(this.account); } --- 286,297 ---- { if(this.account.Portfolio.Count > 0) ! { ! this.numOfClosingsWithOpenPositions++; ! if(this.numOfClosingsWithOpenPositions > this.numOfClosingsToCrossBeforeExit) ! { ! AccountManager.ClosePositions(this.account); ! this.numOfClosingsWithOpenPositions = 0; ! } ! } } *************** *** 286,293 **** EndOfDayDateTime lastEndOfDayDateTime) { ! this.returnsManager = ! new ReturnsManager( new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker ) , ! this.historicalQuoteProvider); } --- 301,346 ---- EndOfDayDateTime lastEndOfDayDateTime) { ! ReturnIntervals returnIntervals = ! new DailyOpenToCloseIntervals( firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker ); ! if( this.inSampleChooser is PVOCorrelationChooser ) ! { ! 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, lastEndOfDayDateTime, ! this.benchmark.Ticker, 2); ! break; ! case IntervalsType.CloseToCloseIntervals_FiveDays: ! returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, 5); ! break; ! case IntervalsType.CloseToOpenIntervals: ! returnIntervals = new CloseToOpenIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker); ! break; ! case IntervalsType.DailyOpenToCloseIntervals: ! returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker ); ! break; ! case IntervalsType.OpenToCloseCloseToOpenIntervals: ! returnIntervals = new OpenToCloseCloseToOpenIntervals( ! firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker); ! break; ! default: ! // it should never be reached ! returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker ); ! break; ! } ! } ! ! this.returnsManager = ! new ReturnsManager( returnIntervals , this.historicalQuoteProvider); ! } |