[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCount
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/ExtremeCounterTrend In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend Modified Files: EndOfDayTimerHandlerECT.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: EndOfDayTimerHandlerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/EndOfDayTimerHandlerECT.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerECT.cs 17 Sep 2006 21:48:39 -0000 1.5 --- EndOfDayTimerHandlerECT.cs 29 Aug 2007 09:43:30 -0000 1.6 *************** *** 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 ---- *************** *** 119,125 **** DateTime finalDateForHalfPeriod = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! returnValue = ! SignedTicker.GetCloseToClosePortfolioReturn( ! this.chosenTickers, this.chosenTickersPortfolioWeights, initialDateForHalfPeriod,finalDateForHalfPeriod); } --- 114,118 ---- DateTime finalDateForHalfPeriod = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! returnValue = this.chosenWeightedPositions.GetCloseToCloseReturn( initialDateForHalfPeriod,finalDateForHalfPeriod); } *************** *** 139,150 **** { if(lastHalfPeriodGain < 0.0) ! base.openPositions(this.chosenTickers); else if (lastHalfPeriodGain > 0.0 && this.portfolioType == PortfolioType.ShortAndLong) { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); //short the portfolio try{ ! base.openPositions(this.chosenTickers); } catch(Exception ex) --- 132,145 ---- { if(lastHalfPeriodGain < 0.0) ! AccountManager.OpenPositions(this.chosenWeightedPositions, ! this.account); else if (lastHalfPeriodGain > 0.0 && this.portfolioType == PortfolioType.ShortAndLong) { ! this.chosenWeightedPositions.Reverse(); //short the portfolio try{ ! AccountManager.OpenPositions(this.chosenWeightedPositions, ! this.account); } catch(Exception ex) *************** *** 153,157 **** } finally{ ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); } } --- 148,152 ---- } finally{ ! this.chosenWeightedPositions.Reverse(); } } *************** *** 165,170 **** { //Close if halfPeriod has elapsed or stop loss condition reached ! base.closePositions(); ! this.daysCounterWithPositions = 0; } } --- 160,165 ---- { //Close if halfPeriod has elapsed or stop loss condition reached ! AccountManager.ClosePositions(this.account); ! this.daysCounterWithPositions = 0; } } *************** *** 177,181 **** //this.marketCloseEventHandler_updateStopLossCondition(); this.marketCloseEventHandler_closePositions(); ! if(this.chosenTickers[0] != null) //tickers to buy have been chosen { --- 172,176 ---- //this.marketCloseEventHandler_updateStopLossCondition(); this.marketCloseEventHandler_closePositions(); ! if(this.chosenWeightedPositions != null) //tickers to buy have been chosen { *************** *** 253,260 **** { 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 - { this.iGenomeManager = --- 248,254 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenWeightedPositions.Count*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen { this.iGenomeManager = *************** *** 281,286 **** ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, this.numDaysForReturnCalculation, this.portfolioType, GO.GenerationCounter); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio --- 275,284 ---- ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, this.numDaysForReturnCalculation, this.portfolioType, GO.GenerationCounter); ! // this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! // this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! SignedTickers signedTickers = new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers ); ! this.chosenWeightedPositions = ! new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! signedTickers); } //else it will be buyed again the previous optimized portfolio *************** *** 299,303 **** this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; - this.orders.Clear(); if((this.numDaysElapsedSinceLastOptimization - 1 == this.numDaysBetweenEachOptimization)) //|| this.isTheFirstClose ) --- 297,300 ---- |