使用IEX API进行实时股票信息(雅虎财经更换)?

就像标题所说,我现在正在寻找股票信息的替代来源,雅虎已经禁用许多人已经使用的API。 我一直在寻找的新来源是: https : //iextrading.com/developer/

我的问题是如何实际获得数据到Excel中…我想通过VBA,因为这是我用来从雅虎的数据。 然而,我想我想要做的是远远超出我目前的能力…我也尝试使用Excel的WEBSERVICE()函数与下面的URL来看看一个价格: https ://api.iextrading.com/1.0 /股票/ AAPL /价格,但没有奏效。 据我了解,IEX已经为我们免费提供了大量的数据,我只是不知道如何访问它。 我对VBA的推理是为了能够使用工作簿中的input列表来获取代码,并且能够将这些数据访问放在许多工作簿中。 任何帮助深表感谢。 另外,对于我自己可以从哪里开始学习的任何方向都会受到同样的欢迎。 谢谢。

更新:我的评论中提到的代码

Function StockPrice(ticker As String, item As String) As Double Dim strURL As String, strCSV As Double, itemFound As Integer, tag As String itemFound = 0 If item = "lastprice" Then tag = "price" itemFound = 1 ElseIf item = "pe" Then tag = "peRatio" itemFound = 1 End If If itemFound = 1 Then strURL = "https://api.iextrading.com/1.0/stock/" & ticker & "/" & tag Set XMLHTTP = CreateObject("MSXML2.XMLHTTP") XMLHTTP.Open "GET", strURL, False XMLHTTP.send StockPrice = XMLHTTP.responseText Set XMLHTTP = Nothing Else StockPrice = "Item Not Found" End If End Function 

这可能有点简单,但这是一个开始:

 Sub IEX() Dim Price As Single Price = Application.WebService("https://api.iextrading.com/1.0/stock/aapl/price") End Sub 

我想我已经解决了这个问题。 这里是任何有兴趣的人的代码。 这可以直接替代那些使用Yahoo Finance API的人。

 Function StockPrice(ticker As String, item As String) Dim strURL As String, strCSV As Double, itemFound As Integer, tag As String itemFound = 0 If item = "lastprice" Then tag = "latestPrice" itemFound = 1 ElseIf item = "pe" Then tag = "peRatio" itemFound = 1 ElseIf item = "company" Then tag = "companyName" itemFound = 1 ElseIf item = "sector" Then tag = "sector" itemFound = 1 ElseIf item = "open" Then tag = "open" itemFound = 1 ElseIf item = "yclose" Then tag = "previousClose" itemFound = 1 ElseIf item = "change" Then tag = "change" itemFound = 1 ElseIf item = "%change" Then tag = "changePercent" itemFound = 1 ElseIf item = "marketcap" Then tag = "marketCap" itemFound = 1 ElseIf item = "52high" Then tag = "week52High" itemFound = 1 ElseIf item = "52low" Then tag = "week52Low" itemFound = 1 End If If itemFound = 1 Then strURL = "https://api.iextrading.com/1.0/stock/" & ticker & "/quote/" & tag Set XMLHTTP = CreateObject("MSXML2.XMLHTTP") XMLHTTP.Open "GET", strURL, False XMLHTTP.send StockPrice = XMLHTTP.responseText Set XMLHTTP = Nothing Else StockPrice = "Item Not Found" End If End Function 

IEX比我在这里build立的function多得多。 只是没有足够的经验来构build它。 在这里查看这些function: https : //iextrading.com/developer/docs/