15

getSymbols and Alpha Vantage

 3 years ago
source link: http://blog.fosstrading.com/2017/10/getsymbols-and-alpha-vantage.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

getSymbols and Alpha Vantage

October 06, 2017

Thanks to Paul Teetor, getSymbols() can now import data from Alpha Vantage!  This feature is part of the quantmod 0.4-11 release, and provides another another data source to avoid any Yahoo Finance API changes*.

Alpha Vantage is a free web service that provides real-time and historical equity data.  They provide daily, weekly, and monthly history for both domestic and international markets, with up to 20 years of history. Dividend and split adjusted close prices are available for daily data. They also provide near real-time price bars at a resolution of 1 minute or more, for up to 10 recent days.

All you need to get started is a one-time registration for an API key.  Alpha Vantage has clean, documented, public API that returns either JSON-encoded data or a CSV file.  The arguments to getSymbols.av() closely follow the native API, so be sure to use their documentation!

To get started, install the latest quantmod from CRAN.  Then you call:

getSymbols("MSFT", src = "av", api.key = "\[your key\]") 

Where you replace "\[your key"\] with the API key you receive after registration.  You can use setDefaults() to set your API key one time, and use it for all getSymbols.av() calls.

setDefaults("getSymbols.av", api.key = "\[your key\]")

* Speaking of API changes, this release also includes a fix for a Yahoo Finance change (#174).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK