Skip to main content

Download historical financial data from yahoo finance

Project description

Yahoo Finance Historical Data Downloader

Download historical price, dividends and stock splits data from yahoo finance in python.

Installation

  • This module runs on python >= 3.3. It might run on other version, but has not been tested.
  • Dependencies: numpy, pandas, requests, pandas_market_calendars.
  1. Installation using pip:
    $ pip install yahoo_finance_hdd
    
  2. Installation using github:
    $ git clone https://github.com/sdiz/yahoo_finance_hdd.git
    $ cd yahoo_finance_hdd
    $ python setup.py install
    

Usage

  • The data from all methods is returned as a pandas dataframe.
  • Create a parameters object to define all necessary input parameters
    • start : the start date of the data series ('yyyy-mm-dd').
    • end : the end date of the data series ('yyyy-mm-dd').
    • tickers : single tickers can be passed as a string. Multiple tickers have to be passed as a list e.g ['IBM', 'AAPL'].
    • interval : specify the frequency of the data series.
      • 'd' = daily
      • 'w' = weekly
      • 'm' = monthly
    • exchange : the exchange to obtain the dates for the data series (default NYSE)
      • available exchanges are: ['BMF', 'CFE', 'CME', 'CBOT', 'COMEX', 'NYMEX', 'EUREX', 'ICE', 'ICEUS', 'NYFE', 'JPX', 'LSE', 'NYSE', 'stock', 'NASDAQ', 'BATS', 'OSE', 'SIX', 'TSX', 'TSXV', 'SSE', 'HKEX']
    • columns : a list of strings specifying the data columns to be returned.
      • ['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']
  • Available methods
    • get_history(params) : download historical financial price data from yahoo finance.
    • get_dividends(params) : download historical dividend data from yahoo finance.
    • get_splits(params) : download historical data for stock splits from yahoo finance.

Examples

from yahoo_finance_hdd import YahooFinance, Parameters

# create parameter object
params = Parameters(
            start = '2010-12-01',
            end = '2019-08-20',
            tickers = ['AAPL', 'VZ', 'JPM'],
            interval = 'w',
            exchange = 'NYSE',
            columns = ['Open', 'Close']
        )

# e.g change interval to daily
params.interval = 'd'

# create new yahoo finance instance
yf = YahooFinance()

# download historical financial price data
price_df = yf.get_history(params)

# download historical dividends data
dividends_df = yf.get_dividends(params)

# download historical stock splits data
splits_df = yf.get_splits(params)

Returned Data

alt text

Authors

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yahoo_finance_hdd-0.2.2.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file yahoo_finance_hdd-0.2.2.tar.gz.

File metadata

  • Download URL: yahoo_finance_hdd-0.2.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.4

File hashes

Hashes for yahoo_finance_hdd-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ac8068c9825c8fabe3011f3691420c52d62d02ebaef5c8cc0c3e2596202cec8c
MD5 96605d59c26d36dea29e7f3ed6190423
BLAKE2b-256 0e44ca801fb2b73f78d597ee6f333faa28b3f75d152f6d184c44bf21a2bf6571

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page