[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag WeightedPositi
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-08-12 19:09:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19348/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WeightedPositions.cs Log Message: Added the Indexer construct, for an array-like access to the WeightedPositions' items. Added GetOpenToCloseReturn method. Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WeightedPositions.cs 8 Aug 2007 18:31:35 -0000 1.8 --- WeightedPositions.cs 12 Aug 2007 19:09:41 -0000 1.9 *************** *** 153,156 **** --- 153,168 ---- return (WeightedPosition)this.GetByIndex( i ); } + public WeightedPosition this[ int index ] + { + get + { + return (WeightedPosition)this.GetByIndex( index ); + } + set + { + this.SetByIndex( index, value ); + } + } + #region GetEquityLine /// <summary> *************** *** 532,535 **** --- 544,564 ---- return returns; } + /// <summary> + /// Gets the Open To Close return for the current instance of WeightedPositions + /// </summary> + /// <param name="marketDate">Market date for which return has to be computed</param> + public double GetOpenToCloseReturn(DateTime marketDate) + { + Quotes[] tickersQuotes = new Quotes[this.Count]; + for(int i = 0; i<this.Count; i++) + tickersQuotes[i] = new Quotes( this[i].Ticker,marketDate,marketDate ); + double openToCloseReturn = 0.0; + for(int i = 0; i < this.Count ; i++) + openToCloseReturn += + ( (float)tickersQuotes[i].Rows[0]["quClose"] / + (float)tickersQuotes[i].Rows[0]["quOpen"] - 1.0f ) * + (float)this[i].Weight; + return openToCloseReturn; + } } } |