Giter VIP home page Giter VIP logo

python-yahoo-finance-download's Introduction

Download data from Yahoo Finance API

Get quote, dividend and split history for a given ticker symbol from a specified starting date to today.

Inspired by c0redumb's yahoo_quote_download and rubenafo's YahooFetcher, but implemented using requests for fetching data, and returning Pandas dataframes.

New Yahoo API

Yahoo Finance changed how their stock data API works as of May, 2017. The data is still available on Yahoo Finance pages, but the new API uses authentication via a cookie and a 'crumb'. This module obtains these with an initial request and uses them for the subsequent requests.

For the Yahoo Finance API changes read c0redumb's description.

Class

Downloader()

from yahoo_downloader import Downloader

downloader = Downloader()

Methods

downloader.get_history(ticker, years=20)

Returns quotes, dividends and splits in single Pandas DataFrame for the given ticker and specified number of years ending today (or the latest available).

Splits are filled with 1s between split dates and dividends filled with 0s between ex-dividend dates (as in the Quandl Python API) to make further adjustments easier. No other transformations are made on Yahoo Finance data.

downloader.settings()

Return the currently set ticker and year range in (ticker, years) tuple.

Example

from yahoo_downloader import Downloader

downloader = Downloader()

# Full data:
df = downloader.get_history('MSFT', years=10)

# Check settings:
settings = downloader.settings()
print(settings)

>>> ('MSFT', 10)

print(df.info())

<class 'pandas.core.frame.DataFrame'>
Index: 2518 entries, '2007-06-08' to '2017-06-07'
Data columns (total 8 columns):
Open            2518 non-null float64
High            2518 non-null float64
Low             2518 non-null float64
Close           2518 non-null float64
Adj Close       2518 non-null float64
Volume          2518 non-null int64
Dividends       2518 non-null float64
Stock Splits    2518 non-null int64
dtypes: float64(6), int64(2)
memory usage: 177.0+ KB

python-yahoo-finance-download's People

Contributors

somiandras avatar

Stargazers

Morgen Friedel avatar  avatar Stubertus avatar

Watchers

James Cloos avatar  avatar

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.