Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9429/b7_Scripts/WalkForwardTesting/WalkForwardLag
Modified Files:
WeightedPositions.cs
Log Message:
- the public static method AreValidTickers has been added
- the constructor's parameter are further checked now: no duplicate is allowed for tickers
Index: WeightedPositions.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WeightedPositions.cs 31 Jul 2006 16:42:29 -0000 1.1
--- WeightedPositions.cs 8 Sep 2006 15:32:27 -0000 1.2
***************
*** 59,62 ****
--- 59,74 ----
}
}
+ #region checkParameters
+ private void checkParameters_checkDoubleTickers( string[] tickers )
+ {
+ SortedList sortedTicker = new SortedList();
+ foreach ( string ticker in tickers )
+ if ( !sortedTicker.ContainsKey( ticker ) )
+ sortedTicker.Add( ticker , ticker );
+ else
+ throw new Exception( "The WeightedPositions constructur " +
+ "has received a tickers parameter with the ticker '" +
+ ticker + "' that is contained twice! This is not allowed." );
+ }
private void checkParameters( double[] normalizedWeightValues ,
string[] tickers )
***************
*** 72,76 ****
--- 84,90 ----
"should sum up to 1, " +
"but it sums up to " + totalWeight.ToString() );
+ this.checkParameters_checkDoubleTickers( tickers );
}
+ #endregion
public WeightedPosition GetWeightedPosition( string ticker )
{
***************
*** 250,253 ****
--- 264,278 ----
}
#endregion
+ /// <summary>
+ /// It controls if a WeightedPositions class may be build on the
+ /// given tickers
+ /// </summary>
+ /// <param name="tickers"></param>
+ /// <returns></returns>
+ public static bool AreValidTickers( string[] tickers )
+ {
+ return !QuantProject.ADT.Collections.CollectionManager.ContainsDuplicates(
+ tickers );
+ }
}
|