[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedPeriodO
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-08-29 09:44:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedPeriodOscillators In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedPeriodOscillators Modified Files: EndOfDayTimerHandlerFPOscillatorCTC.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerFPOscillatorCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedPeriodOscillators/EndOfDayTimerHandlerFPOscillatorCTC.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandlerFPOscillatorCTC.cs 17 Sep 2006 21:48:39 -0000 1.4 --- EndOfDayTimerHandlerFPOscillatorCTC.cs 29 Aug 2007 09:43:30 -0000 1.5 *************** *** 49,57 **** private int numDaysForReturnCalculation; private double maxAcceptableCloseToCloseDrawdown; - private bool stopLossConditionReached; - private double currentAccountValue; - private double previousAccountValue; - private int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; private int daysCounterWithPositions; private int daysCounterWithRightPositions; --- 49,52 ---- *************** *** 109,119 **** } - private void marketCloseEventHandler_reverseSignOfTickers(string[] signedTickers) - { - for(int i = 0; i<signedTickers.Length; i++) - if(signedTickers[i] != null) - signedTickers[i] = SignedTicker.GetOppositeSignedTicker(signedTickers[i]); - } - private void marketCloseEventHandler_updateCounters(bool isTheFirstClose) { --- 104,107 ---- *************** *** 138,144 **** (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; gainForTheLastHalfPeriod = ! SignedTicker.GetCloseToClosePortfolioReturn( ! this.chosenTickers, this.chosenTickersPortfolioWeights, ! initialDateForHalfPeriod,finalDateForHalfPeriod); if(gainForTheLastHalfPeriod < 0.0) //in the last periods the combination has lost, so --- 126,130 ---- (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; gainForTheLastHalfPeriod = ! chosenWeightedPositions.GetCloseToCloseReturn(initialDateForHalfPeriod,finalDateForHalfPeriod); if(gainForTheLastHalfPeriod < 0.0) //in the last periods the combination has lost, so *************** *** 158,162 **** { if(this.marketCloseEventHandler_openPositionsIfTuned_isTuned(timer)) ! base.openPositions(this.chosenTickers); } --- 144,148 ---- { if(this.marketCloseEventHandler_openPositionsIfTuned_isTuned(timer)) ! AccountManager.OpenPositions(this.chosenWeightedPositions, this.account); } *************** *** 168,173 **** { //Close if halfPeriod has elapsed or stop loss condition reached ! base.closePositions(); ! this.daysCounterWithPositions = 0; } } --- 154,159 ---- { //Close if halfPeriod has elapsed or stop loss condition reached ! AccountManager.ClosePositions(this.account); ! this.daysCounterWithPositions = 0; } } *************** *** 179,183 **** if(this.account.Portfolio.Count == 0 && ! this.chosenTickers[0] != null) //portfolio is empty and tickers to buy have been chosen this.marketCloseEventHandler_openPositionsIfTuned((IndexBasedEndOfDayTimer)sender); --- 165,169 ---- if(this.account.Portfolio.Count == 0 && ! this.chosenWeightedPositions != null) //portfolio is empty and tickers to buy have been chosen this.marketCloseEventHandler_openPositionsIfTuned((IndexBasedEndOfDayTimer)sender); *************** *** 277,281 **** { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen --- 263,267 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 311,316 **** ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, this.numDaysForReturnCalculation); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio --- 297,302 ---- ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, this.numDaysForReturnCalculation); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 329,333 **** this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; - this.orders.Clear(); if((this.numDaysElapsedSinceLastOptimization - 1 == this.numDaysBetweenEachOptimization)) //|| this.isTheFirstClose ) --- 315,318 ---- |