[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/Immediate
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-08-29 09:44:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower Modified Files: EndOfDayTimerHandlerITF.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: EndOfDayTimerHandlerITF.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower/EndOfDayTimerHandlerITF.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandlerITF.cs 17 Sep 2006 21:48:39 -0000 1.3 --- EndOfDayTimerHandlerITF.cs 29 Aug 2007 09:43:31 -0000 1.4 *************** *** 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 DateTime lastCloseDate; --- 49,52 ---- *************** *** 113,119 **** (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; returnValue = ! SignedTicker.GetCloseToClosePortfolioReturn( ! this.chosenTickers, this.chosenTickersPortfolioWeights, ! initialDateForHalfPeriod,finalDateForHalfPeriod); } catch(MissingQuotesException ex) --- 108,112 ---- (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; returnValue = ! chosenWeightedPositions.GetCloseToCloseReturn(initialDateForHalfPeriod,finalDateForHalfPeriod); } catch(MissingQuotesException ex) *************** *** 132,142 **** { if(lastHalfPeriodGain > 0.0) ! base.openPositions(this.chosenTickers); else//the last HalfPeriodGain has been negative { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); //short the portfolio try{ ! base.openPositions(this.chosenTickers); } catch(Exception ex) --- 125,135 ---- { if(lastHalfPeriodGain > 0.0) ! AccountManager.OpenPositions(chosenWeightedPositions, this.account); else//the last HalfPeriodGain has been negative { ! chosenWeightedPositions.Reverse(); //short the portfolio try{ ! AccountManager.OpenPositions(chosenWeightedPositions, this.account); } catch(Exception ex) *************** *** 145,149 **** } finally{ ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); } } --- 138,142 ---- } finally{ ! chosenWeightedPositions.Reverse(); } } *************** *** 157,161 **** { //Close if halfPeriod has elapsed or stop loss condition reached ! base.closePositions(); this.daysCounterWithPositions = 0; } --- 150,154 ---- { //Close if halfPeriod has elapsed or stop loss condition reached ! AccountManager.ClosePositions(this.account); this.daysCounterWithPositions = 0; } *************** *** 169,173 **** this.daysCounterWithPositions++; this.marketCloseEventHandler_closePositions(); ! if(this.chosenTickers[0] != null) //tickers to buy have been chosen { --- 162,166 ---- this.daysCounterWithPositions++; this.marketCloseEventHandler_closePositions(); ! if(chosenWeightedPositions != null) //tickers to buy have been chosen { *************** *** 244,248 **** { 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 --- 237,241 ---- { 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 *************** *** 266,271 **** ((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 --- 259,264 ---- ((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 *************** *** 284,288 **** this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; - this.orders.Clear(); if((this.numDaysElapsedSinceLastOptimization - 1 == this.numDaysBetweenEachOptimization)) //|| this.isTheFirstClose ) --- 277,280 ---- |