Skip to main content

Yahoo Finance API

Minimal API to interact with Yahoo Finance.

Installation

pip install yahoo_finance_api2

Usage

The following example retrieves 10 days of 5 minute frequency Microsoft (MSFT) stock data.

import sys
from yahoo_finance_api2 import share
from yahoo_finance_api2.exceptions import YahooFinanceError

my_share = share.Share('MSFT')
symbol_data = None

try:
    symbol_data = my_share.get_historical(share.PERIOD_TYPE_DAY,
                                          10,
                                          share.FREQUENCY_TYPE_MINUTE,
                                          5)
except YahooFinanceError as e:
    print(e.message)
    sys.exit(1)

print(symbol_data)

The output format:

{
  'timestamp': [...],
  'open': [...],
  'high': [...],
  'low': [...],
  'close': [...],
  'adj_close': [...],
  'volume': [...]
}

API

  • Class Share:
    • get_historical(period_type, period, frequency_type, frequency)
      • Returns historical data for the given period type (share.PERIOD_TYPE_DAY, share.PERIOD_TYPE_WEEK, share.PERIOD_TYPE_MONTH, share.PERIOD_TYPE_YEAR), period (1, 5, 10, etc.), frequency_type (share.FREQUENCY_TYPE_MINUTE, share.FREQUENCY_TYPE_DAY, share.FREQUENCY_TYPE_MONTH, share.FREQUENCY_TYPE_YEAR), and frequency (1, 5, 10, etc.). Only certain combinations of these parameters are allowed.

Release files for yahoo-finance-api2 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yahoo-finance-api2 0.0.12
File Size Uploaded
yahoo_finance_api2-0.0.12.tar.gz 3.2 kB Details

Release files / yahoo_finance_api2-0.0.12.tar.gz

Download URL yahoo_finance_api2-0.0.12.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
64ce96adfd62cf74506938597039a1372701a974d1a2cf0dec00a3bc8b24a8f3
BLAKE2b-256 checksum
How to use checksums
b0f884b44878bc6211cbc8b463729d9a5777e9f818c3d29cbdc9786e8fbb4e3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.12 This release

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page