Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3064/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower
Modified Files:
GenomeManagerITF.cs EndOfDayTimerHandlerITF.cs
Log Message:
Minor changes:
-formatting changes;
-changes in parameters.
Index: GenomeManagerITF.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower/GenomeManagerITF.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** GenomeManagerITF.cs 3 Aug 2006 21:14:13 -0000 1.1
--- GenomeManagerITF.cs 17 Sep 2006 21:48:39 -0000 1.2
***************
*** 90,116 ****
private double[] getFitnessValue_getEquityLineRates()
{
! double[] returnValue = new double[this.PortfolioRatesOfReturn.Length];
! double gainForTheLastHalfPeriod = 0.0;
for(int i = this.numDaysForReturnCalculation - 1;
! i<this.PortfolioRatesOfReturn.Length - this.numDaysForReturnCalculation;
! i += this.numDaysForReturnCalculation)
{
! gainForTheLastHalfPeriod = 0.0;
for(int j=this.numDaysForReturnCalculation - 1;
! j > -1; j--)
{
! gainForTheLastHalfPeriod =
! (1.0+gainForTheLastHalfPeriod) * this.PortfolioRatesOfReturn[i-j];
}
!
for(int t=1;t<this.numDaysForReturnCalculation + 1;t++)
{
! if(gainForTheLastHalfPeriod<0.0)
! // if gain of first half period is negative
! returnValue[i+t] = - this.PortfolioRatesOfReturn[i+t];
! //return of the next half period is still negative
! else// if gain of first half period is positive
! returnValue[i+t] = this.PortfolioRatesOfReturn[i+t];
! //return of the next half period is still positive
}
--- 90,119 ----
private double[] getFitnessValue_getEquityLineRates()
{
! double[] returnValue = new double[this.PortfolioRatesOfReturn.Length];
! double K;//initial capital invested at the beginning of the period
for(int i = this.numDaysForReturnCalculation - 1;
! i<this.PortfolioRatesOfReturn.Length - this.numDaysForReturnCalculation;
! i += this.numDaysForReturnCalculation)
{
! K = 1.0;
for(int j=this.numDaysForReturnCalculation - 1;
! j > -1; j--)
{
! K = K + K * this.PortfolioRatesOfReturn[i-j];
}
!
for(int t=1;t<this.numDaysForReturnCalculation + 1;t++)
{
! if(K < 1.0 && this.PortfolioType == PortfolioType.ShortAndLong)
! // if gain of first half period is negative and
! //positions can be reversed
! returnValue[i+t] = - this.PortfolioRatesOfReturn[i+t];
! else if(K > 1.0)
! //if gain of first half period is positive
! returnValue[i+t] = this.PortfolioRatesOfReturn[i+t];
! else if(K < 1.0 && this.PortfolioType != PortfolioType.ShortAndLong)
! //if gain of first half period is negative and
! //original positions can't be reversed
! returnValue[i+t] = 0.0;//out of the market
}
Index: EndOfDayTimerHandlerITF.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower/EndOfDayTimerHandlerITF.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EndOfDayTimerHandlerITF.cs 7 Aug 2006 21:09:15 -0000 1.2
--- EndOfDayTimerHandlerITF.cs 17 Sep 2006 21:48:39 -0000 1.3
***************
*** 132,136 ****
{
if(lastHalfPeriodGain > 0.0)
! base.openPositions();
else//the last HalfPeriodGain has been negative
{
--- 132,136 ----
{
if(lastHalfPeriodGain > 0.0)
! base.openPositions(this.chosenTickers);
else//the last HalfPeriodGain has been negative
{
***************
*** 138,142 ****
//short the portfolio
try{
! base.openPositions();
}
catch(Exception ex)
--- 138,142 ----
//short the portfolio
try{
! base.openPositions(this.chosenTickers);
}
catch(Exception ex)
|