Yet another change in the API from Google?!
The simple example worked yesterday, not so today...
same here
In [54]: param = {
...: 'q': "APPL",
...: 'i': "86400",
...: 'x': "NASD",
...: 'p': "1Y"
...: }
In [55]: get_price_data(param)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-55-2c29cc213674> in <module>()
----> 1 get_price_data(param)
c:\python27\lib\site-packages\googlefinance\client.pyc in get_price_data(query)
13 cols = price.split(",")
14 if cols[0][0] == 'a':
---> 15 basetime = int(cols[0][1:])
16 index.append(datetime.fromtimestamp(basetime))
17 data.append([float(cols[4]), float(cols[2]), float(cols[3]), float(cols[1]), int(cols[5])])
ValueError: invalid literal for int() with base 10: 'pplied physics as regular articles'
Same here.
same problem ..
same. Let's all pray they don't pull a Yahoo Finance API...
I tried to run the sample code: from googlefinance.client import get_price_data, get_prices_data, get_prices_time_data
Dow Jones
param = { 'q': ".DJI", # Stock symbol (ex: "AAPL") 'i': "86400", # Interval size in seconds ("86400" = 1 day intervals) 'x': "INDEXDJX", # Stock exchange symbol on which stock is traded (ex: "NASD") 'p': "1Y" # Period (Ex: "1Y" = 1 year) }
get price data (return pandas dataframe)
df = get_price_data(param) print(df)
and got an empty data frame. I also tried running similar code and got the following error:
ValueError: invalid literal for int() with base 10: '24 hours a day'
Does this mean the API is down?
they have 403: forbidden error
Any new on this? Im alredy thinking abount moving to another API.
I built some code based on pulling intraday data from the google finance api to create a pandas dataframe:
import pandas as pd api = 'http://finance.google.com/finance/getprices?q=' + stock +'&i=300&p=3d&f=d,o,h,l,c,' df = pd.read_csv(api, skiprows=8, header=None) price.columns = ['Record', 'Open', 'High', 'Low', 'Close']
Since the google api stopped working I found another way to get the same data via IEX API by calling https://api.iextrading.com/1.0/stock/aapl/chart/1d?chartInterval=5
My question is ... how do I get the IEX data into a pandas dataframe using the link above like I used to do with google. Probably simple but I just don't know it !
Thanks!
I'm getting the data and converting to excel file maybe you can try getting it into the csv format here's the snippet I use check the json and add the objects you need
import json,requests,pprint,xlsxwriter
response = requests.get("https://api.iextrading.com/1.0/stock/msft/chart/date/20180801")
workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': True})
worksheet.write('A1', 'minute', bold)
worksheet.write('B1', 'open', bold)
worksheet.write('C1', 'high', bold)
worksheet.write('D1', 'low', bold)
worksheet.write('E1', 'close', bold)
row=1
col=0
todos = json.loads(response.text)
for x in todos:
print x['minute']," ",x['high']," ",x['low']," ",x['close']
worksheet.write(row, col, x['minute'])
worksheet.write(row, col+1, x['open'])
worksheet.write(row, col+2, x['high'])
worksheet.write(row, col+3, x['low'])
worksheet.write(row, col+4, x['close'])
row += 1
workbook.close()
Is someone going to make a PR to match the syntax of the new format? -lazydev @dan-aksenov What other APIs are available? I feel like I end up cycling through price APIs every 6 months and it's really slowing down the development of my trading models
I converted to alpha vantage. It requires a API key, but it is free, and data goes back up to 20 years (iex only had 5 years of historical data). The python module below made is very easy.
https://pypi.org/project/alpha_vantage/
https://www.alphavantage.co/
I would like to try that option, but how on earth do I figure out what data is available? Tried to register on the forum, but that only insists that my "registration is spam"! It then tells me to ask an administrator to invite me instead, but of course without any description of how to do such a thing. Seems really unprofessional, so I am actually not very hopeful about this either...
enter your info on the alphavantage page to get an API key:
https://www.alphavantage.co/support/#api-key
I entered info and was immediately shown my free API key