Python Forum
Get DataFrame from GoogleFinance Client
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get DataFrame from GoogleFinance Client
#1
How to use python 3.6 to get dataframes by using Google Finance Client (import googlefinance.client as gf) ?
I would like to get data from this URL: http://www.google.com/finance/getprices?...,o,h,l,c,v
Thanks.
Reply
#2
The examples are pretty clear.
https://github.com/pdevty/googlefinance-client-python
What is not clear? As far as I can see you want to get data for FB stock. To get help - show us what you have done so far - post your code in code tags, ask questions about problems you cannot resolve. In case you get error - post the full traceback in error tags
Reply
#3
I can use the following to get dataframe but it is daily data.
I am wondering if I can get dataframe of 5-minute data in the url but don't know how to make a function call like below. Thanks.
http://www.google.com/finance/getprices?...,o,h,l,c,v

import pandas as pd
import googlefinance.client as gf

param = {'q': 'FB','i': "86400",'x': "NASD",'P': "3M"}
df = pd.DataFrame(gf.get_price_data(param))
print(df)
Reply
#4
param is a dict that supply params to the function get_price_data.
'q' is the stock symbol
'i' is the interval in seconds. the example is '86400' (that is 24 hours * 60 minutes * 60 seconds). if you want 5 minutes interval it should be '300' (5 minutes * 60 seconds)
'x' is the exchange whre it is traded ('NASD' for NSADAQ)
'p' is the period - in your case '3M'. Note that it is lower-case 'p' in the example. In your code it is upper-case, which may or may not be a problem (depending on the package). To be on the safe side I would change it to 'p'

Also
df=pd.DataFrame(gf.get_price_data(param))
Could be just
df=gf.get_price_data(param)
get_price_data will return DataFrame as per the example
Reply
#5
very nice. Thank you.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020