Optimizations for CMTrend

This commit is contained in:
2025-04-21 18:03:07 -04:00
parent 53e84e765c
commit 14bd7651ca
9 changed files with 302 additions and 34 deletions

View File

@@ -69,6 +69,54 @@ namespace MarketData.DataAccess
}
}
public static Dictionary<String,CompanyProfile> GetCompanyProfiles(List<String> symbols)
{
Dictionary<String,CompanyProfile> companyProfiles=new Dictionary<String,CompanyProfile>();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
String strQuery = null;
try
{
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
sb.Append("select sm.symbol,sm.sector,sm.industry,sm.security_type,sm.company,cp.description,cp.pricing_source,cp.can_roll_previous,cp.freeze_pricing from securitymaster sm left outer join companyprofile cp on sm.symbol=cp.symbol").Append(" ");
sb.Append("where sm.symbol in ").Append(SqlUtils.CreateInClause(symbols));
strQuery = sb.ToString();
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
sqlDataReader = sqlCommand.ExecuteReader();
while(sqlDataReader.Read())
{
CompanyProfile companyProfile = new CompanyProfile();
companyProfile.Symbol=sqlDataReader.GetString(0);
if (!sqlDataReader.IsDBNull(1)) companyProfile.Sector = sqlDataReader.GetString(1);
if (!sqlDataReader.IsDBNull(2)) companyProfile.Industry = sqlDataReader.GetString(2);
if (!sqlDataReader.IsDBNull(3)) companyProfile.SecurityType = sqlDataReader.GetString(3);
if (!sqlDataReader.IsDBNull(4)) companyProfile.CompanyName = sqlDataReader.GetString(4);
if (!sqlDataReader.IsDBNull(5)) companyProfile.Description = sqlDataReader.GetString(5);
if (!sqlDataReader.IsDBNull(6)) companyProfile.PricingSource = sqlDataReader.GetString(6).ToUpper();
if (!sqlDataReader.IsDBNull(7)) companyProfile.CanRollPrevious = sqlDataReader.GetBoolean(7);
if (!sqlDataReader.IsDBNull(8)) companyProfile.FreezePricing = sqlDataReader.GetBoolean(8);
if(!companyProfiles.ContainsKey(companyProfile.Symbol))companyProfiles.Add(companyProfile.Symbol, companyProfile);
}
return companyProfiles;
}
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception);
return null;
}
finally
{
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
}
}
public static CompanyProfiles GetCompanyProfiles()
{
CompanyProfiles companyProfiles=new CompanyProfiles();