Pydantic-compatible financial data types and validators
Project description
finschema
Financial validation types, schemas, quality engine, and ecosystem integrations for Python.
Project Status
Current release line: v0.6.0 Integrations Rollup
Install
pip install finschema
Optional extras:
pip install "finschema[pandas]"
pip install "finschema[polars]"
pip install "finschema[fastapi]"
pip install "finschema[yaml]"
Feature Matrix
| Area | Status | Highlights |
|---|---|---|
| Core Types | ✅ | ISIN/CUSIP/SEDOL/LEI/IBAN/BIC + FIGI/VALOR/WKN/RIC/Ticker, Country/Currency, Money/Price/Quantity/Percentage |
| Schemas | ✅ | Trade, Position, Portfolio + extended v0.5 schema set |
| Quality Engine | ✅ | Built-in rule packs, custom rules, strict/soft mode, TOML/YAML/pyproject config |
| Pandas | ✅ | .validate(), .is_valid(), .clean(), .coerce(), Series.validate_rows(), read_csv() helper |
| Polars | ✅ | DataFrame/Series/LazyFrame parity + expression validators (expr.is_valid_isin) |
| FastAPI | ✅ | Middleware auto-validation, quality headers, structured 422s, dependency helper |
| CLI | ✅ | check, validate (csv/json/jsonl/parquet), diff, --watch, HTML/JSON report outputs |
| HTML Reports | ✅ | Standalone single-file report, filter/sort, score gauge, invalid-row CSV export |
Quick Start
from finschema.types import ISIN, Money, CountryCode, CurrencyCode
from finschema.quality import ValidationEngine
isin = ISIN("US0378331005")
money = Money("1000.50", "EUR")
country = CountryCode("DEU")
currency = CurrencyCode("JPY")
report = ValidationEngine().validate(
[{"trade_id": "T-1", "isin": "US0378331005", "side": "BUY", "quantity": 10, "price": 10.5, "currency": "USD", "trade_date": "2026-03-19", "settlement_date": "2026-03-20"}],
schema="Trade",
)
print(isin, money, country.alpha2, currency.decimals, report.score)
CLI
finschema check isin US0378331005
finschema check isin --batch identifiers.txt
finschema validate trades.csv --schema Trade --output report.html
finschema validate trades.json --schema Trade --config finschema.toml --watch
finschema diff trades_day1.csv trades_day2.csv --schema Trade --output-json diff.json
Integrations
# Pandas
import pandas as pd
import finschema.integrations.pandas # registers .finschema
df = pd.read_csv("trades.csv")
clean_df, report = df.finschema.clean("Trade")
# Polars
import polars as pl
import finschema.integrations.polars # registers .finschema
from finschema.integrations.polars import expr
pf = pl.read_csv("trades.csv")
pf = pf.filter(expr.is_valid_isin("isin"))
# FastAPI
from fastapi import FastAPI
from finschema.integrations.fastapi import FinschemaMiddleware
from finschema.schemas import Trade
app = FastAPI()
app.add_middleware(FinschemaMiddleware, strict=True)
@app.post("/trades")
async def create_trade(trade: Trade) -> dict[str, str]:
return {"trade_id": trade.trade_id}
Development
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
ruff check .
ruff format --check .
mypy
pytest
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 finschema-0.6.0.tar.gz.
File metadata
- Download URL: finschema-0.6.0.tar.gz
- Upload date:
- Size: 69.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801e917aee65d8ac5d09f9186f8e90959a376b755e28103a5c0736c223c23e14
|
|
| MD5 |
2fed080f6573086276bf3af31d8461fb
|
|
| BLAKE2b-256 |
ef42bfc1a4369ac6505735103ef6d50b0bc963805177547e30e33353a8e05304
|
Provenance
The following attestation bundles were made for finschema-0.6.0.tar.gz:
Publisher:
publish.yml on tkrenn12306/finschema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finschema-0.6.0.tar.gz -
Subject digest:
801e917aee65d8ac5d09f9186f8e90959a376b755e28103a5c0736c223c23e14 - Sigstore transparency entry: 1139355137
- Sigstore integration time:
-
Permalink:
tkrenn12306/finschema@f577548d6f641727cf6aaf72f8cd76cb1fe12475 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/tkrenn12306
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f577548d6f641727cf6aaf72f8cd76cb1fe12475 -
Trigger Event:
push
-
Statement type:
File details
Details for the file finschema-0.6.0-py3-none-any.whl.
File metadata
- Download URL: finschema-0.6.0-py3-none-any.whl
- Upload date:
- Size: 69.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c4b22de84b39ea10218d5e1df5b646501d9b080e33bc25a27e4c11a3989f02
|
|
| MD5 |
812750539de025f539a36e88bfbbe2a6
|
|
| BLAKE2b-256 |
a1b01e3efffbeb32004b22c6ae281ffc6bcfda990fec04092ca62797ebeed6ec
|
Provenance
The following attestation bundles were made for finschema-0.6.0-py3-none-any.whl:
Publisher:
publish.yml on tkrenn12306/finschema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finschema-0.6.0-py3-none-any.whl -
Subject digest:
e3c4b22de84b39ea10218d5e1df5b646501d9b080e33bc25a27e4c11a3989f02 - Sigstore transparency entry: 1139355196
- Sigstore integration time:
-
Permalink:
tkrenn12306/finschema@f577548d6f641727cf6aaf72f8cd76cb1fe12475 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/tkrenn12306
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f577548d6f641727cf6aaf72f8cd76cb1fe12475 -
Trigger Event:
push
-
Statement type: