Skip to main content

A lightweight utility to scrape and retrieve financial index constituents, including S&P 500, Nasdaq-100, S&P 100, and S&P/CLX IPSA.

Reason this release was yanked:

get_ipsa function not working as expected

Project description

Indexes: A Lightweight S&P 500, Nasdaq-100, S&P 100 & S&P/CLX IPSA Scraper

indexes is a professional Python utility designed to scrape and retrieve financial index constituents, providing developers with a clean, programmatic interface to access real-time market data. It simplifies the process of extracting stock market components from the S&P 500, Nasdaq-100, S&P 100, and S&P/CLX IPSA (Chile) for financial analysis and algorithmic trading.

License PyPI version Python versions Financial Data Extraction

Why use Indexes?

For financial analysts and Python developers, keeping up-to-date lists of S&P 500, Nasdaq-100, S&P 100, and IPSA constituents can be tedious. indexes provides a simple, cached interface to fetch this data from reliable public sources (like Wikipedia and Yahoo Finance), returning essential metadata such as Sector, Industry, CIK, and more.

Key Features

  • Efficient Scrapers: Get up-to-date S&P 500, Nasdaq-100, S&P 100, and S&P/CLX IPSA constituents in seconds.
  • Flexible Data Formats: Retrieve results as a Python list or a dict keyed by symbol.
  • Granular Field Selection: Extract only what you need.
  • Smart Caching: Minimizes network requests by caching data within the same execution session.
  • Minimalist Design: Zero-config, lightweight, and easy to integrate into larger financial pipelines.

Installation

Install the package via pip:

pip install indexes

Requirements

  • Python >= 3.8
  • requests
  • beautifulsoup4

Quick Start & Usage

from indexes import get_sp500, get_nasdaq100, get_sp100, get_ipsa

# Get a simple list of all S&P 500 ticker symbols
sp500_symbols = get_sp500()

# Get S&P 100 symbols
sp100_symbols = get_sp100()

# Get IPSA symbols (Chilean main stocks)
ipsa_symbols = get_ipsa()

# Get Nasdaq-100 details
nasdaq_details = get_nasdaq100(
    return_type='dict', 
    fields=['name', 'industry']
)

# Example: Accessing Apple Inc. metadata (present in both)
print(nasdaq_details['AAPL'])
# Output: {'name': 'Apple Inc.', 'industry': 'Technology'}

# Get a list of dictionaries with custom fields
data = get_sp500(return_type='list', fields=['name', 'sector', 'cik'])

API Documentation

get_sp500(return_type='list', fields=None)

The entry point for fetching the S&P 500 index components.

  • return_type (str): 'list' (default) or 'dict'.
  • fields (list, optional): Defaults to ['symbol'].
    • Supported fields: symbol, name, sector, sub_industry, date_added, cik, founded.

get_nasdaq100(return_type='list', fields=None)

The entry point for fetching the Nasdaq-100 index components.

  • return_type (str): 'list' (default) or 'dict'.
  • fields (list, optional): Defaults to ['symbol'].
    • Supported fields: symbol, name, industry, subsector.

get_sp100(return_type='list', fields=None)

The entry point for fetching the S&P 100 index components.

  • return_type (str): 'list' (default) or 'dict'.
  • fields (list, optional): Defaults to ['symbol'].
    • Supported fields: symbol, name, sector.

get_ipsa(return_type='list', fields=None)

The entry point for fetching the S&P/CLX IPSA index components (Chilean main stocks).

  • return_type (str): 'list' (default) or 'dict'.
  • fields (list, optional): Defaults to ['symbol'].
    • Supported fields: symbol, name.

Development and Contributions

We welcome contributions from the community! Whether it's adding new indexes, new features or improving the scraper's robustness, feel free to submit a Pull Request.

Local Setup

  1. Clone the repository:
    git clone https://github.com/fzunigam/indexes.git
    cd indexes
    
  2. Install in editable mode:
    pip install -e .
    

Running Tests

Ensure stability by running the test suite:

pytest

Disclaimer

This project was built with the help of AI coding tools.

License

indexes is licensed under the MIT License. See the LICENSE file for more information.

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

indexes-0.1.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

indexes-0.1.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file indexes-0.1.4.tar.gz.

File metadata

  • Download URL: indexes-0.1.4.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for indexes-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1a3286057c85809e4f0e75f68c3868f7d000c1791c333c70ffa98f0d32d7154f
MD5 9546b389b554cc544eada1ec3629244d
BLAKE2b-256 3f811e18adda87695d3502190410e5eef14e4d44b57aed0fd274ac916933c7ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for indexes-0.1.4.tar.gz:

Publisher: publish.yml on fzunigam/indexes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file indexes-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: indexes-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for indexes-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c869aecc52c5b2fd168d9413906fec44574e9f62da84e3012f11ac40d35915fb
MD5 d9b1defbdb06aee9647da8274269e21f
BLAKE2b-256 580e7645a5bedeba4fb188e553128b0b280a671d7248f2b6a28b9d6877a161a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for indexes-0.1.4-py3-none-any.whl:

Publisher: publish.yml on fzunigam/indexes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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