It looks like there once were some useful YQL ways to get option data that no longer work. At least I couldn't get them to work.
Are there any new ones that have taken their place? Anyone have a good alternative to YQL if not?
It looks like there once were some useful YQL ways to get option data that no longer work. At least I couldn't get them to work.
Are there any new ones that have taken their place? Anyone have a good alternative to YQL if not?
The only source I've found so far is Quandl. However, their data is spread over multiple data sets and it is a paid subscription for some premium data sets. The free service gets you a lot though.
To install just use pip install quandl
. Their python user guide is located here https://github.com/quandl/quandl-python.
Here's an example of pulling dividend data over a period from quandl.
import quandl
import requests
import pandas as pd
import io
from datetime import datetime
ticker = 'MSFT'
start = '2010-05-01'
end = '2017-05-31'
url = 'https://www.quandl.com/api/v3/datasets/WIKI/{}.csv?trim_start={}&trim_end={}'\
.format(ticker, start, end)
urlData = requests.get(url).content
rawData = pd.read_csv(io.StringIO(urlData.decode('utf-8'))).sort_values(by='Date').set_index('Date')
df = pd.DataFrame(rawData[rawData['Ex-Dividend'] != 0]['Ex-Dividend'])
df.index = pd.to_datetime(df.index)
start = datetime(2015, 1, 20)
end = datetime(2017, 1, 20)
df[start:end]
If you're only looking for US data and are comfortable with Node.js then there are some excellent packages on npm :
https://github.com/pilwon/node-yahoo-finance
https://github.com/richardlevano/yahoo-nasdaq
These basically work by scraping the yahoo website, or downloading data available in CSV using the request Nodejs library and then parsing it. It is also simple to write your own scraper to do the same if you look at the code.
If you're using node-yahoo-finance, then simply use
yahooFinance.snapshot({
symbols: [SYMBOL1, SYMBOL2],
fields: FIELDS // ex: ['s', 'n', 'd1', 'l1', 'y', 'r']
}, function (err, snapshot) {
/*
{
AAPL: {
symbol: 'AAPL',
name: 'Apple Inc.',
lastTradeDate: '11/15/2013',
lastTradePriceOnly: '524.88',
dividendYield: '2.23',
peRatio: '13.29'
},
GOOGL: {
symbol: 'GOOGL',
name: 'Google Inc.',
lastTradeDate: '11/15/2013',
lastTradePriceOnly: '1034.23',
dividendYield: 'N/A',
peRatio: '28.17'
}
}
*/
});
And for options data (bid-ask spread)
a: Ask
b: Bid
b2: Ask (Realtime)
b3: Bid (Realtime)
p: Previous Close
o: Open
Check out more NPM packages here :- https://www.npmjs.com/browse/keyword/finance