[Quantproject-developers] QuantProject/b2_DataAccess/Tables Quotes.cs,1.17,1.18
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-08-28 17:14:04
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8254/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: The method SetDataTable has been overloaded, to builda a Quotes data table containing a row for each ticker in a given collection, with the quotes for the given DateTime Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Quotes.cs 22 Aug 2004 16:56:25 -0000 1.17 --- Quotes.cs 28 Aug 2004 17:13:55 -0000 1.18 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Data; using System.Text; *************** *** 756,776 **** { string sql; ! if(Tickers_tickerGroups.HasTickers(tickerOrGroupID)) ! sql = "select * from quotes INNER JOIN tickers_tickerGroups ON " + ! "quotes." + Quotes.TickerFieldName + "=tickers_tickerGroups." + Tickers_tickerGroups.Ticker + " " + ! "where " + Tickers_tickerGroups.GroupID + "='" + tickerOrGroupID + "' " + ! "and " + Quotes.Date + ">=" + SQLBuilder.GetDateConstant( startDate ) + " " + ! "and " + Quotes.Date + "<=" + SQLBuilder.GetDateConstant( endDate ) + " " + ! "order by " + Quotes.Date; ! else ! sql = "select * from quotes " + ! "where " + Quotes.TickerFieldName + "='" + tickerOrGroupID + "' " + ! "and " + Quotes.Date + ">=" + SQLBuilder.GetDateConstant( startDate ) + " " + ! "and " + Quotes.Date + "<=" + SQLBuilder.GetDateConstant( endDate ) + " " + ! "order by " + Quotes.Date; ! SqlExecutor.SetDataTable( sql , dataTable ); } --- 757,815 ---- { string sql; ! if(Tickers_tickerGroups.HasTickers(tickerOrGroupID)) ! sql = "select * from quotes INNER JOIN tickers_tickerGroups ON " + ! "quotes." + Quotes.TickerFieldName + "=tickers_tickerGroups." + Tickers_tickerGroups.Ticker + " " + ! "where " + Tickers_tickerGroups.GroupID + "='" + tickerOrGroupID + "' " + ! "and " + Quotes.Date + ">=" + SQLBuilder.GetDateConstant( startDate ) + " " + ! "and " + Quotes.Date + "<=" + SQLBuilder.GetDateConstant( endDate ) + " " + ! "order by " + Quotes.Date; ! else ! sql = "select * from quotes " + ! "where " + Quotes.TickerFieldName + "='" + tickerOrGroupID + "' " + ! "and " + Quotes.Date + ">=" + SQLBuilder.GetDateConstant( startDate ) + " " + ! "and " + Quotes.Date + "<=" + SQLBuilder.GetDateConstant( endDate ) + " " + ! "order by " + Quotes.Date; ! SqlExecutor.SetDataTable( sql , dataTable ); } + #region SetDataTable for tickerList + private static string setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( + string ticker ) + { + return "(" + Quotes.TickerFieldName + "='" + ticker + "')"; + } + private static string setDataTable_getTickerListWhereClause( ICollection tickerCollection ) + { + string returnValue = ""; + foreach (string ticker in tickerCollection) + if ( returnValue == "" ) + // this is the first ticker to handle + returnValue += setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); + else + // this is not the first ticker to handle + returnValue += " or " + + setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); + return "( " + returnValue + " )"; + } + /// <summary> + /// Builds a Quotes data table containing a row for each ticker in the + /// collection, with the quotes for the given DateTime + /// </summary> + /// <param name="tickerCollection">Tickers whose quotes are to be fetched</param> + /// <param name="dateTime">Date for the quotes to be fetched</param> + /// <param name="dataTable">Output parameter</param> + public static void SetDataTable( ICollection tickerCollection , DateTime dateTime , DataTable dataTable) + { + string sql; + sql = "select * from quotes " + + "where " + setDataTable_getTickerListWhereClause( tickerCollection ) + + " and " + Quotes.Date + "=" + SQLBuilder.GetDateConstant( dateTime ) + " " + + "order by " + Quotes.TickerFieldName; + + SqlExecutor.SetDataTable( sql , dataTable ); + } + #endregion + |