dimanche 3 décembre 2017

Webservice data from alphavantage.com to get financial data

I am using Excel 2016 and do NOT have any issues when I use the Webservice functions as follows:

=WEBSERVICE("http://ift.tt/2iJ9JOG")

I changed my api key to DEMO as i did not want to display mine here. You can easily get an api key at their website.

The problem is when I use the following code, it does not work. I use this code for other websites like yahoo.finace (until they stop supporting it), or iextrading.com and it works fine. But not for alpha advantage.

    sURL = "http://ift.tt/2AKNP4N?
    function=TIME_SERIES_DAILY&symbol=T&apikey=DEMO&datatype=csv"


    With Worksheets("Scratch").QueryTables.Add(Connection:="URL;" & sURL, 
    Destination:=Worksheets("Scratch").Range("A1"))
            .BackgroundQuery = True
            .TablesOnlyFromHTML = False
            .RefreshStyle = xlOverwriteCells 'this code is needed to prevent 
    adding a new column each time data is entered.
            .Refresh BackgroundQuery:=False
            .SaveData = True
    End With

Any suggestions on why this code is not working? Or is there another site that works well? I liked yahoo.finace but no longer works. iextrading.com is ok but does not work on ETFs. alphavantage.co does but does not output that company name.




Aucun commentaire:

Enregistrer un commentaire