Skip to main content

A simple package to fetch ready-to-use stock data from yfinance

Project description

yf_simple_fetcher

A simple Python library to fetch historical stock data from Yahoo Finance (yfinance) with flexible intervals and clean, ready-to-use DataFrames.


Features

  • Fetch ready-to-use data for any stock by default.
  • Supports custom intervals like 1min, 15min, hourly, daily.
  • Automatically handles yfinance MultiIndex issues.
  • Returns clean pandas.DataFrame with datetime index and simple column names.
  • Easy to extend with custom intervals or periods.

Installation

pip install yf-simple-fetcher

Usage

Basic Usage (1-year hourly data)

from yf_simple_fetcher import get_data

# 1-year hourly data
df_hourly = get_data("AAPL", "hourly")
print(df_hourly.head())

Custom Intervals

# 2-year daily data
df_daily = get_data("AAPL", "daily")

# Last month, 15-minute data
df_15min = get_data("AAPL", "15min")

# Last week, 1-minute data
df_1min = get_data("AAPL", "1min")

Available Presets

By default, the library includes:

interval_periods = {
    "hourly": {"interval": "1h", "start": datetime.now() - timedelta(days=365), "end": datetime.now()},
    "daily": {"interval": "1d", "start": datetime.now() - timedelta(days=730), "end": datetime.now()},
    "15min": {"interval": "15m", "start": datetime.now() - timedelta(days=30), "end": datetime.now()},
}

You can add your own presets easily by updating the interval_periods dictionary.


Example Output

                       Open      High       Low     Close     Volume
2024-01-10 14:00    147.23    148.12    146.80    147.90    4556123
2024-01-10 15:00    147.90    148.55    147.44    148.30    3894411
...

Installation for Development (optional)

If you want to edit or extend the library locally:

git clone https://github.com/devwithmpho/yf_simple_fetcher.git
cd yf_simple_fetcher
pip install -e .

Dependencies


License

MIT License. See LICENSE for details.


Author

Mpho

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

yf_simple_fetcher-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yf_simple_fetcher-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file yf_simple_fetcher-0.1.1.tar.gz.

File metadata

  • Download URL: yf_simple_fetcher-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for yf_simple_fetcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 749fa5950e56ce1c3c1af894bbdc60a836c4677c0b2d480e2b79f8b5ec09bcf8
MD5 22c87f5672d41003a8ca76d16267abdd
BLAKE2b-256 7102f2d4e901ab1c86cb9bebbc3c9625f215933c7ced9b3e7c163edb8318a9fb

See more details on using hashes here.

File details

Details for the file yf_simple_fetcher-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for yf_simple_fetcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dcfc11306c00f31442abc6981131512a8fbe43e3c7d422660920e846f0762ef
MD5 d723db6267aa4d19982957f236dd2ebc
BLAKE2b-256 9fbffdf38cd33b800c04ab09c96caa3b8eca212de71bf0325a674b846b7c2770

See more details on using hashes here.

Supported by

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