获取Google财经/雅虎财经的报价

时间:2012-06-25 00:02:02

标签: c# finance

我如何在C#上收到股票报价? Google财经API不是很有帮助

4 个答案:

答案 0 :(得分:1)

你看过这个吗?非常有用的例子。

http://www.jarloo.com/real-time-google-stock-api/

答案 1 :(得分:1)

Google Finance API替代方案。AlphaVantage是Google的Finance API的免费,优秀替代方案。您可以注册免费的API密钥,以开始检索实时和历史股票市场报价。

如何使用C#检索AlphaVantage股票市场数据?以下是一些示例代码,用于检索C#中的每月股票市场价格。您将需要安装ServiceStack.Text-一种免费的,开源的高性能.NET文本实用程序,以运行以下命令(安装包ServiceStack.Text)。

library(data.table)
setDT(df)[, .SD[.N == 9], .(group = cumsum(sequence == 1))
          ][order(-date), .SD[which.min(low)], group]

您可以在gistlyn here中运行以上示例代码。 我写了整篇文章“ AlphaVantage和C#” here

答案 2 :(得分:0)

我建议你通过Stock quote from Yahoo! in C#文章访问雅虎的股票报价......

答案 3 :(得分:0)

最快的方法之一是使用yahoo http请求(有些详细信息可以在http://www.gummy-stuff.org/Yahoo-data.htm中找到)

然后使用以下代码以编程方式检索结果,而不是手动下载或使用电子表格。

public static string Extract(string yahooHttpRequestString)
{
      //if need to pass proxy using local configuration  
      System.Net.WebClient webClient = new WebClient();  
      webClient.Proxy = HttpWebRequest.GetSystemWebProxy();  
      webClient.Proxy.Credentials = CredentialCache.DefaultCredentials;  

      Stream strm = webClient.OpenRead(yahooHttpRequestString);  
      StreamReader sr = new StreamReader(strm);  
      string result = sr.ReadToEnd();            
      strm.Close();             
      return result;  
}  

然后你可以进一步处理返回的字符串,或修改上面的代码来解析引用的每个段的字符串,进入更详细的数据结构。