Python package for Swiss financial data
Project description
swiss-finance-data
Python package for Swiss financial data — starting with SNB (Swiss National Bank)
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 failsProviderNotFoundError— 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 dateYYYY-MMend(str, optional): End dateYYYY-MMprovider(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
- GitHub: @EMen11
- LinkedIn: Elie Menassa
- Email: menassa.elie.dev@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swiss_finance_data-0.1.0.tar.gz.
File metadata
- Download URL: swiss_finance_data-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19940da7e798549b8351f2f41a6bc71940740b538c5249228917de09c83d5161
|
|
| MD5 |
54f82f52702db4fb7ec5127d2e3053a7
|
|
| BLAKE2b-256 |
7c3254d780ad579d10820550b7261b5dbc662b8c740e11becce50228ac41cdc8
|
File details
Details for the file swiss_finance_data-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swiss_finance_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a5c35ab47dcfe41f83cb8a595955bc4f9835ae1f3957aebde70ce4e415234b7
|
|
| MD5 |
0c39ecdbf631d1b0b6628650eee6806a
|
|
| BLAKE2b-256 |
f4dee3aa38b81c758da8dc8375f3999df3550511ad942e3538ec58621a47cc5d
|