Skip to main content

finance flow

Standard financial flow models

Build Status codecov License PyPI

Overview

finance-flow provides reusable finance-specific callable models, schemas, and transformations. It owns provider-neutral research and portfolio workflow logic: normalize market data, validate finance structures, build universes, calculate signals, produce target positions, backtest, and generate reports.

It does not own extraction credentials, provider clients, storage destinations, or application orchestration. Those concerns belong in finance-etl, connector packages, or downstream applications.

Quick Start

Normalize provider-shaped daily aggregate rows into typed daily bars:

from finance_flow import normalize_massive_daily_bars

bars = normalize_massive_daily_bars(
    {
        "results": [
            {"T": "AAPL", "o": 184.22, "h": 185.88, "l": 183.43, "c": 184.95, "v": 58414500}
        ]
    },
    ticker="AAPL",
    session_date="2024-01-03",
)

Use the callable wrapper when composing the transform inside a ccflow graph:

from finance_flow import MassiveDailyBarsNormalizeContext, MassiveDailyBarsNormalizeModel

result = MassiveDailyBarsNormalizeModel()(
    MassiveDailyBarsNormalizeContext(
        payload=[{"ticker": "AAPL", "open": 1, "high": 2, "low": 1, "close": 2, "volume": 100}],
        ticker="AAPL",
        session_date="2024-01-03",
    )
)

Publish normalized daily bars as parquet artifacts:

from finance_flow import MassiveDailyBarsArtifactContext, MassiveDailyBarsArtifactModel

result = MassiveDailyBarsArtifactModel(input_store=store, output=store)(
    MassiveDailyBarsArtifactContext(ticker="AAPL", date="2024-01-03")
)

The artifact task reads massive/stocks/rest/daily-aggs/json/{date}/{ticker}.json and writes massive/stocks/bars/daily/parquet/{date}/{ticker}.parquet.

Build market-wide daily bars from Massive day-aggregate flat files with MassiveDailyBarsFlatFileModel. It materializes massive/stocks/s3/day-aggs/{year}/{month}/{date}.csv.gz to a local workspace, streams it through MassiveDailyBarsFlatFileTransformModel into one validated Parquet file per session, and writes that file through a local writer and an optional backup writer under massive/stocks/curated/bars/daily/v1/{year}/{month}/{date}.parquet.

Each session also gets a {date}.metadata.json sidecar, written through the same writers. It records:

  • the source object's key, URI, size, and, when the store reports them, ETag, version ID, and last-modified time;
  • transform provenance: for a partition transformed in the same run, recorded with the transform class, a SHA-256 fingerprint of its configuration, and the finance-flow and pyarrow versions; for a partition that already existed, backfilled with those fields left null, since what produced it is unknown;
  • the output key, size, SHA-256, and row count;
  • quality counters recomputed from the written Parquet: row and ticker counts, duplicate tickers, null required values, negative volume or transactions, OHLC violations, and zero-volume and zero-transaction rows.

When a partition already exists but its sidecar does not, the model writes only the sidecar, so older sessions can be backfilled without re-transforming. Set overwrite_sidecar=true to regenerate sidecars without rewriting partitions. If the workspace copy had to be rebuilt while the published partition already exists, the model skips the sidecar rather than describe bytes that were never published.

Documentation

Dependency Contract

  • Depends on ccflow for callable model integration and may depend on dataframe and validation libraries needed for finance transformations.
  • May be consumed by finance-etl and application-specific packages.
  • Must not depend on connector packages unless a transformation genuinely needs optional I/O support, and must not depend on application-specific packages.

Test Convention

Default tests should use small synthetic finance datasets and run without external services or provider credentials.

Metadata

Release files for finance-flow 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for finance-flow 0.2.0
File Size Uploaded Provenance Actions
finance_flow-0.2.0.tar.gz 56.3 kB Without provenance Details for finance_flow-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for finance-flow 0.2.0
File Interpreter ABI Platform Actions
finance_flow-0.2.0-py3-none-any.whl Python 3 none any Details for finance_flow-0.2.0-py3-none-any.whl

Total release size: 125.7 kB

Release files / finance_flow-0.2.0.tar.gz

Download URL finance_flow-0.2.0.tar.gz
Size 56.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e14c054ac27812db014fdc139c0b436631bf552b8cf4a4e4655d775e028c6dc3
BLAKE2b-256 checksum
How to use checksums
7ed57efb6d5f9e4469f8f0a47a2d6f67f85419ae27e1a81c643d371e315c9165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / finance_flow-0.2.0-py3-none-any.whl

Download URL finance_flow-0.2.0-py3-none-any.whl
Size 69.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ad1ecfdb64b0654617e60aba06697e35d9ee9aa69eb77c44aa5fc1d6bbbc248
BLAKE2b-256 checksum
How to use checksums
4e5c0e5281c257adb512cb9ad03f594652a68c12a8743f1a64a3e00df52c3dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for finance-flow 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page