[Quantproject-developers] QuantProject/b2_DataAccess DataBase.cs,1.4,1.5
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2005-01-09 22:22:45
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28813/b2_DataAccess Modified Files: DataBase.cs Log Message: - BarComponent has been replaced by QuoteField - the GetHistories method has been removed Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataBase.cs 3 Jan 2004 16:13:49 -0000 1.4 --- DataBase.cs 9 Jan 2005 22:22:36 -0000 1.5 *************** *** 47,72 **** /// <summary> ! /// Returns the field name corresponding to the bar component /// </summary> ! /// <param name="barComponent">Discriminates among Open, High, Low and Closure</param> ! /// <returns>Field name corresponding to the bar component</returns> ! private static string getFieldName( BarComponent barComponent ) { string fieldName = ""; ! switch ( barComponent ) { ! case BarComponent.Open: fieldName = "quOpen"; break; ! case BarComponent.High: fieldName = "quHigh"; break; ! case BarComponent.Low: fieldName = "quLow"; break; ! case BarComponent.Close: ! fieldName = "quAdjustedClose"; ! break; ! default: break; } --- 47,81 ---- /// <summary> ! /// Returns the field name corresponding to the quote field /// </summary> ! /// <param name="quoteField">Discriminates among Open, High, Low and Closure</param> ! /// <returns>Field name corresponding to the quote field</returns> ! private static string getFieldName( QuoteField quoteField ) { string fieldName = ""; ! switch ( quoteField ) { ! case QuoteField.Open: fieldName = "quOpen"; break; ! case QuoteField.High: fieldName = "quHigh"; break; ! case QuoteField.Low: fieldName = "quLow"; break; ! case QuoteField.Close: ! fieldName = "quClose"; ! break; ! case QuoteField.AdjustedClose: ! fieldName = "quAdjustedClose"; ! break; ! case QuoteField.AdjustedCloseToCloseRatio: ! fieldName = "quAdjustedCloseToCloseRatio"; ! break; ! case QuoteField.Volume: ! fieldName = "quVolume"; ! break; ! default: break; } *************** *** 75,79 **** #region "GetHistory" ! private static History getHistory_try( string instrumentKey , BarComponent barComponent ) { History history = new History(); --- 84,88 ---- #region "GetHistory" ! private static History getHistory_try( string instrumentKey , QuoteField quoteField ) { History history = new History(); *************** *** 83,102 **** DataTable dataTable = new DataTable(); oleDbDataAdapter.Fill( dataTable ); ! history.Import( dataTable , "quDate" , getFieldName( barComponent ) ); return history; } /// <summary> ! /// Returns the full history for the instrument and the specified bar component /// </summary> /// <param name="instrumentKey">Identifier (ticker) for the instrument whose story /// has to be returned</param> ! /// <param name="barComponent">Discriminates among Open, High, Low and Closure</param> ! /// <returns>The history for the given instrument and bar component</returns> ! public static History GetHistory( string instrumentKey , BarComponent barComponent ) { History history; try { ! history = getHistory_try( instrumentKey , barComponent ); } catch (Exception ex) --- 92,111 ---- DataTable dataTable = new DataTable(); oleDbDataAdapter.Fill( dataTable ); ! history.Import( dataTable , "quDate" , getFieldName( quoteField ) ); 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) *************** *** 109,159 **** #endregion ! #region "GetHistories" ! private static Single getHistories_try_getValue( DataRow dataRow , DateTime dateTime , ! BarComponent barComponent ) ! { ! Single returnValue; ! if ( barComponent == BarComponent.Close ) ! returnValue = (Single)dataRow[ getFieldName( barComponent ) ]; ! else ! returnValue = (Single)dataRow[ getFieldName( barComponent ) ] * ! (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 } } --- 118,168 ---- #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 } } |