Skip to main content

financial-agent

Python quality PyPI Python 3.12 Docs License: MIT

A Python platform for systematic ETF trading that has to earn its way to capital: cost-aware backtests, a statistical promotion gate, journaled paper trading and explicitly gated Alpaca and IBKR execution. It also holds an equity-research harness and separate RL/deep-learning research stacks. The platform is beta: live performance is unproven, and neither a historical pass nor paper results guarantee profit.

Docs: https://bichengwang.github.io/financial-agent/ has the quant guides, evidence reports, equity research and changelog.

Status (2026-10-28)

Stage State
Research gate trend_vol_target passes all eight checks with its frozen identity target_vol=0.12, max_weight=0.25 (data through 2026-10-27, DSR 0.994)
Paper evidence Alpaca paper sessions scheduled weekdays before the open: first session 2026-10-29, first orders 2026-11-02; 0 of 20 clean sessions
Live Not authorized. Earliest decision 2026-11-25, if no paper session halts

The paper-to-live plan tracks the remaining steps and decisions.

Quickstart (offline, five minutes)

pip install fa-quant
fa-quant demo --sessions 25 --state-dir /tmp/fa-quant-demo

Or from a clone, with uv (Python 3.12 is pinned by .python-version):

uv sync --locked
uv run fa-quant demo
uv run fa-quant --help

The demo runs backtest, validation, certification, local paper sessions and status on seeded synthetic data with a planted trend, without network access. Its numbers show the software working, not market performance.

The PyPI distribution is fa-quant; it installs the fa-quant command and the financial_agent import package. The unrelated financial-agent PyPI project is not this one. Python 3.12 is tested; on 3.13+ the NumPy <2 pin builds NumPy from source. Examples, docs and evidence live in this repository. Optional rl, dl, notebooks and research extras add the heavier research stacks; uv sync --locked --all-extras installs everything.

Real-data research

The example universe is SPY, QQQ, IWM, EFA, EEM, TLT, IEF, LQD, GLD, DBC and VNQ with weekly next-open fills, whole shares, a 2% cash buffer and 2 bps half-spread plus 3 bps slippage per side. Downloads are cached under gitignored var/. Use the latest completed session as the inclusive end:

uv run fa-quant backtest --config examples/quant/paper.toml --end 2026-10-27 --json
uv run fa-quant validate --config examples/quant/paper.toml --end 2026-10-27 --json
uv run fa-quant certify --config examples/quant/paper.toml --end 2026-10-27 \
  --output var/quant-paper/certificate.json

validate and certify exit 2 when any check fails; a failed certificate can be saved but never authorizes trading. With --config, all settings come from the TOML. See strategy research for grids, disclosed trials and how to read each statistic.

Results

The committed evidence covers 2006-02-06 through 2026-10-12. Full-period backtests at default parameters:

Strategy CAGR Net Sharpe Max drawdown Turnover/year
Trend vol target 5.625% 0.740 16.533% 14.375×
Dual momentum 11.100% 0.754 26.397% 10.550×
SPY buy-and-hold 11.122% 0.652 54.299% 0.048×
60/40 SPY/IEF 8.212% 0.785 31.979% 0.206×

The trend strategy's promotion gate (walk-forward out-of-sample, 3,528 sessions):

Protocol Data OOS Sharpe DSR OOS max drawdown PBO Verdict
Four-variant search 2006-02-06 to 2026-10-12 0.729 0.996 17.1% 0.650 Pass; selects 0.12 / 0.25
Frozen 0.12 / 0.25, four trials disclosed 2006-03-01 to 2026-10-27 0.704 0.994 13.7% n/a Pass

PBO 0.650 means picking the in-sample winner added no reliable value, and the choice switched 6 times in 13 folds. So the selected identity is now frozen: re-certification can no longer switch parameters and restart the paper clock. DSR still deflates by all four variants tried. The frozen row's walk-forward returns aren't out-of-sample for the choice of identity, which used the same history; the freeze stabilizes the identity, it doesn't strengthen the statistical case.

Dual momentum and 60/40 also pass all eight checks as single pre-registered variants; SPY fails the 25% OOS drawdown limit. Statistical passes don't override execution limits: dual momentum's three 33.3% slots and the concentrated benchmarks exceed the 30% per-name cap. The equity research_forecast signal fails its real-ledger gate for lack of history. No parameter or threshold was tuned to pass.

Paper trading

Put Alpaca paper keys in the environment as APCA_API_KEY_ID and APCA_API_SECRET_KEY, never in TOML, git or shell history. Preview, run and inspect before the opening auction (orders must go out before 09:25 New York time):

uv run fa-quant run --config examples/quant/paper.toml --dry-run
uv run fa-quant run --config examples/quant/paper.toml
uv run fa-quant status --config examples/quant/paper.toml

