Skip to main content

Python package for Swiss financial data

Project description

swiss-finance-data

Python package for Swiss financial data — starting with SNB (Swiss National Bank)

PyPI version Tests Coverage License Python Downloads


Why swiss-finance-data?

Accessing Swiss financial data in Python is fragmented. Existing tools focus on US/global markets and provide limited support for Swiss-specific datasets.

swiss-finance-data aims to provide:

  • A unified, clean API for Swiss financial data
  • Official government data sources — no scraping
  • Extensible provider architecture
  • Long-term maintainability

Scope

swiss-finance-data focuses on:

  • Official and legally reusable data sources
  • Clean abstraction over data providers
  • Stability and long-term maintainability
  • Swiss-specific financial datasets

It does not aim to replace global data providers such as yfinance, but to complement them for Swiss markets.


Features

v0.1.0 — Available now:

  • SNB Policy Rate — Current and historical Swiss National Bank policy rates
  • Provider Architecture — Extensible system for multiple data sources
  • Tested & documented — 89% unit test coverage
  • Reliable — Official Swiss government data sources, no scraping

Coming in future versions:

  • SMI equities (v0.2.0)
  • Caching layer (v0.2.0)
  • Swiss government bonds (v0.3.0)
  • Real estate indices SWIIT (v0.4.0)

Installation

pip install swiss-finance-data

Requirements: Python 3.10+

Requires internet access — data is fetched live from the official SNB API.


Quick Start

Get current SNB policy rate

from swiss_finance import SNB

rate = SNB.get_policy_rate()
print(f"SNB Policy Rate: {rate}%")
# Output: SNB Policy Rate: 0.0%

Get historical rates

from swiss_finance import SNB

rates = SNB.get_historical_rates(start='2020-01')
print(rates.tail())
#                 rate
# date
# 2025-09-01      0.0
# 2025-10-01      0.0
# 2025-11-01      0.0
# 2025-12-01      0.0
# 2026-01-01      0.0

Error handling

from swiss_finance import SNB, SNBAPIError

try:
    rate = SNB.get_policy_rate()
except SNBAPIError as e:
    print(f"Failed to fetch data: {e}")

API Documentation

SNB.get_policy_rate(provider='snb_official')

Get the current SNB policy rate.

Parameters:

  • provider (str, optional): Data provider to use. Default: 'snb_official'

Returns: float — Current policy rate (percentage)

Raises:

  • SNBAPIError — If API call fails
  • ProviderNotFoundError — If provider doesn't exist

Example:

rate = SNB.get_policy_rate()

SNB.get_historical_rates(start=None, end=None, provider='snb_official')

Get historical SNB policy rates.

Parameters:

  • start (str, optional): Start date YYYY-MM
  • end (str, optional): End date YYYY-MM
  • provider (str, optional): Data provider to use. Default: 'snb_official'

Returns: pandas.DataFrame — Date index + rate column

Raises:

  • SNBAPIError — If API call fails

Example:

# Full history
rates = SNB.get_historical_rates()

# Specific range
rates = SNB.get_historical_rates(start='2020-01', end='2024-12')

SNB.list_providers()

List available data providers.

Returns: list

Example:

SNB.list_providers()
# ['snb_official']

Data Sources

All data sources are documented in docs/DATA_SOURCES.md.

Source Data License
Swiss National Bank Policy rates (current + historical) SNB Open Data terms

Development

Setup

git clone https://github.com/EMen11/swiss-finance-data.git
cd swiss-finance-data
pip install -e .[dev]

Run tests

pytest --cov=swiss_finance tests/

API Stability

  • v0.x — API may evolve based on feedback
  • v1.0+ — Stable public API with backward compatibility guaranteed
  • Versioning follows Semantic Versioning (SemVer).

Roadmap

  • v0.1.0 — SNB policy rates
  • v0.2.0 — SMI equities + caching
  • v0.3.0 — Swiss government bonds
  • v0.4.0 — Real estate indices (SWIIT)
  • v1.0.0 — Stable API, full documentation

License

MIT License — see LICENSE for details.


Author

Elie Menassa

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

swiss_finance_data-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

swiss_finance_data-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for swiss_finance_data-0.1.1.tar.gz
Algorithm Hash digest
SHA256 96fbfda2b3e8f33070ecf620953ca8d20681f85ce2175a65de139c0189562d4e
MD5 34f14802fd2c41d9eb56244b6f73f2c6
BLAKE2b-256 5f7ec4f2bef13a7aff92c4ba5e518a9a3b2d0ff9c03027f9fda109dcb5eb6f34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for swiss_finance_data-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e10c9dfbae735e5121703c11cf151e0f0c29723be51a3805698571000523e1aa
MD5 9e0944c8b14a5ced4e73982459e84e0a
BLAKE2b-256 480ee9ef479f9cada390e7b9300cf5cc8affa9f72663bd331c3987a1dda4bd74

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