[Quantproject-developers] QuantProject/b3_Data/DataProviders HistoricalDataProvider.cs,1.2,1.3
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-11-29 16:05:27
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18780/b3_Data/DataProviders Modified Files: HistoricalDataProvider.cs Log Message: An automatic quote caching tecnique has been implemented. Index: HistoricalDataProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/HistoricalDataProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalDataProvider.cs 28 Aug 2004 17:24:57 -0000 1.2 --- HistoricalDataProvider.cs 29 Nov 2004 16:05:04 -0000 1.3 *************** *** 126,138 **** } public static double GetMarketValue( string instrumentKey , ExtendedDateTime extendedDateTime ) ! { ! //DateTime dateTime = ! return Convert.ToDouble( ! ( (History) ((Hashtable) ! cachedHistories[ instrumentKey ])[ extendedDateTime.BarComponent ] ).GetByIndex( ! ( (History) ((Hashtable) cachedHistories[ instrumentKey ])[ extendedDateTime.BarComponent ] ! ).IndexOfKeyOrPrevious( extendedDateTime.DateTime ) ) ); ! } /// <summary> --- 126,161 ---- } + private static void cache( string instrumentKey , BarComponent barComponent ) + { + if ( !cachedHistories.ContainsKey( instrumentKey ) ) + // no component at all for the instrument instrumentKey has been cached yet + cachedHistories.Add( instrumentKey , new Hashtable() ); + ((Hashtable)cachedHistories[ instrumentKey ]).Add( barComponent , + DataBase.GetHistory( instrumentKey , barComponent ) ); + } public static double GetMarketValue( string instrumentKey , ExtendedDateTime extendedDateTime ) ! { ! if ( !cachedHistories.ContainsKey( instrumentKey ) || ! !(((Hashtable)cachedHistories[ instrumentKey ]).ContainsKey( ! extendedDateTime.BarComponent)) ) ! // the instrument instrumentKey has not been cached yet, for the given bar component ! cache( instrumentKey , extendedDateTime.BarComponent ); ! return Convert.ToDouble( ! ( (History) ((Hashtable) ! cachedHistories[ instrumentKey ])[ extendedDateTime.BarComponent ] ).GetByIndex( ! ( (History) ((Hashtable) cachedHistories[ instrumentKey ])[ extendedDateTime.BarComponent ] ! ).IndexOfKeyOrPrevious( extendedDateTime.DateTime ) ) ); ! } ! ! public static double GetMarketValue( string instrumentKey , DateTime dateTime , ! BarComponent barComponent ) ! { ! //DateTime dateTime = ! return Convert.ToDouble( ! ( (History) ((Hashtable) ! cachedHistories[ instrumentKey ])[ barComponent ] ).GetByIndex( ! ( (History) ((Hashtable) cachedHistories[ instrumentKey ])[ barComponent ] ! ).IndexOfKeyOrPrevious( dateTime ) ) ); ! } /// <summary> |