Optimizations
This commit is contained in:
@@ -139,6 +139,48 @@ namespace MarketData.DataAccess
|
||||
if(null!=sqlTransaction) sqlTransaction.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<String,bool> HasStopLimit(List<String> symbols)
|
||||
{
|
||||
MySqlConnection sqlConnection=null;
|
||||
MySqlDataReader sqlDataReader=null;
|
||||
MySqlCommand sqlCommand=null;
|
||||
Dictionary<String,bool> hasStopLimit = new Dictionary<String,bool>();
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
if(null==symbols) return null;
|
||||
sqlConnection=SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||
sb.Append("select symbol, count(*) from stoplimits ");
|
||||
sb.Append("where symbol in ");
|
||||
sb.Append(SqlUtils.CreateInClause(symbols));
|
||||
sb.Append(" and active=1 group by 1");
|
||||
String strQuery=sb.ToString();
|
||||
sqlCommand=new MySqlCommand(strQuery,sqlConnection);
|
||||
sqlCommand.CommandTimeout=SqlUtils.COMMAND_TIMEOUT;
|
||||
sqlDataReader=sqlCommand.ExecuteReader();
|
||||
while(sqlDataReader.Read())
|
||||
{
|
||||
String symbol = sqlDataReader.GetString(0);
|
||||
symbol = symbol.ToUpper();
|
||||
hasStopLimit.Add(symbol, true);
|
||||
}
|
||||
return hasStopLimit;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,exception);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(null!=sqlCommand) sqlCommand.Dispose();
|
||||
if(null!=sqlDataReader) sqlDataReader.Close();
|
||||
if(null!=sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasStopLimit(String symbol)
|
||||
{
|
||||
MySqlConnection sqlConnection=null;
|
||||
@@ -153,6 +195,7 @@ namespace MarketData.DataAccess
|
||||
sqlConnection=SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||
sb.Append("select count(*) from stoplimits ");
|
||||
sb.Append("where symbol='").Append(symbol).Append("'");
|
||||
sb.Append(" and active=1");
|
||||
strQuery=sb.ToString();
|
||||
sqlCommand=new MySqlCommand(strQuery,sqlConnection);
|
||||
sqlCommand.CommandTimeout=SqlUtils.COMMAND_TIMEOUT;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace MarketData.DataAccess
|
||||
{
|
||||
public class PricingDA
|
||||
{
|
||||
public static readonly int ForwardLookingDays = 90;
|
||||
private PricingDA()
|
||||
{
|
||||
}
|
||||
@@ -628,6 +629,52 @@ namespace MarketData.DataAccess
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<String,String> GetNamesForSymbols(List<String> symbols)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
MySqlDataReader sqlDataReader = null;
|
||||
MySqlCommand sqlCommand=null;
|
||||
String strQuery = null;
|
||||
Dictionary<String,String> dictionary = new Dictionary<String,String>();
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
|
||||
sb.Append("select symbol, company from securitymaster where symbol in ");
|
||||
sb.Append(SqlUtils.CreateInClause(symbols));
|
||||
sb.Append(";");
|
||||
strQuery = sb.ToString(); ;
|
||||
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
||||
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
||||
sqlDataReader = sqlCommand.ExecuteReader();
|
||||
while (sqlDataReader.Read())
|
||||
{
|
||||
String symbol = sqlDataReader.GetString(0);
|
||||
String companyName = sqlDataReader.GetString(1);
|
||||
if(null==companyName || null==symbol)continue;
|
||||
companyName=companyName.ToUpper();
|
||||
symbol = symbol.ToUpper();
|
||||
if(dictionary.ContainsKey(symbol))continue;
|
||||
dictionary.Add(symbol,companyName);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,exception);
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Query was {0}",strQuery));
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(null!=sqlCommand)sqlCommand.Dispose();
|
||||
if (null != sqlDataReader) sqlDataReader.Close();
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static String GetNameForSymbol(String symbol)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
@@ -1117,6 +1164,7 @@ namespace MarketData.DataAccess
|
||||
// Get prices starting at "startDate" and "days" number of days going into future
|
||||
public static Prices GetPricesForward(String symbol,DateTime startDate,int days)
|
||||
{
|
||||
Profiler profiler = new Profiler();
|
||||
MySqlConnection sqlConnection=null;
|
||||
MySqlDataReader sqlDataReader=null;
|
||||
MySqlCommand sqlCommand=null;
|
||||
@@ -1166,6 +1214,7 @@ namespace MarketData.DataAccess
|
||||
if(null!=sqlCommand) sqlCommand.Dispose();
|
||||
if(null!=sqlDataReader) sqlDataReader.Close();
|
||||
if(null!=sqlConnection) sqlConnection.Close();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[GetPricesForward] Done, took {0}(ms)",profiler.End()));
|
||||
}
|
||||
}
|
||||
public static Prices GetPricesOnOrBefore(String symbol,DateTime startDate)
|
||||
|
||||
Reference in New Issue
Block a user