Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19030/b2_DataAccess/Tables
Modified Files:
Quotes.cs
Log Message:
The GetTickersByLiquidity method has been overloaded so that now it is possible to select a subset of tickers whose volume is above a given threshold
Index: Quotes.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Quotes.cs 7 Jan 2006 10:56:09 -0000 1.28
--- Quotes.cs 18 Jun 2006 14:19:44 -0000 1.29
***************
*** 456,459 ****
--- 456,496 ----
return SqlExecutor.GetDataTable( sql );
}
+
+ /// <summary>
+ /// returns tickers ordered by liquidity, with a specified min volume
+ /// </summary>
+ /// <param name="orderInASCMode">true iff return must be ordered</param>
+ /// <param name="groupID"></param>
+ /// <param name="firstQuoteDate"></param>
+ /// <param name="lastQuoteDate"></param>
+ /// <param name="maxNumOfReturnedTickers"></param>
+ /// <param name="minVolume"></param>
+ /// <returns></returns>
+ public static DataTable GetTickersByLiquidity( bool orderInASCMode, string groupID,
+ DateTime firstQuoteDate,
+ DateTime lastQuoteDate,
+ long minVolume,
+ long maxNumOfReturnedTickers
+ )
+ {
+ string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " +
+ "Avg([quVolume]) AS AverageTradedValue " +
+ "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 " +
+ "HAVING Avg([quVolume])>=" + minVolume.ToString() + " " +
+ "ORDER BY Avg([quVolume])";
+ string sortDirection = " DESC";
+ if(orderInASCMode)
+ sortDirection = " ASC";
+ sql = sql + sortDirection;
+ return SqlExecutor.GetDataTable( sql );
+ }
+
|