Skip to main content

Pydantic-compatible financial data types and validators

Project description

finschema

CI PyPI Coverage Python License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finschema-0.6.0.tar.gz (69.2 kB view details)

Uploaded Source

Built Distribution

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

finschema-0.6.0-py3-none-any.whl (69.9 kB view details)

Uploaded Python 3

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

Hashes for finschema-0.6.0.tar.gz
Algorithm Hash digest
SHA256 801e917aee65d8ac5d09f9186f8e90959a376b755e28103a5c0736c223c23e14
MD5 2fed080f6573086276bf3af31d8461fb
BLAKE2b-256 ef42bfc1a4369ac6505735103ef6d50b0bc963805177547e30e33353a8e05304

See more details on using hashes here.

Provenance

The following attestation bundles were made for finschema-0.6.0.tar.gz:

Publisher: publish.yml on tkrenn12306/finschema

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

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

Hashes for finschema-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3c4b22de84b39ea10218d5e1df5b646501d9b080e33bc25a27e4c11a3989f02
MD5 812750539de025f539a36e88bfbbe2a6
BLAKE2b-256 a1b01e3efffbeb32004b22c6ae281ffc6bcfda990fec04092ca62797ebeed6ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for finschema-0.6.0-py3-none-any.whl:

Publisher: publish.yml on tkrenn12306/finschema

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