Add UnemploymentData
This commit is contained in:
@@ -35,7 +35,8 @@ namespace MarketData.Services
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEANALYSTRATINGS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATESECFILINGSWATCHLIST /WATCHLIST:");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATECOMPANYPROFILES");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEGDPPERCAPITA");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "UPDATEGDPPERCAPITA");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEUNEMPLOYMENTPERCAPITA");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEETFHOLDINGS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFINANCIALSTATEMENTS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFUNDAMENTALS");
|
||||
@@ -78,7 +79,8 @@ namespace MarketData.Services
|
||||
tasks.Add("UPDATEANALYSTRATINGS",TaskUpdateAnalystRatings);
|
||||
tasks.Add("UPDATESECFILINGSWATCHLIST",TaskUpdateSECFilingsWatchList);
|
||||
tasks.Add("UPDATECOMPANYPROFILES",TaskUpdateCompanyProfiles);
|
||||
tasks.Add("UPDATEGDPPERCAPITA",TaskUpdateGDPPerCapita);
|
||||
tasks.Add("UPDATEGDPPERCAPITA", TaskUpdateGDPPerCapita);
|
||||
tasks.Add("UPDATEUNEMPLOYMENTPERCAPITA", TaskUpdateUnemploymentPerCapita);
|
||||
tasks.Add("UPDATEETFHOLDINGS",TaskUpdateETFHoldings);
|
||||
tasks.Add("UPDATEFINANCIALSTATEMENTS",TaskUpdateFinancialStatements);
|
||||
tasks.Add("UPDATEFUNDAMENTALS",TaskUpdateFundamentals);
|
||||
@@ -219,6 +221,12 @@ namespace MarketData.Services
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateUnemploymentPerCapita(CommandArgs commandArgs)
|
||||
{
|
||||
LoadUnemploymentPerCapita();
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateCompanyProfiles(CommandArgs commandArgs)
|
||||
{
|
||||
UpdateCompanyProfiles();
|
||||
@@ -577,6 +585,7 @@ namespace MarketData.Services
|
||||
{
|
||||
UpdateYieldCurve(); // www.treasury.gov
|
||||
LoadGDPPerCapita(); // api.worldbank.org
|
||||
LoadUnemploymentPerCapita(); // api.worldbank.org
|
||||
LoadConsumerPriceIndex(); // Load consumer price index data from Bureau of Labor Statistics
|
||||
resetEvents[STAGE_3].Set();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_3 complete.");
|
||||
@@ -746,65 +755,105 @@ namespace MarketData.Services
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms).");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the GDP Data from WorldBank
|
||||
/// </summary>
|
||||
public static void LoadGDPPerCapita()
|
||||
{
|
||||
Profiler profiler = new Profiler();
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
|
||||
EconomicIndicators economicIndicators=MarketDataHelper.GetGDPPerCapita();
|
||||
if(null==economicIndicators||0==economicIndicators.Count)
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Started.");
|
||||
EconomicIndicators economicIndicators = MarketDataHelper.GetGDPPerCapita();
|
||||
if (null == economicIndicators || 0 == economicIndicators.Count)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"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("Downloaded {0} countries.",distinctCountry.Count));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"Saving...");
|
||||
if(EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators))
|
||||
List<String> distinctCountry = (from EconomicIndicator economicIndicator in economicIndicators select economicIndicator.CountryCode).Distinct().ToList();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Downloaded {0} countries.", distinctCountry.Count));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Saving...");
|
||||
if (EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators))
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Save complete.");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Save complete.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"Failed to save economic indicators.");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Failed to save economic indicators.");
|
||||
}
|
||||
}
|
||||
catch(Exception exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("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)");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Done, total took {profiler.End()}(ms)");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the Unemployment Data from WorldBank
|
||||
/// </summary>
|
||||
public static void LoadUnemploymentPerCapita()
|
||||
{
|
||||
Profiler profiler = new Profiler();
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Started.");
|
||||
EconomicIndicators economicIndicators = MarketDataHelper.GetUnemploymentPerCapita();
|
||||
if (null == economicIndicators || 0 == economicIndicators.Count)
|
||||
{
|
||||
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("Downloaded {0} countries.", distinctCountry.Count));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Saving...");
|
||||
if (EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators))
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Save complete.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Failed to save economic indicators.");
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Exception:{0}", exception.ToString()));
|
||||
}
|
||||
finally
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Done, total took {profiler.End()}(ms)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void UpdateYieldCurve() // maintains current year of yield curve data
|
||||
{
|
||||
Profiler profiler = new Profiler();
|
||||
try
|
||||
{
|
||||
int year = DateTime.Now.Year;
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"Retrieving yield curve for year "+year);
|
||||
YieldCurve yieldCurve=MarketDataHelper.GetYieldCurve(year);
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Retrieving yield curve for year " + year);
|
||||
YieldCurve yieldCurve = MarketDataHelper.GetYieldCurve(year);
|
||||
if (null == yieldCurve)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Failed to get YieldCurve for {0}", year));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Failed to get YieldCurve for {0}", year));
|
||||
return;
|
||||
}
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"Got "+yieldCurve.Count+" points for "+year);
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Got " + yieldCurve.Count + " points for " + year);
|
||||
YieldCurveDA.InsertOrUpdate(yieldCurve);
|
||||
}
|
||||
catch(Exception exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Exception: {exception.ToString()}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Done, total took {profiler.End()}(ms)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"market_data" : "Database=market_data;Datasource=adrastea;Username=guest;Password=guest",
|
||||
"portfolio_data" : "Database=portfolio_data;Datasource=adrastea;Username=guest;Password=guest",
|
||||
"user_data" : "Database=user_data;Datasource=adrastea;Username=guest;Password=guest",
|
||||
"market_data" : "Database=market_data;Datasource=isonoe;Username=guest;Password=guest",
|
||||
"portfolio_data" : "Database=portfolio_data;Datasource=isonoe;Username=guest;Password=guest",
|
||||
"user_data" : "Database=user_data;Datasource=isonoe;Username=guest;Password=guest",
|
||||
"sms_smtpaddress" : "smtp.gmail.com",
|
||||
"sms_smsusername" : "skessler1964@gmail.com",
|
||||
"sms_smspassword" : "xjfo isnf gmyi zovr",
|
||||
|
||||
Reference in New Issue
Block a user