private static void DownLoadLastPrice(List <string> ETFList, ref List <QuoteFiveDay> quoteFiveDayList) { string[] quotesArray = ETFList.ToArray(); IEnumerable <MaasOne.Finance.YahooFinance.QuoteProperty> properties = new MaasOne.Finance.YahooFinance.QuoteProperty[] { MaasOne.Finance.YahooFinance.QuoteProperty.Symbol, MaasOne.Finance.YahooFinance.QuoteProperty.LastTradePriceOnly }; //Download MaasOne.Finance.YahooFinance.QuotesDownload dl = new MaasOne.Finance.YahooFinance.QuotesDownload(); MaasOne.Base.Response <MaasOne.Finance.YahooFinance.QuotesResult> resp = dl.Download(quotesArray, properties); //Response/Result if (resp.Connection.State == MaasOne.Base.ConnectionState.Success) { int i = 0; foreach (MaasOne.Finance.YahooFinance.QuotesData qd in resp.Result.Items) { quoteFiveDayList.Add(new QuoteFiveDay() { Id = quotesArray[i], Last = qd.LastTradePriceOnly }); i++; } } }
/// <summary> /// Get the latest stock quote for this code or null if not found /// </summary> /// <param name="stockCode"></param> /// <returns></returns> public StockQuote Get(string stockCode) { var quotesDownload = new QuotesDownload(); var response = quotesDownload.Download(PostFixStockCode(stockCode), _quoteProperties); if (response.Connection.State == ConnectionState.Success) { var result = response.Result.Items.SingleOrDefault(); if (result != null) { return new StockQuote(stockCode.ToUpper(), Convert.ToDecimal(result.LastTradePriceOnly), result.LastTradeDate); } } return null; }
private void RetrieveQuoteProperties(string symbol, ref Dictionary<string, Object> stats) { QuotesDownload dl = new QuotesDownload(); DownloadClient<QuotesResult> baseDl = dl; QuotesDownloadSettings settings = dl.Settings; settings.IDs = new string[] { symbol }; settings.Properties = new QuoteProperty[] { QuoteProperty.Symbol, QuoteProperty.Name, QuoteProperty.LastTradePriceOnly, QuoteProperty.MarketCapitalization, QuoteProperty.PERatio, QuoteProperty.EBITDA, QuoteProperty.PEGRatio, QuoteProperty.Revenue, QuoteProperty.YearHigh, QuoteProperty.YearLow, QuoteProperty.ShortRatio, QuoteProperty.OneyrTargetPrice, QuoteProperty.AverageDailyVolume, QuoteProperty.BookValuePerShare, QuoteProperty.DilutedEPS, //QuoteProperty.TrailingAnnualDividendYield, QuoteProperty.TrailingAnnualDividendYieldInPercent, //QuoteProperty.SharesOutstanding }; Response<QuotesResult> resp = baseDl.Download(); SettingsBase baseSettings = baseDl.Settings; ConnectionInfo connInfo = resp.Connection; if (connInfo.State == ConnectionState.Success) { QuotesResult result = resp.Result; stats.Add("LastTradePriceOnly", CheckDecimalItem(Convert.ToString(result.Items[0].LastTradePriceOnly))); stats.Add("AverageDailyVolume", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.AverageDailyVolume)))); stats.Add("MarketCapitalization", GetDecimalFromConString(Convert.ToString(result.Items[0].Values(QuoteProperty.MarketCapitalization)))); stats.Add("EBITDA", GetDecimalFromConString(Convert.ToString(result.Items[0].Values(QuoteProperty.EBITDA)))); stats.Add("PEGRatio", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.PEGRatio)))); stats.Add("Revenue", GetDecimalFromConString(Convert.ToString(result.Items[0].Values(QuoteProperty.Revenue)))); stats.Add("PERatio", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.PERatio)))); stats.Add("YearHigh", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.YearHigh)))); stats.Add("YearLow", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.YearLow)))); stats.Add("ShortRatio", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.ShortRatio)))); stats.Add("OneyrTargetPrice", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.OneyrTargetPrice)))); stats.Add("BookValuePerShare", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.BookValuePerShare)))); stats.Add("DilutedEPS", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.DilutedEPS)))); stats.Add("Name", Convert.ToString(result.Items[0].Name)); stats.Add("TrailingAnnualDividendYieldInPercent", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.TrailingAnnualDividendYieldInPercent)))); //stats.Add("TrailingAnnualDividendYield", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.TrailingAnnualDividendYield)))); //stats.Add("SharesOutstanding", CheckDecimalItem(Convert.ToString(result.Items[0].Values(QuoteProperty.SharesOutstanding)))); } else { Exception ex = connInfo.Exception; Console.WriteLine(ex.Message); } }
public void RetrieveYahooCompanyInfo(string symbol, ref Dictionary<string, Object> stats) { CompanyInfoDownload d1 = new CompanyInfoDownload(); DownloadClient<CompanyInfoResult> baseD1 = d1; CompanyInfoDownloadSettings settings = d1.Settings; settings.IDs = new string[] { symbol }; Response<CompanyInfoResult> resp = baseD1.Download(); SettingsBase baseSettings = baseD1.Settings; ConnectionInfo connInfo = resp.Connection; if (connInfo.State == ConnectionState.Success) { CompanyInfoResult result = resp.Result; stats.Add("Sector", result.Items[0].SectorName); stats.Add("Industry", result.Items[0].IndustryName); } else { Exception ex = connInfo.Exception; Console.WriteLine(ex.Message); } QuotesDownload d2 = new QuotesDownload(); DownloadClient<QuotesResult> baseD2 = d2; QuotesDownloadSettings settings1 = d2.Settings; settings1.IDs = new string[] { symbol }; settings1.Properties = new QuoteProperty[] { QuoteProperty.Symbol, QuoteProperty.Name }; Response<QuotesResult> resp1 = baseD2.Download(); SettingsBase baseSettings1 = baseD2.Settings; ConnectionInfo connInfo1 = resp1.Connection; if (connInfo1.State == ConnectionState.Success) { QuotesResult result = resp1.Result; stats.Add("Name", Convert.ToString(result.Items[0].Name)); } else { Exception ex = connInfo.Exception; Console.WriteLine(ex.Message); } }