[Quantproject-developers] QuantProject/b3_Data/DataProviders HistoricalDataProvider.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-08-28 17:25:06
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10451/b3_Data/DataProviders Modified Files: HistoricalDataProvider.cs Log Message: Added the GetQuotes method, to return the hashtable containing, for each ticker, the quote for the given extended date time Index: HistoricalDataProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/HistoricalDataProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalDataProvider.cs 23 Aug 2004 22:33:57 -0000 1.1 --- HistoricalDataProvider.cs 28 Aug 2004 17:24:57 -0000 1.2 *************** *** 145,148 **** --- 145,181 ---- return Quotes.GetTickerQuotes( instrumentKey ); } + #region GetQuotes + private static double getQuotes_getQuoteValue( DataRow dataRow , ExtendedDateTime extendedDateTime ) + { + double returnValue; + /// TO DO: evaluate to use a Quote class, that derives from the DataRow class + /// and use properties instead of dataRow accessing + if ( extendedDateTime.BarComponent == BarComponent.Open ) + returnValue = (double)dataRow[ QuantProject.Data.DataTables.Quotes.Open ] * + (double)dataRow[ QuantProject.Data.DataTables.Quotes.AdjustedClose ] / + (double)dataRow[ QuantProject.Data.DataTables.Quotes.Close ]; + else + returnValue = (double)dataRow[ QuantProject.Data.DataTables.Quotes.AdjustedClose ]; + return returnValue; + } + /// <summary> + /// Returns the hashtable containing, for each ticker, the + /// quote for the given extended date time + /// </summary> + /// <param name="tickerCollection">List of tickers whose quotes are to be fetched</param> + /// <param name="extendedDateTime"></param> + /// <returns></returns> + public static Hashtable GetQuotes( ICollection tickerCollection , + ExtendedDateTime extendedDateTime ) + { + Hashtable returnValue = new Hashtable(); + QuantProject.Data.DataTables.Quotes quotes = + new QuantProject.Data.DataTables.Quotes( tickerCollection ,extendedDateTime.DateTime ); + foreach (DataRow dataRow in quotes.Rows) + returnValue.Add( dataRow[ QuantProject.Data.DataTables.Quotes.TickerFieldName ] , + getQuotes_getQuoteValue( dataRow , extendedDateTime ) ); + return returnValue; + } + #endregion } } |