Add UnemploymentData
This commit is contained in:
@@ -20,31 +20,32 @@ using MarketDataLib.Utility;
|
||||
using MarketData.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
//Zacks Rank - Zacks
|
||||
//Splits - EODDATA
|
||||
//GDP Data - WorldBank
|
||||
//Dividend History - NASDAQ
|
||||
//Options - NASDAQ
|
||||
//Analyst Ratings - Briefing.com
|
||||
//SEC Filings - SEC.GOV (EDGAR)
|
||||
//Yield Curve - Treasury.Gov
|
||||
//ETF Holdings - Yahoo Finance
|
||||
//Insider Transactions - Insider Tracking.com
|
||||
//Company Profile - MorningStar + Reuters
|
||||
//Headlines - Seeking Alpha + NASDAQ
|
||||
//CIK Codes - SEC.GOV
|
||||
//Analyst Price Target - Yahoo Finance , Market Beat as backup
|
||||
//Historical - MorningStar
|
||||
//Income Statement - NASDAQ
|
||||
//Balance Sheet - NASDAQ
|
||||
//Statement of Cashflows - MorningStar
|
||||
//Fundamentals - 2 Sources....Yahoo Finance & FINVIZ
|
||||
// Zacks Rank - Zacks
|
||||
// Splits - EODDATA
|
||||
// GDP Data - WorldBank
|
||||
// Employment Data - WorldBank
|
||||
// Dividend History - NASDAQ
|
||||
// Options - NASDAQ
|
||||
// Analyst Ratings - Briefing.com
|
||||
// SEC Filings - SEC.GOV (EDGAR)
|
||||
// Yield Curve - Treasury.Gov
|
||||
// ETF Holdings - Yahoo Finance
|
||||
// Insider Transactions - Insider Tracking.com
|
||||
// Company Profile - MorningStar + Reuters
|
||||
// Headlines - Seeking Alpha + NASDAQ
|
||||
// CIK Codes - SEC.GOV
|
||||
// Analyst Price Target - Yahoo Finance , Market Beat as backup
|
||||
// Historical - MorningStar
|
||||
// Income Statement - NASDAQ
|
||||
// Balance Sheet - NASDAQ
|
||||
// Statement of Cashflows - MorningStar
|
||||
// Fundamentals - 2 Sources....Yahoo Finance & FINVIZ
|
||||
// a) Key Statistics
|
||||
// b) Financials
|
||||
//Intraday Pricing - Yahoo Finance + BigCharts
|
||||
//Historical Pricing - BigCharts + Yahoo Finance
|
||||
//CompanyDescription - Reuters
|
||||
//Premarket - CNN
|
||||
// Intraday Pricing - Yahoo Finance + RobinHood
|
||||
// Historical Pricing - Yahoo Finance
|
||||
// CompanyDescription - Reuters
|
||||
// Premarket - CNN
|
||||
|
||||
namespace MarketData.Helper
|
||||
{
|
||||
@@ -395,50 +396,94 @@ namespace MarketData.Helper
|
||||
if (null != httpNetResponse) httpNetResponse.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
// ************************************************************************** G D P P E R C A P I T A D A T A W O R L D B A N K *************************************************
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
public static EconomicIndicators GetGDPPerCapita(bool debug=false)
|
||||
{
|
||||
HttpNetResponse httpNetResponse=null;
|
||||
try
|
||||
{
|
||||
// Retrieve compressed CSV from World Bank web site and write to disk
|
||||
StringBuilder sb=new StringBuilder();
|
||||
String strRequest;
|
||||
String currentWorkingDirectory=Directory.GetCurrentDirectory();
|
||||
String strExtractFolder=currentWorkingDirectory+"/"+"extracts";
|
||||
String strFileName="API_NY.GDP.MKTP.CD_DS2_V2_USD.zip";
|
||||
String strPathFileName=currentWorkingDirectory+"/"+strFileName;
|
||||
sb.Append("http://api.worldbank.org/v2/en/indicator/NY.GDP.MKTP.CD?downloadformat=csv");
|
||||
strRequest=sb.ToString();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Downloading {0} from {1}",strFileName,strRequest));
|
||||
httpNetResponse=HttpNetRequest.GetRequestStreamZIP(strRequest);
|
||||
if(!httpNetResponse.Success)
|
||||
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
// ************************************************************************** W O R L D B A N K F E E D *************************************************
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
public static EconomicIndicators GetUnemploymentPerCapita(bool debug = false)
|
||||
{
|
||||
HttpNetResponse httpNetResponse = null;
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String strRequest;
|
||||
String currentWorkingDirectory = Directory.GetCurrentDirectory();
|
||||
String strExtractFolder = currentWorkingDirectory + "/" + "extracts";
|
||||
String strFileName = "API_SL.UEM.TOTL.ZS_DS2_en_csv_v2_254884.zip";
|
||||
String strPathFileName = currentWorkingDirectory + "/" + strFileName;
|
||||
sb.Append("http://api.worldbank.org/v2/en/indicator/SL.UEM.TOTL.ZS?downloadformat=csv");
|
||||
strRequest = sb.ToString();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Downloading {0} from {1}", strFileName, strRequest));
|
||||
httpNetResponse = HttpNetRequest.GetRequestStreamZIP(strRequest);
|
||||
if (!httpNetResponse.Success)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Request:{0} failed with status {1}",httpNetResponse.Request,httpNetResponse.StatusCode));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
|
||||
return null;
|
||||
}
|
||||
if(File.Exists(strPathFileName))File.Delete(strPathFileName);
|
||||
FileStream outStream=new FileStream(strPathFileName,FileMode.Create);
|
||||
byte[] streamBytes=httpNetResponse.ResponseStream.GetBuffer();
|
||||
outStream.Write(streamBytes,0,streamBytes.Length);
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
if (File.Exists(strPathFileName)) File.Delete(strPathFileName);
|
||||
FileStream outStream = new FileStream(strPathFileName, FileMode.Create);
|
||||
byte[] streamBytes = httpNetResponse.ResponseStream.GetBuffer();
|
||||
outStream.Write(streamBytes, 0, streamBytes.Length);
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
outStream.Dispose();
|
||||
return EconomicIndicators.FromZipFile(strPathFileName,strExtractFolder,debug);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,exception);
|
||||
return EconomicIndicators.FromZipFile(strPathFileName, strExtractFolder, debug);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(null!=httpNetResponse)httpNetResponse.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != httpNetResponse) httpNetResponse.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves GDP Data from WorlBank as zip file, decompresses the zip file, reads and imports the CSV contents and returns EconomicIndicators
|
||||
/// </summary>
|
||||
/// <param name="debug"></param>
|
||||
/// <returns></returns>
|
||||
public static EconomicIndicators GetGDPPerCapita(bool debug = false)
|
||||
{
|
||||
HttpNetResponse httpNetResponse = null;
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String strRequest;
|
||||
String currentWorkingDirectory = Directory.GetCurrentDirectory();
|
||||
String strExtractFolder = currentWorkingDirectory + "/" + "extracts";
|
||||
String strFileName = "API_NY.GDP.MKTP.CD_DS2_V2_USD.zip";
|
||||
String strPathFileName = currentWorkingDirectory + "/" + strFileName;
|
||||
sb.Append("http://api.worldbank.org/v2/en/indicator/NY.GDP.MKTP.CD?downloadformat=csv");
|
||||
strRequest = sb.ToString();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Downloading {0} from {1}", strFileName, strRequest));
|
||||
httpNetResponse = HttpNetRequest.GetRequestStreamZIP(strRequest);
|
||||
if (!httpNetResponse.Success)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
|
||||
return null;
|
||||
}
|
||||
if (File.Exists(strPathFileName)) File.Delete(strPathFileName);
|
||||
FileStream outStream = new FileStream(strPathFileName, FileMode.Create);
|
||||
byte[] streamBytes = httpNetResponse.ResponseStream.GetBuffer();
|
||||
outStream.Write(streamBytes, 0, streamBytes.Length);
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
outStream.Dispose();
|
||||
return EconomicIndicators.FromZipFile(strPathFileName, strExtractFolder, debug);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != httpNetResponse) httpNetResponse.Dispose();
|
||||
}
|
||||
}
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
// ************************************************************************** D I V I D E N D H I S T O R Y N A S D A Q ***********************************************************
|
||||
// ***************************************************************************************************************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user