[Quantproject-developers] QuantProject/b4_Business/a2_Strategies WeightedPositions.cs, 1.13, 1.14
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-02-27 22:17:13
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14360/a2_Strategies Modified Files: WeightedPositions.cs Log Message: The read only property public WeightedPositions Opposite has been added Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** WeightedPositions.cs 14 Jan 2008 23:27:26 -0000 1.13 --- WeightedPositions.cs 27 Feb 2008 22:17:10 -0000 1.14 *************** *** 118,121 **** --- 118,144 ---- get { return this.ToString(); } } + + /// <summary> + /// returns a new WeightedPositions object, obtained by the current instance, + /// but reversing the sign of each weight for each position: + /// long positions become then short positions and viceversa + /// </summary> + public WeightedPositions Opposite + { + get + { + double[] oppositeWeights = new Double[ this.Count ]; + string[] tickers = new String[ this.Count ]; + for ( int i = 0 ; i < this.Count ; i++ ) + { + tickers[ i ] = ((WeightedPosition)(this[ i ])).Ticker; + oppositeWeights[ i ] = -((WeightedPosition)(this[ i ])).Weight; + } + WeightedPositions opposite = new WeightedPositions( + oppositeWeights , tickers ); + return opposite; + } + } + private void weightedPositions_default( double[] normalizedWeightValues , string[] tickers ) |