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.2.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.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yf_simple_fetcher-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 f6ab708b10b2927e54c57c1db59ae9f4c4ec7c10e161b94451749ca0f025bab5
MD5 b23d9077695e55fc268da2ed875852da
BLAKE2b-256 e1d08f3f264ee6d1101240f0c4f1b43ceed076a1499c87c77823ba7856e083b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yf_simple_fetcher-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 583af6155a2fb3c563bfdf81849dc7751d2697ab7d84929630c937718a5dd10f
MD5 54173755973e75541fe1b7a44b064abf
BLAKE2b-256 773e5a1543e3121569c0c15dfdf8f1a82a014484588fb59dc454e8a792d1ccc6

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