[Quantproject-developers] QuantProject/b2_DataAccess/Tables Quotes.cs, 1.38, 1.39
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2011-08-21 10:06:57
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables
In directory vz-cvs-3.sog:/tmp/cvs-serv28472/Tables
Modified Files:
Quotes.cs
Log Message:
Some methods have been fixed in accessing Quotes table
Index: Quotes.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** Quotes.cs 16 Jan 2011 11:18:32 -0000 1.38
--- Quotes.cs 21 Aug 2011 10:06:55 -0000 1.39
***************
*** 106,110 ****
return dataTable.Rows.Count;
}
!
/// <summary>
/// Returns the adjusted close value for the given ticker at the specified date
--- 106,125 ----
return dataTable.Rows.Count;
}
!
! /// <summary>
! /// Returns the number of days at which the given ticker has quotes in the db
! /// </summary>
! /// <param name="ticker">ticker for which the number of days has to be returned</param>
! /// <returns></returns>
! public static int GetNumberOfDaysWithQuotes( string ticker, DateTime firstDate,
! DateTime lastDate)
! {
! DataTable dataTable = SqlExecutor.GetDataTable(
! "select * from quotes WHERE quTicker='" + ticker + "'" +
! " AND quDate BETWEEN " + SQLBuilder.GetDateConstant(firstDate) +
! " AND " + SQLBuilder.GetDateConstant(lastDate));
! return dataTable.Rows.Count;
! }
!
/// <summary>
/// Returns the adjusted close value for the given ticker at the specified date
***************
*** 113,123 ****
/// <param name="ticker">ticker for which the adj close has to be returned</param>
/// <returns></returns>
! public static float GetAdjustedClose( string ticker, DateTime date )
{
! DataTable dataTable = SqlExecutor.GetDataTable(
! "select quAdjustedClose from quotes where quTicker='" + ticker + "' " +
! "and quDate=" + SQLBuilder.GetDateConstant(date) );
! return (float)dataTable.Rows[0][0];
}
/// <summary>
/// Returns the raw (not adjusted) close for the given ticker at the specified date
--- 128,139 ----
/// <param name="ticker">ticker for which the adj close has to be returned</param>
/// <returns></returns>
! public static double GetAdjustedClose( string ticker, DateTime date )
{
! string strSQL = "select quAdjustedClose from quotes where quTicker='" + ticker + "' " +
! "and quDate=" + SQLBuilder.GetDateConstant(date);
! DataTable dataTable = SqlExecutor.GetDataTable(strSQL);
! return (double)dataTable.Rows[0][0];
}
+
/// <summary>
/// Returns the raw (not adjusted) close for the given ticker at the specified date
***************
*** 728,732 ****
DataTable dt;
string sql = "SELECT quotes.quTicker, " +
! "Avg([quVolume]) AS AverageTradedVolume " +
"FROM quotes WHERE quTicker ='" +
ticker + "' " +
--- 744,748 ----
DataTable dt;
string sql = "SELECT quotes.quTicker, " +
! "Avg(quVolume) AS AverageTradedVolume " +
"FROM quotes WHERE quTicker ='" +
ticker + "' " +
***************
*** 736,742 ****
dt = SqlExecutor.GetDataTable( sql );
if(dt.Rows.Count==0)
! return 0;
else
! return (double)dt.Rows[0]["AverageTradedVolume"];
}
--- 752,758 ----
dt = SqlExecutor.GetDataTable( sql );
if(dt.Rows.Count==0)
! return 0.0;
else
! return Convert.ToDouble(dt.Rows[0]["AverageTradedVolume"]);
}
***************
*** 902,905 ****
--- 918,949 ----
/// <summary>
+ /// returns the average adjusted close price for the given ticker,
+ /// at the specified time interval
+ /// </summary>
+ public static double GetAverageAdjustedClosePrice( string ticker,
+ DateTime firstQuoteDate,
+ DateTime lastQuoteDate)
+
+ {
+ double returnValue = double.MinValue;
+ DataTable dt;
+ string sql = "SELECT quotes.quTicker, " +
+ "Avg(quotes.quAdjustedClose) AS AverageAdjClosePrice " +
+ "FROM quotes " +
+ "WHERE quotes.quTicker ='" + ticker +
+ "' AND quotes.quDate Between " + SQLBuilder.GetDateConstant(firstQuoteDate) + " " +
+ "AND " + SQLBuilder.GetDateConstant(lastQuoteDate) + " " +
+ "GROUP BY quotes.quTicker";
+ dt = SqlExecutor.GetDataTable( sql );
+ if(dt.Rows.Count > 0)
+ {
+ if( dt.Rows[0]["AverageAdjClosePrice"] is double )
+ //cast is possible
+ returnValue = (double)dt.Rows[0]["AverageAdjClosePrice"];
+ }
+ return returnValue;
+ }
+
+ /// <summary>
/// returns raw open price's standard deviation for the given ticker,
/// at the specified time interval
|