[Quantproject-developers] QuantProject/b2_DataAccess DataBase.cs,1.3,1.4
Brought to you by:
glauco_1
|
From: <gla...@us...> - 2004-01-03 16:13:54
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess
In directory sc8-pr-cvs1:/tmp/cvs-serv31132/b2_DataAccess
Modified Files:
DataBase.cs
Log Message:
GetHistories has been fixed to work with the new
quotes table (now adjusted open, adjusted high
and adjusted close are computed values: they
are not stored into the database anymore).
Index: DataBase.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DataBase.cs 21 Dec 2003 21:09:57 -0000 1.3
--- DataBase.cs 3 Jan 2004 16:13:49 -0000 1.4
***************
*** 46,50 ****
}
! #region "GetHistories"
private static string getFieldName( BarComponent barComponent )
{
--- 46,54 ----
}
! /// <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 )
{
***************
*** 53,57 ****
{
case BarComponent.Open:
! fieldName = "quAdjustedOpen";
break;
case BarComponent.High:
--- 57,61 ----
{
case BarComponent.Open:
! fieldName = "quOpen";
break;
case BarComponent.High:
***************
*** 69,72 ****
--- 73,124 ----
return fieldName;
}
+
+ #region "GetHistory"
+ private static History getHistory_try( string instrumentKey , BarComponent barComponent )
+ {
+ History history = new History();
+ string commandString =
+ "select * from quotes where quTicker='" + instrumentKey + "'";
+ OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , oleDbConnection );
+ 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)
+ {
+ MessageBox.Show( ex.ToString() );
+ history = null;
+ }
+ return history;
+ }
+ #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 )
{
***************
*** 84,88 ****
foreach ( BarComponent barComponent in barComponents.Keys )
((History) histories[ barComponent ]).Add( (DateTime) dataRow[ "quDate" ] ,
! dataRow[ getFieldName( barComponent ) ] );
return histories;
}
--- 136,142 ----
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;
}
|