[Quantproject-developers] QuantProject/b2_DataAccess DataBase.cs,1.5,1.6
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2005-05-26 23:44:19
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28833/b2_DataAccess Modified Files: DataBase.cs Log Message: getHistory_common() private method has been introduced: now an History can be asked specifying the first date and the second date. Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DataBase.cs 9 Jan 2005 22:22:36 -0000 1.5 --- DataBase.cs 26 May 2005 23:44:07 -0000 1.6 *************** *** 84,92 **** #region "GetHistory" ! private static History getHistory_try( string instrumentKey , QuoteField quoteField ) { History history = new History(); string commandString = ! "select * from quotes where quTicker='" + instrumentKey + "'"; OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , oleDbConnection ); DataTable dataTable = new DataTable(); --- 84,95 ---- #region "GetHistory" ! private static History getHistory_try( string instrumentKey , QuoteField quoteField , ! DateTime firstDate , DateTime lastDate ) { History history = new History(); string commandString = ! "select * from quotes where (quTicker='" + instrumentKey + "') " + ! "and (quDate>=" + SQLBuilder.GetDateConstant( firstDate ) + ") " + ! "and (quDate<=" + SQLBuilder.GetDateConstant( lastDate ) + ")"; OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , oleDbConnection ); DataTable dataTable = new DataTable(); *************** *** 95,168 **** return history; } ! /// <summary> ! /// Returns the full history for the instrument and the specified quote field ! /// </summary> ! /// <param name="instrumentKey">Identifier (ticker) for the instrument whose story ! /// has to be returned</param> ! /// <param name="quoteField">Discriminates among Open, High, Low and Closure</param> ! /// <returns>The history for the given instrument and quote field</returns> ! public static History GetHistory( string instrumentKey , QuoteField quoteField ) ! { ! History history; ! try ! { ! history = getHistory_try( instrumentKey , quoteField ); ! } ! catch (Exception ex) ! { ! MessageBox.Show( ex.ToString() ); ! history = null; ! } ! return history; ! } ! #endregion ! // #region "GetHistories" ! // private static Single getHistories_try_getValue( DataRow dataRow , DateTime dateTime , ! // QuoteField quoteField ) ! // { ! // Single returnValue; ! // if ( quoteField == QuoteField.cl ) ! // returnValue = (Single)dataRow[ getFieldName( quoteField ) ]; ! // else ! // returnValue = (Single)dataRow[ getFieldName( quoteField ) ] * ! // (Single)dataRow[ "quAdjustedClose" ] / (Single)dataRow[ "quClose" ]; ! // return returnValue; ! // } ! // private static Hashtable getHistories_try( string instrumentKey , Hashtable barComponents , DateTime startDateTime , DateTime endDateTime ) ! // { ! // Hashtable histories = new Hashtable(); ! // foreach (BarComponent barComponent in barComponents.Keys) ! // histories.Add( barComponent , new History() ); ! // string commandString = ! // "select * from quotes where quTicker='" + instrumentKey + "' and " + ! // "quDate>=" + SQLBuilder.GetDateConstant( startDateTime ) + " and " + ! // "quDate<=" + SQLBuilder.GetDateConstant( endDateTime ); ! // OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , oleDbConnection ); ! // DataSet dataSet = new DataSet(); ! // oleDbDataAdapter.Fill( dataSet , "history" ); ! // foreach ( DataRow dataRow in dataSet.Tables[ "history" ].Rows ) ! // foreach ( BarComponent barComponent in barComponents.Keys ) ! // ((History) histories[ barComponent ]).Add( (DateTime) dataRow[ "quDate" ] , ! // getHistories_try_getValue( dataRow , (DateTime) dataRow[ "quDate" ] , barComponent ) ); ! //// ((History) histories[ barComponent ]).Add( (DateTime) dataRow[ "quDate" ] , ! //// dataRow[ getFieldName( barComponent ) ] ); ! // return histories; ! // } ! // public static Hashtable GetHistories( string instrumentKey , Hashtable barComponents , DateTime startDateTime , DateTime endDateTime ) ! // { ! // Hashtable histories; ! // try ! // { ! // histories = getHistories_try( instrumentKey , barComponents , startDateTime , endDateTime ); ! // } ! // catch (Exception ex) ! // { ! // MessageBox.Show( ex.ToString() ); ! // histories = null; ! // } ! // return histories; ! // } ! // #endregion } } --- 98,143 ---- return history; } ! private static History getHistory_common( string instrumentKey , QuoteField quoteField , ! DateTime firstDate , DateTime lastDate ) ! { ! History history; ! try ! { ! history = getHistory_try( instrumentKey , quoteField , firstDate , lastDate ); ! } ! catch (Exception ex) ! { ! MessageBox.Show( ex.ToString() ); ! history = null; ! } ! return history; ! } ! /// <summary> ! /// Returns the full history for the instrument and the specified quote field ! /// </summary> ! /// <param name="instrumentKey">Identifier (ticker) for the instrument whose story ! /// has to be returned</param> ! /// <param name="quoteField">Discriminates among Open, High, Low and Closure</param> ! /// <returns>The history for the given instrument and quote field</returns> ! public static History GetHistory( string instrumentKey , QuoteField quoteField ) ! { ! return getHistory_common( instrumentKey , quoteField , DateTime.MinValue , DateTime.MaxValue ); ! } ! /// <summary> ! /// Returns the history for the instrument and the specified quote field ! /// </summary> ! /// <param name="instrumentKey">Identifier (ticker) for the instrument whose story ! /// has to be returned</param> ! /// <param name="quoteField">Discriminates among Open, High, Low and Closure</param> ! /// <param name="firstDate">First date for quotes to be fetched</param> ! /// <param name="lastDate">Last date for quotes to be fetched</param> ! /// <returns>The history for the given instrument and quote field</returns> ! public static History GetHistory( string instrumentKey , QuoteField quoteField , ! DateTime firstDate , DateTime lastDate ) ! { ! return getHistory_common( instrumentKey , quoteField , firstDate , lastDate ); ! } ! #endregion } } |