For unattended runs, schedule deploy/quant/run-session.py with the launchd, cron or systemd templates beside it. It loads keys from a chmod 600 env file, passes the exit code through and posts a sanitized alert to FA_QUANT_ALERT_WEBHOOK when a session halts. status reports live readiness: clean sessions, halts, slippage against the allowance and certificate age. See the daily schedule.

IBKR uses the locally running Client Portal Gateway with a daily browser login. Copy ibkr-paper.toml, set your USD paper account ID and gateway port, and follow the gateway setup. TLS verification can be disabled only on loopback, and order questions halt unless their message IDs are explicitly allowed.

Live gate

Every live session re-checks all of these:

  • mode = "live" in a separate TOML and FA_QUANT_ALLOW_LIVE=1 in the environment.
  • A passing certificate at most 90 days old for exactly the configured strategy and parameters.
  • At least 20 distinct clean paper sessions with the same broker and identity, with fills, no halts or reconciliation breaks in that window, and mean slippage within twice the modeled cost.

Configs can tighten runtime risk limits, never loosen them. The MCP server exposes research and paper previews only and can't place orders. The kill switch persists and blocks new submissions, but doesn't cancel orders or liquidate. Read safety and go-live steps before changing mode and operations for kill/unkill and incidents.

Equity research and RL

The native ticker workflow combines sourced evidence, Decimal arithmetic, optional earnings/DCF/comps models and structural audits; retained research remains provisional. The daily equity workflow produces dated source/prediction packages. The harness provides deterministic report checks and ledger audits:

uv run python -m financial_agent.harness --help
uv run python -m financial_agent.harness audit --output-dir agents/equity/output

Generic RL supplies tabular Q-learning, GridWorld, Gymnasium wrappers and bounded training loops; examples show the APIs and notebooks keep historical outputs. The FinRL-derived trading/ and TensorFlow dl/ stacks are experimental: nothing reaches capital unless it implements Strategy and passes the same gates. The historical autotrain entrypoint is not turnkey.

Repository map

Path Purpose
src/financial_agent/quant Data, strategies, backtest, validation, risk, execution, runner and CLI/MCP
docs/quant Architecture, safety, operations, strategy guide
examples/quant / deploy/quant Paper configs, scheduler wrapper and launchd/cron/systemd templates
reports/quant Dated strategy and research-forecast evidence
tests/quant Deterministic offline regression tests
plan Dated design plans and the paper-to-live roadmap
src/financial_agent/harness Equity schemas, gates, kernels and policy
agents/equity / skills Daily/native equity workflows and agent skills, including quant research and paper operations
src/financial_agent/rl / example/rl Generic RL APIs and examples
src/financial_agent/trading / src/financial_agent/dl Experimental financial RL and prediction research
notebooks Saved research outputs; avoid incidental reruns

Limitations

  • Yahoo's adjusted OHLCV is revised retrospectively and isn't raw auction data; paper slippage is measured against those adjusted opens.
  • The fixed ETF universe carries selection bias. Simulations omit taxes, cash interest, capacity, market impact and exact corporate-action accounting.
  • Statistics describe this historical sample, not future profitability.
  • The scheduled runner doesn't monitor intraday loss or guarantee fills; reference-price limits don't remove gap risk.
  • State and journal hashes are integrity checks, not signatures. The runner targets macOS and Linux.

Contributing and security

See CONTRIBUTING.md for setup, checks and pull request rules, and the code of conduct. Report vulnerabilities privately as described in SECURITY.md.

License

MIT. Software is provided as is, without warranty.

Metadata

Release files for fa-quant 1.3.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 fa-quant 1.3.0
File Size Uploaded Provenance Actions
fa_quant-1.3.0.tar.gz 180.2 kB With provenance Details for fa_quant-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fa-quant 1.3.0
File Interpreter ABI Platform Actions
fa_quant-1.3.0-py3-none-any.whl Python 3 none any Details for fa_quant-1.3.0-py3-none-any.whl

Total release size: 396.7 kB

Release files / fa_quant-1.3.0.tar.gz

Download URL fa_quant-1.3.0.tar.gz
Size 180.2 kB
Tags Source
SHA-256 checksum
How to use checksums
546514ba9eaabd0b0f1c52d5a0801e6f5b581ffb8e91163cbf85e8665d5b4ef6
BLAKE2b-256 checksum
How to use checksums
794e5d46763a0eb855b6730926b2bdf67c9c7fb91c02447e99cf08ac02c892c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / fa_quant-1.3.0-py3-none-any.whl

Download URL fa_quant-1.3.0-py3-none-any.whl
Size 216.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db5423716521a41ad10c97ac360fd518b3dbf188cc9aa4b9f6d998a7ad90bfba
BLAKE2b-256 checksum
How to use checksums
f03ddbf2cf84971cd18f141090242daa5d8b3aa4780593fa4a575ba335f26248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for fa-quant 1.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fa_quant-1.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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

1.3.0 This release

2 release files Full 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