[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination ExtremeCoun
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2006-08-07 21:10:45
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25183/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: ExtremeCounterTrendStrategy.cs Log Message: Minor changes for ECT strategy. Index: ExtremeCounterTrendStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/ExtremeCounterTrendStrategy.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExtremeCounterTrendStrategy.cs 2 Jul 2006 19:22:12 -0000 1.2 --- ExtremeCounterTrendStrategy.cs 7 Aug 2006 21:10:36 -0000 1.3 *************** *** 47,55 **** private int numOfClosesElapsed = 0; private int numOfDaysWithOpenPosition = 0; public ExtremeCounterTrendStrategy( Account account , string[] signedTickers, double[] weightsForSignedTickers, ! int numDaysForReturnCalculation) { this.account = account; --- 47,57 ---- private int numOfClosesElapsed = 0; private int numOfDaysWithOpenPosition = 0; + private PortfolioType portfolioType; public ExtremeCounterTrendStrategy( Account account , string[] signedTickers, double[] weightsForSignedTickers, ! int numDaysForReturnCalculation, ! PortfolioType portfolioType) { this.account = account; *************** *** 57,60 **** --- 59,63 ---- this.weightsForSignedTickers = weightsForSignedTickers; this.numDaysForReturnCalculation = numDaysForReturnCalculation; + this.portfolioType = portfolioType; } *************** *** 125,135 **** if(lastHalfPeriodGain < 0.0) this.marketCloseEventHandler_addOrders(); ! else { SignedTicker.ChangeSignOfEachTicker(this.signedTickers); ! //short the portfolio ! try{this.marketCloseEventHandler_addOrders();} ! catch(Exception ex){ex = ex;} ! finally{SignedTicker.ChangeSignOfEachTicker(this.signedTickers);} } } --- 128,148 ---- if(lastHalfPeriodGain < 0.0) this.marketCloseEventHandler_addOrders(); ! else if (lastHalfPeriodGain > 0.0 && ! this.portfolioType == PortfolioType.ShortAndLong ) ! //if gain of the last half period is positive and ! //original positions can be reversed { SignedTicker.ChangeSignOfEachTicker(this.signedTickers); ! //short the portfolio (short --> long; long --> short) ! try{ ! this.marketCloseEventHandler_addOrders(); ! } ! catch(Exception ex) ! { ! ex = ex; ! } ! finally{ ! SignedTicker.ChangeSignOfEachTicker(this.signedTickers); ! } } } *************** *** 149,152 **** --- 162,167 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { + this.numOfClosesElapsed++; + if(this.account.Transactions.Count == 0) this.account.AddCash(30000); *************** *** 157,168 **** if(this.numOfDaysWithOpenPosition == this.numDaysForReturnCalculation) this.marketCloseEventHandler_closePositions(); ! if(this.account.Portfolio.Count == 0 && ! (this.numOfClosesElapsed + 1) >= this.numDaysForReturnCalculation) ! //portfolio is empty and previous closes can be now checked ! if(this.account.Portfolio.Count == 0) this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); - - this.numOfClosesElapsed++; } --- 172,180 ---- if(this.numOfDaysWithOpenPosition == this.numDaysForReturnCalculation) this.marketCloseEventHandler_closePositions(); ! if(this.account.Portfolio.Count == 0 && ! this.numOfClosesElapsed >= this.numDaysForReturnCalculation) ! //portfolio is empty and previous closes can be now checked this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); } |