Skip to main content

Financial infrastructure toolkit: banking connections, market data, credit, cashflows, and brokerage integrations

Project description

fin-infra

PyPI Docs

Financial infrastructure toolkit for fintech applications. fin-infra provides production-ready building blocks for banking connections, market data, credit scores, tax data, brokerage integrations, and cashflow analysis—everything needed to build comprehensive personal finance management applications.

What is fin-infra?

fin-infra is the financial data layer for fintech apps. While svc-infra handles generic backend operations (auth, API scaffolding, database, billing), fin-infra is purpose-built for financial applications where users need to:

  • Connect bank accounts and pull transaction history
  • Link brokerage accounts and view portfolio holdings
  • Check credit scores and monitor credit reports
  • Access tax documents and data
  • View real-time market data (stocks, crypto, forex)
  • Perform financial calculations (NPV, IRR, loan amortization)

Status

Alpha. Core functionality is stable, but the surface is intentionally small while we stabilize models and provider contracts.

Helper Index

Area What it covers Guide
Getting Started Overview and installation Getting Started
API Integration Building fintech APIs with fin-infra + svc-infra API Guide
Banking Account aggregation, transactions, statements Banking
Market Data Stocks, crypto, forex quotes and historical data Market Data
Credit Scores Credit reports and monitoring Credit
Brokerage Trading accounts and portfolio data Brokerage
Tax Data Tax documents and data management Tax
Cashflows NPV, IRR, loan calculations Cashflows
Observability Metrics and route classification for financial endpoints Observability
Compliance PII boundaries, vendor ToS, GLBA/FCRA/PCI-DSS, data lifecycle Compliance
Contributing Dev setup and quality gates Contributing
Acceptance Acceptance testing guide Acceptance

Quick Start

Installation

# From PyPI (when published)
pip install fin-infra

# For backend infrastructure (auth, API, DB, cache, jobs), also install:
pip install svc-infra

# For development
git clone https://github.com/your-org/fin-infra
cd fin-infra
poetry install

Note: fin-infra provides ONLY financial data integrations. For backend infrastructure (API framework, auth, database, caching, jobs), you need svc-infra. Applications typically use both packages together.

One-Call Setup

from fin_infra.banking import easy_banking
from fin_infra.markets import easy_market, easy_crypto
from fin_infra.credit import easy_credit
from fin_infra.cashflows import npv, irr

# Banking
banking = easy_banking()
accounts = await banking.get_accounts("access_token")
transactions = await banking.get_transactions("account_id")

# Market Data
market = easy_market()
quote = market.quote("AAPL")

crypto = easy_crypto()
ticker = crypto.ticker("BTC/USDT")

# Credit Scores
credit = easy_credit()
score = await credit.get_credit_score("user_123")

# Cashflows
cashflows = [-1000, 300, 300, 300, 300]
net_value = npv(0.08, cashflows)
rate_of_return = irr(cashflows)

With FastAPI (fin-infra + svc-infra)

from fastapi import FastAPI
from svc_infra.obs import add_observability
from fin_infra.obs import financial_route_classifier
from fin_infra.banking import add_banking
from fin_infra.markets import add_market_data

# Create app with backend framework (svc-infra)
app = FastAPI(title="Fintech API")

# Add financial capabilities (fin-infra)
add_banking(app, provider="plaid")
add_market_data(app, provider="alphavantage")

# Option 1: Basic observability (all routes auto-instrumented)
add_observability(app)

# Option 2: With route classification (recommended for production)
# All routes auto-instrumented + categorized for filtering in Grafana
add_observability(app, route_classifier=financial_route_classifier)

What gets instrumented?

