[Quantproject-developers] QuantProject/b2_DataAccess/Tables Quotes.cs,1.16,1.17
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-08-22 16:56:40
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20513/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Added new types of selection for the TickerSelector class (added new methods to Quotes classes and renamed some previous elements for the enum SelectionType) Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Quotes.cs 4 Aug 2004 22:55:09 -0000 1.16 --- Quotes.cs 22 Aug 2004 16:56:25 -0000 1.17 *************** *** 413,419 **** /// <summary> ! /// Returns tickers ordered by a volatility index (stdDev of adjustedCloseToClose ratio) /// </summary> ! public static DataTable GetTickersByVolatility( bool orderInASCMode, string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, --- 413,419 ---- /// <summary> ! /// Returns tickers ordered by a close to close volatility index (stdDev of adjustedCloseToClose ratio) /// </summary> ! public static DataTable GetTickersByCloseToCloseVolatility( bool orderInASCMode, string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, *************** *** 439,442 **** --- 439,468 ---- /// <summary> + /// Returns tickers ordered by a close to open volatility index (stdDev of Close To Open ratio) + /// </summary> + public static DataTable GetTickersByCloseToOpenVolatility( bool orderInASCMode, string groupID, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + long maxNumOfReturnedTickers) + { + string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + + "StDev(quotes.quClose/quotes.quOpen) AS CloseToOpenStandDev " + + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + + "ON quotes.quTicker = tickers_tickerGroups.ttTiId " + + "WHERE tickers_tickerGroups.ttTgId='" + groupID + "' " + + "AND quotes.quDate BETWEEN " + + SQLBuilder.GetDateConstant(firstQuoteDate) + " AND " + + SQLBuilder.GetDateConstant(lastQuoteDate) + + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + + "ORDER BY StDev(quotes.quClose/quotes.quOpen)"; + string sortDirection = " DESC"; + if(orderInASCMode) + sortDirection = " ASC"; + sql = sql + sortDirection; + return SqlExecutor.GetDataTable( sql ); + } + + /// <summary> /// Returns tickers ordered by average close to close performance /// </summary> *************** *** 465,468 **** --- 491,520 ---- /// <summary> + /// Returns tickers ordered by average close to open performance (in the same bar) + /// </summary> + public static DataTable GetTickersByAverageCloseToOpenPerformance( bool orderInASCMode, string groupID, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + long maxNumOfReturnedTickers) + { + string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + + "Avg(quotes.quClose/quotes.quOpen) AS AverageCloseToOpenPerformance " + + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + + "ON quotes.quTicker = tickers_tickerGroups.ttTiId " + + "WHERE tickers_tickerGroups.ttTgId='" + groupID + "' " + + "AND quotes.quDate BETWEEN " + + SQLBuilder.GetDateConstant(firstQuoteDate) + " AND " + + SQLBuilder.GetDateConstant(lastQuoteDate) + + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + + "ORDER BY Avg(quotes.quClose/quotes.quOpen)"; + string sortDirection = " DESC"; + if(orderInASCMode) + sortDirection = " ASC"; + sql = sql + sortDirection; + return SqlExecutor.GetDataTable( sql ); + } + + /// <summary> /// returns the average traded value for the given ticker in the specified interval /// </summary> *************** *** 512,515 **** --- 564,591 ---- /// <summary> + /// returns the average close to open performance value for the given ticker in the specified interval + /// </summary> + public static double GetAverageCloseToOpenPerformance( string ticker, + DateTime firstQuoteDate, + DateTime lastQuoteDate) + + { + DataTable dt; + string sql = "SELECT quotes.quTicker, " + + "Avg([quClose]/[quOpen]) AS AverageCloseToOpenPerformance " + + "FROM quotes WHERE 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) + return 0; + else + return (double)dt.Rows[0]["AverageCloseToOpenPerformance"]; + } + + + /// <summary> /// returns the standard deviation of the adjusted close to close ratio /// for the given ticker in the specified interval *************** *** 535,539 **** } ! --- 611,637 ---- } ! /// <summary> ! /// returns the standard deviation of the adjusted close to open ratio ! /// for the given ticker in the specified interval ! /// </summary> ! public static double GetCloseToOpenStandardDeviation( string ticker, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate) ! ! { ! DataTable dt; ! string sql = "SELECT quotes.quTicker, " + ! "StDev(quotes.quClose/quotes.quOpen) AS CloseToOpenStandDev " + ! "FROM quotes WHERE 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) ! return 0; ! else ! return (double)dt.Rows[0]["CloseToOpenStandDev"]; ! } |