Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23216/b7_Scripts/WalkForwardTesting/WalkForwardLag
Modified Files:
WeightedPositions.cs
Log Message:
A new constructor has been added.
Added new properties (NumberOfLongPositions and NumberOfShortPositions).
Other minor changes.
Index: WeightedPositions.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** WeightedPositions.cs 7 Aug 2007 16:51:44 -0000 1.7
--- WeightedPositions.cs 8 Aug 2007 18:31:35 -0000 1.8
***************
*** 48,52 ****
get { return getType(); }
}
! public WeightedPositions( double[] normalizedWeightValues ,
string[] tickers )
{
--- 48,85 ----
get { return getType(); }
}
!
! private int numberOfLongPositions = int.MaxValue;
! private int numberOfShortPositions = int.MaxValue;
!
! public int NumberOfLongPositions {
! get {
! if(this.numberOfLongPositions == int.MaxValue)
! //that is private field has not been assigned yet
! {
! this.numberOfLongPositions = 0;
! foreach(WeightedPosition weightedPosition in this)
! if(weightedPosition.IsLong)
! this.numberOfLongPositions++;
! }
! return this.numberOfLongPositions;
! }
! }
!
! public int NumberOfShortPositions {
! get {
! if(this.numberOfShortPositions == int.MaxValue)
! //that is private field has not been assigned yet
! {
! this.numberOfShortPositions = 0;
! foreach(WeightedPosition weightedPosition in this)
! if(weightedPosition.IsShort)
! this.numberOfShortPositions++;
! }
! return this.numberOfShortPositions;
! }
! }
!
!
! private void weightedPositions_default( double[] normalizedWeightValues ,
string[] tickers )
{
***************
*** 58,65 ****
if ( !this.ContainsKey( ticker ) )
this.Add( ticker , new WeightedPosition( weight , ticker ) );
- else
- ((WeightedPosition)this[ ticker ]).Weight += weight;
}
}
#region checkParameters
private void checkParameters_checkDoubleTickers( string[] tickers )
--- 91,120 ----
if ( !this.ContainsKey( ticker ) )
this.Add( ticker , new WeightedPosition( weight , ticker ) );
}
}
+
+ public WeightedPositions( double[] normalizedWeightValues ,
+ string[] tickers )
+ {
+ this.weightedPositions_default( normalizedWeightValues,
+ tickers );
+ }
+
+ public WeightedPositions( double[] normalizedUnsignedWeightValues,
+ SignedTickers signedTickers )
+ {
+ string[] unsignedTickers = new string [ signedTickers.Count ];
+ double[] normalizedSignedWeightValues =
+ new double[ normalizedUnsignedWeightValues.Length ];
+ for(int i = 0; i < signedTickers.Count; i++)
+ {
+ unsignedTickers[i] = signedTickers[i].Ticker;
+ normalizedSignedWeightValues[i] =
+ signedTickers[i].Multiplier * normalizedUnsignedWeightValues[i];
+ }
+ this.weightedPositions_default(normalizedSignedWeightValues,
+ unsignedTickers);
+ }
+
#region checkParameters
private void checkParameters_checkDoubleTickers( string[] tickers )
|