Both options automatically instrument ALL routes in your app:

  • ✅ Financial routes: /banking/*, /market/*, /crypto/*
  • ✅ Non-financial routes: /health, /docs, /admin/*

The difference: Route classification adds category labels (|financial, |public) for filtering metrics in Grafana.

Without classifier:

# Metrics: route="/banking/accounts"
http_server_requests_total{route="/banking/accounts", method="GET"} 42

With classifier:

# Metrics: route="/banking/accounts|financial" (can filter by |financial)
http_server_requests_total{route="/banking/accounts|financial", method="GET"} 42

# Filter all financial routes in Grafana:
sum(rate(http_server_requests_total{route=~".*\\|financial"}[5m]))

See Observability Guide for more details.

Architecture Overview

fin-infra/
├── src/fin_infra/
│   ├── banking/            # Bank account aggregation
│   │   ├── plaid/          # Plaid provider
│   │   └── teller/         # Teller provider
│   ├── brokerage/          # Trading account connections
│   ├── credit/             # Credit score providers
│   ├── markets/            # Market data (stocks/crypto)
│   ├── tax/                # Tax data and documents
│   ├── cashflows/          # Financial calculations
│   ├── obs/                # Observability (route classification)
│   ├── models/             # Pydantic data models
│   ├── providers/          # Provider implementations
│   └── docs/               # Packaged documentation
├── tests/
│   ├── unit/               # Fast unit tests
│   └── acceptance/         # Provider integration tests
└── examples/               # Example applications

Configuration

fin-infra uses environment variables for provider credentials:

# Banking providers
PLAID_CLIENT_ID=your_client_id
PLAID_SECRET=your_secret
PLAID_ENV=sandbox

# Market data providers
ALPHAVANTAGE_API_KEY=your_api_key

# Credit providers (v2: OAuth 2.0)
EXPERIAN_CLIENT_ID=your_client_id
EXPERIAN_CLIENT_SECRET=your_client_secret
EXPERIAN_BASE_URL=https://sandbox-us-api.experian.com  # or production URL

Development

# Install dependencies
poetry install

# Format code
make format

# Run linting
make lint

# Type check
make type

# Run tests
make unit      # Unit tests only
make accept    # Acceptance tests
make test      # All tests

Acceptance Tests and CI

Acceptance tests are marked with @pytest.mark.acceptance and are excluded by default.

Running locally

Export any required API keys (only Alpha Vantage is needed by default):

  • ALPHAVANTAGE_API_KEY – required for Alpha Vantage market data tests

Run acceptance tests:

poetry run pytest -q -m acceptance

GitHub Actions Secrets

The acceptance workflow in .github/workflows/acceptance.yml expects:

  • ALPHAVANTAGE_API_KEY – add it under Repository Settings → Secrets and variables → Actions → New repository secret

If the secret isn't configured, acceptance tests will still run and CoinGecko tests (public) will pass, but Alpha Vantage tests will be skipped.

Contributing

  • Keep APIs small and typed. Prefer Pydantic models for IO boundaries.
  • Add or update tests for any behavior changes. Keep pytest passing and mypy clean.
  • See Contributing Guide for detailed development workflow.

License

MIT

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

fin_infra-0.1.15.tar.gz (440.7 kB view details)

Uploaded Source

Built Distribution

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

fin_infra-0.1.15-py3-none-any.whl (535.0 kB view details)

Uploaded Python 3

File details

Details for the file fin_infra-0.1.15.tar.gz.

File metadata

  • Download URL: fin_infra-0.1.15.tar.gz
  • Upload date:
  • Size: 440.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fin_infra-0.1.15.tar.gz
Algorithm Hash digest
SHA256 cb049f1aa5e9a7f69bc6a09568dd31b3d6a108a694e9d75ba832fad806bd217e
MD5 6289eb4f53e4abf4b53bd2ebfdd2f1b9
BLAKE2b-256 8f5c9e1c94fa0799b9964833000010679abc9a7c0cc5f23c661182f9b32b7130

See more details on using hashes here.

Provenance

The following attestation bundles were made for fin_infra-0.1.15.tar.gz:

Publisher: publish-pypi.yml on Aliikhatami94/fin-infra

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

File details

Details for the file fin_infra-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: fin_infra-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 535.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fin_infra-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 631055584df9e57cf2e05c01117ae3a1596a8fa912ce698addd9125391a33411
MD5 99ac6355fd15254887633373f8f51ebc
BLAKE2b-256 0ac25ab085a46daecb93da3513ed6a7b6e955adeae4a998783843b8459a61047

See more details on using hashes here.

Provenance

The following attestation bundles were made for fin_infra-0.1.15-py3-none-any.whl:

Publisher: publish-pypi.yml on Aliikhatami94/fin-infra

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