Logging changes.

This commit is contained in:
2025-04-10 22:32:10 -04:00
parent f9365049e2
commit 98cab516fb
5 changed files with 235 additions and 90 deletions

View File

@@ -329,9 +329,7 @@ namespace MarketData.Services
ThreadPool.QueueUserWorkItem(delegate
{
LoadConsumerPriceIndex(); // Load consumer price index data from Bureau of Labor Statistics
UpdateCompanyProfiles(); // financials.morningstar.com and finance.yahoo.com
LoadGDPPerCapita(); // api.worldbank.org
resetEvents[STAGE_2].Set();
SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_2 complete. LoadConsumerPriceIndex,UpdateCompanyProfiles,LoadGDPPerCapita ", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_2 complete.");
@@ -340,6 +338,8 @@ namespace MarketData.Services
ThreadPool.QueueUserWorkItem(delegate
{
UpdateYieldCurve(); // www.treasury.gov
LoadGDPPerCapita(); // api.worldbank.org
LoadConsumerPriceIndex(); // Load consumer price index data from Bureau of Labor Statistics
resetEvents[STAGE_3].Set();
SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_3 complete. UpdateYieldCurve", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_3 complete.");
@@ -469,65 +469,81 @@ namespace MarketData.Services
public static void LoadConsumerPriceIndex()
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine("[LoadConsumerPriceIndex] started.");
MDTrace.WriteLine("Started.");
PriceIndices priceIndices=MarketDataHelper.GetConsumerPriceIndices();
if(null==priceIndices)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Failed, check log file for isssues.");
MDTrace.WriteLine(LogLevel.DEBUG,"Failed, check log file for isssues.");
return;
}
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadConsumerPriceIndex] Got:{0} records from source feed.",priceIndices.Count()));
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Saving...");
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got:{0} records from source feed.",priceIndices.Count()));
MDTrace.WriteLine(LogLevel.DEBUG,"Saving...");
ConsumerPriceIndexDA.InsertUpdatePriceIndices(priceIndices);
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Save complete...");
MDTrace.WriteLine(LogLevel.DEBUG,"Save complete...");
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadConsumerPriceIndex] Exception:{0}",exception.ToString()));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateCompanyProfiles()
{
try
{
CompanyProfileMarketDataHelper companyProfileMarketDataHelper=new CompanyProfileMarketDataHelper();
companyProfileMarketDataHelper.UpdateCompanyProfiles();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception);
}
}
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Started.");
CompanyProfileMarketDataHelper companyProfileMarketDataHelper=new CompanyProfileMarketDataHelper();
companyProfileMarketDataHelper.UpdateCompanyProfiles();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms).");
}
}
public static void LoadGDPPerCapita()
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine("[LoadGSPPerCapita]");
MDTrace.WriteLine("Started.");
EconomicIndicators economicIndicators=MarketDataHelper.GetGDPPerCapita();
if(null==economicIndicators||0==economicIndicators.Count)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] No data, see log file for potential issues.");
MDTrace.WriteLine(LogLevel.DEBUG,"No data, see log file for potential issues.");
return;
}
List<String> distinctCountry=(from EconomicIndicator economicIndicator in economicIndicators select economicIndicator.CountryCode).Distinct().ToList();
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadGDPPerCapita] Downloaded {0} countries.",distinctCountry.Count));
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Saving...");
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Downloaded {0} countries.",distinctCountry.Count));
MDTrace.WriteLine(LogLevel.DEBUG,"Saving...");
if(EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators))
{
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Success.");
MDTrace.WriteLine(LogLevel.DEBUG,$"Save complete.");
}
else
{
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Failed, check log file for isssues.");
MDTrace.WriteLine(LogLevel.DEBUG,"Failed to save economic indicators.");
}
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadGDPPerCapita] Exception:{0}",exception.ToString()));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
@@ -564,7 +580,7 @@ namespace MarketData.Services
{
if(!CheckRunCriteria())return;
DateGenerator dateGenerator = new DateGenerator();
MDTrace.WriteLine(LogLevel.DEBUG, "Enter");
MDTrace.WriteLine(LogLevel.DEBUG, "Started.");
AnalystRatings analystRatings = MarketDataHelper.GetLatestAnalystRatings();
List<String> symbols = PricingDA.GetSymbolsNotIn(analystRatings.Symbols);
foreach (String symbol in symbols)
@@ -614,6 +630,7 @@ namespace MarketData.Services
public static void UpdateMissingAnalystRatings()
{
Profiler profiler = new Profiler();
try
{
DateGenerator dateGenerator = new DateGenerator();
@@ -648,82 +665,209 @@ namespace MarketData.Services
}
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG, exception);
MDTrace.WriteLine(LogLevel.DEBUG, $"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateSplits()
{
MDTrace.WriteLine("Updating splits.");
Splits splits=MarketDataHelper.GetSplits();
if(null==splits||0==splits.Count)return;
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got {0} split records.",splits.Count));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Writing to database.",splits.Count));
SplitsDA.InsertSplits(splits);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Done."));
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine("Updating splits.");
Splits splits=MarketDataHelper.GetSplits();
if(null==splits||0==splits.Count)return;
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got {0} split records.",splits.Count));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Writing to database.",splits.Count));
SplitsDA.InsertSplits(splits);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Done."));
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void ProcessAllSplits()
{
MDTrace.WriteLine("Processing all splits");
Splits splits=SplitsDA.GetUnappliedSplits();
if(null==splits||0==splits.Count)return;
SplitHelper.ProcessSplits(splits);
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine("Processing all splits");
Splits splits=SplitsDA.GetUnappliedSplits();
if(null==splits||0==splits.Count)return;
SplitHelper.ProcessSplits(splits);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void LoadInsiderTransactions()
{
List<String> symbols = PricingDA.GetSymbols();
InsiderTransactionMarketDataHelper insiderTransactionMarketDataHelper = new InsiderTransactionMarketDataHelper();
insiderTransactionMarketDataHelper.LoadInsiderTransactions(symbols);
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
List<String> symbols = PricingDA.GetSymbols();
InsiderTransactionMarketDataHelper insiderTransactionMarketDataHelper = new InsiderTransactionMarketDataHelper();
insiderTransactionMarketDataHelper.LoadInsiderTransactions(symbols);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateEarningsAnnouncements(String symbol=null)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEEARNINGSANNOUNCEMENTS]");
EarningsAnnouncementsMarketDataHelper earningsAnnouncementsMarketDataHelper=new EarningsAnnouncementsMarketDataHelper();
earningsAnnouncementsMarketDataHelper.UpdateEarningsAnnouncements(symbol);
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEEARNINGSANNOUNCEMENTS] Done");
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
EarningsAnnouncementsMarketDataHelper earningsAnnouncementsMarketDataHelper=new EarningsAnnouncementsMarketDataHelper();
earningsAnnouncementsMarketDataHelper.UpdateEarningsAnnouncements(symbol);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void LoadZacksRank()
{
ZacksRankMarketDataHelper zacksRankMarketDataHelper=new ZacksRankMarketDataHelper();
zacksRankMarketDataHelper.LoadZacksRank();
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
ZacksRankMarketDataHelper zacksRankMarketDataHelper=new ZacksRankMarketDataHelper();
zacksRankMarketDataHelper.LoadZacksRank();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void GetSECFilingsWatchList(String watchListName)
{
List<String> symbols = WatchListDA.GetWatchList(watchListName);
SECFilingMarketDataHelper secFilingMarketDataHelper=new SECFilingMarketDataHelper();
secFilingMarketDataHelper.UpdateSECFilings(symbols);
}
public static void GetSECFilingsWatchList(String watchListName)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
List<String> symbols = WatchListDA.GetWatchList(watchListName);
SECFilingMarketDataHelper secFilingMarketDataHelper=new SECFilingMarketDataHelper();
secFilingMarketDataHelper.UpdateSECFilings(symbols);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateAnalystPriceTarget()
{
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEANALYSTPRICETARGET]");
AnalystPriceTargetMarketDataHelper analystPriceTargetMarketDataHelper=new AnalystPriceTargetMarketDataHelper();
analystPriceTargetMarketDataHelper.LoadAnalystPriceTarget();
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEANALYSTPRICETARGET] Done");
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
AnalystPriceTargetMarketDataHelper analystPriceTargetMarketDataHelper=new AnalystPriceTargetMarketDataHelper();
analystPriceTargetMarketDataHelper.LoadAnalystPriceTarget();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void GetETFHoldings()
{
ETFHoldingsMarketDataHelper etfHoldingsMarketDataHelper=new ETFHoldingsMarketDataHelper();
etfHoldingsMarketDataHelper.LoadETFHoldings();
}
public static void GetETFHoldings()
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
ETFHoldingsMarketDataHelper etfHoldingsMarketDataHelper=new ETFHoldingsMarketDataHelper();
etfHoldingsMarketDataHelper.LoadETFHoldings();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateAllMissingCIK()
{
CIKMarketDataHelper cikMarketDataHelper=new CIKMarketDataHelper();
cikMarketDataHelper.UpdateAllMissingCIK();
}
public static void UpdateAllMissingCIK()
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
CIKMarketDataHelper cikMarketDataHelper=new CIKMarketDataHelper();
cikMarketDataHelper.UpdateAllMissingCIK();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateDividendHistory()
{
DividendHistoryMarketDataHelper dividendHistoryMarketDataHelper=new DividendHistoryMarketDataHelper();
dividendHistoryMarketDataHelper.UpdateDividendHistory();
}
public static void UpdateDividendHistory()
{
Profiler profiler = new Profiler();
try
{
DividendHistoryMarketDataHelper dividendHistoryMarketDataHelper=new DividendHistoryMarketDataHelper();
dividendHistoryMarketDataHelper.UpdateDividendHistory();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
// **********************************************************************************************************************************************
// ******************************************* E N D U P D A T E D A I L Y 2 M E T H O D S ***************************************************