Skip to main content

A structured Python interface for retrieving and validating market data using yfinance

Project description

yfinance

A structured Python interface for retrieving and validating market data using yfinance. Implements the DataSource protocol from pydantic-market-data to provide type-safe security resolution and historical data fetching.

Features

  • Protocol-Oriented: Implements DataSource interface.
  • Security Resolution: Resolve ISINs and Symbols to valid yfinance tickers.
  • Validation:
    • Price Validation: Verify tickers against daily high/low range.
    • Date Validation: Validate prices on specific historical dates.
  • CLI: Optional command-line interface for lookup and history.

Installation

# Basic installation
uv pip install yfinance

Usage

As a Library

from py_yfinance.source import YFinanceDataSource
from pydantic_market_data.models import SecurityCriteria

source = YFinanceDataSource()

# 1. Simple Lookup by Symbol
criteria = SecurityCriteria(symbol="AAPL")
result = source.resolve(criteria)
print(result)
# Symbol(ticker='AAPL', name='Apple Inc.', exchange='NMS', currency='USD', ...)

# 2. Strict Validation using Date & Price
# Useful for verifying ISIN mappings or ensuring data quality
criteria = SecurityCriteria(
    isin="NL0010273215",
    target_date="2025-12-15",
    target_price=923.4  # Validates against history
)
match = source.resolve(criteria)
if match:
    print(f"Verified: {match.ticker}")
else:
    print("Validation failed: Price mismatch or symbol not found")

CLI Usage

Lookup

Resolve a security by Symbol or ISIN.

# Basic Lookup
uv run yfinance lookup --symbol AAPL

# ISIN Lookup with Strict Validation
# Verifies that NL0010273215 commanded a price of ~923.4 on 2025-12-15
uv run yfinance lookup --isin NL0010273215 --date 2025-12-15 --price 923.4

History

Fetch historical candles.

uv run yfinance history AAPL --period 5d

Development

This project uses uv for dependency management.

# Sync dependencies
uv sync

# Run Tests
uv run pytest

License

MIT

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

py_yfinance-0.1.7.tar.gz (116.5 kB view details)

Uploaded Source

Built Distribution

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

py_yfinance-0.1.7-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file py_yfinance-0.1.7.tar.gz.

File metadata

  • Download URL: py_yfinance-0.1.7.tar.gz
  • Upload date:
  • Size: 116.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for py_yfinance-0.1.7.tar.gz
Algorithm Hash digest
SHA256 49fb3cf80ecbc19b44ce373cbd08c98778705369e993f414dc928d99c4abc8a4
MD5 4b240e7d207c2c0fc2be01f1e2b81bd3
BLAKE2b-256 cc2e777538d781e406bacdc4a5c538227af2fe5841e8665154b6eb87506416f4

See more details on using hashes here.

File details

Details for the file py_yfinance-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: py_yfinance-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for py_yfinance-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 95e7f9be05a59fcc2ca3a36144e03b5f60911d697be8c2dc00cf2eaf9b97c604
MD5 03ed9f0a29c2c8b5484516898e0f8de2
BLAKE2b-256 885ec9d4f2e9a989f84f7166dbd118c106a1ddff1caf663f0bfdd66cef2b1bec

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