Code Monkey home page Code Monkey logo

googlefinance-client-python's Introduction

googlefinance.client

googlefinance.client is a python client library for google finance api

Installation

$ pip install googlefinance.client

Usage

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)
#                          Open      High       Low     Close     Volume
# 2016-05-17 05:00:00  17531.76   17755.8  17531.76  17710.71   88436105
# 2016-05-18 05:00:00  17701.46  17701.46  17469.92  17529.98  103253947
# 2016-05-19 05:00:00  17501.28  17636.22  17418.21  17526.62   79038923
# 2016-05-20 05:00:00  17514.16  17514.16  17331.07   17435.4   95531058
# 2016-05-21 05:00:00  17437.32  17571.75  17437.32  17500.94  111992332
# ...                       ...       ...       ...       ...        ...

params = [
	# Dow Jones
	{
		'q': ".DJI",
		'x': "INDEXDJX",
	},
	# NYSE COMPOSITE (DJ)
	{
		'q': "NYA",
		'x': "INDEXNYSEGIS",
	},
	# S&P 500
	{
		'q': ".INX",
		'x': "INDEXSP",
	}
]
period = "1Y"
# get open, high, low, close, volume data (return pandas dataframe)
df = get_prices_data(params, period)
print(df)
#            .DJI_Open  .DJI_High  .DJI_Low  .DJI_Close  .DJI_Volume  \
# 2016-07-20   18503.12   18562.53  18495.11    18559.01    85840786   
# 2016-07-21   18582.70   18622.01  18555.65    18595.03    93233337   
# 2016-07-22   18589.96   18590.44  18469.67    18517.23    86803016   
# 2016-07-23   18524.15   18571.30  18491.59    18570.85    87706622   
# 2016-07-26   18554.49   18555.69  18452.62    18493.06    76807470   
# ...               ...        ...       ...         ...         ...   

params = [
	# Dow Jones
	{
		'q': ".DJI",
		'x': "INDEXDJX",
	},
	# NYSE COMPOSITE (DJ)
	{
		'q': "NYA",
		'x': "INDEXNYSEGIS",
	},
	# S&P 500
	{
		'q': ".INX",
		'x': "INDEXSP",
	}
]
period = "1Y"
interval = 60*30 # 30 minutes
# get open, high, low, close, volume time data (return pandas dataframe)
df = get_prices_time_data(params, period, interval)
print(df)
#                      .DJI_Open  .DJI_High  .DJI_Low  .DJI_Close  .DJI_Volume  \
# 2016-07-19 23:00:00   18503.12   18542.13  18495.11    18522.47            0   
# 2016-07-19 23:30:00   18522.44   18553.30  18509.25    18546.27            0   
# 2016-07-20 00:00:00   18546.20   18549.59  18519.77    18539.93            0   
# 2016-07-20 00:30:00   18540.24   18549.80  18526.99    18534.18            0   
# 2016-07-20 01:00:00   18534.05   18540.38  18507.34    18516.41            0   
# ...                        ...        ...       ...         ...          ...   

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

googlefinance-client-python's People

Contributors

pdevty avatar warrickpk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googlefinance-client-python's Issues

Empty Data Frame

This is my code.

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)

For some reason, the results dont produce anything in the columns. Do I need to write more?

Empty DataFrame
Columns: [Open, High, Low, Close, Volume]
Index: []

ts parameter and p='{x}d' parameter

According to :
http://www.networkerror.org/component/content/44.html?task=view

ts - Starting timestamp (Unix format). If blank, it uses today.

and

p - Period. (A number followed by a "d" or "Y", eg. Days or years. Ex: 40Y = 40 years.)

Which, used together allow to fine tune the date range of the data, ease the use of the downloaded file and make the library convenient for use cases involving data not starting from today.

In the current state of affair, we can process the returned dataframe in order to get only the desired range, but it's an unecessary waste of computional ressource and require to use a wrapper to make good use of the library beyond a single case.

The package should be modified in order to take that into account.

get_closing_data() seems to lag behind (problem with API itself)

Pulling the closing data for the past year today, on 9/07/17, after market close, yields data from 9/08/16 to 9/05/17, skipping the 9/6 and 9/7 market closes. Doing the same thing yesterday, on 9/06/17, after market close, yielded data from 9/07/16 to 9/05/17. get_prices_time_data() has the same problem when pulling daily data (606024 as interval), but changing the interval to 60*60 (hourly) yields up-to-date data.

Edit: actually, this seems to be a problem with the API itself. It is unofficial, after all.

Not working

I think the Google Finance API is changed, so the version is not working. Any plans to update?

Not working

It seems that the solution in thread 3 is not working now. Any updates recently?

get_closing_data returns empty dataframe

As of today (Nov 10, 2017) get_closing_data is returning an empty dataframe, as does get_open_close_data. I don't use the other methods, but the examples seem to work fine when client.py is run.

We've already lost Yahoo finance, please don't let us loose Google Finance as well.

Wrong data from google finance for several ticker symbols

HI there,

Iam facing the problem that wrong values are recieved, for example the tickers FRA:ADE, FRA:SIE, FRA:IFX

Do I have to use the script in a specific way when calling FRA, as some of the values are correct and some are not.

Thanks in advance
Ang3er

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.