Skip to main content

ClearFills Pre-Trade Risk Firewall (clearfills-firewall)

License Python 3.11+ Website

Deterministic Ed25519 pre-trade risk firewall & MCP server for AI trading agents.

Sits between any untrusted AI trading agent (Claude, Grok, Codex, TradingAgents, ai-hedge-fund, or custom Python loops) and your execution gateway so LLMs never hold brokerage API keys and can never hallucinate or get prompt-injected into an unbounded market sweep.


Install

pip install clearfills-firewall

Run the MCP stdio server:

clearfills-firewall-mcp
# or: uvx --from clearfills-firewall clearfills-firewall-mcp

Run the FastAPI HTTP firewall service:

clearfills-firewall

Connect to Claude Code & Cursor

Claude Code

claude mcp add clearfills -- uvx --from clearfills-firewall clearfills-firewall-mcp

Cursor (.cursor/mcp.json) / Project .mcp.json

{
  "mcpServers": {
    "clearfills": {
      "command": "uvx",
      "args": ["--from", "clearfills-firewall", "clearfills-firewall-mcp"]
    }
  }
}

Deterministic Policy Invariants (Zero LLM in the Loop)

Every TradeProposal must satisfy all deterministic math rules before an Ed25519 attestation is signed:

Rejection Code Invariant Enforced
MARKET_ORDER_FORBIDDEN Strict LMT (limit) orders only — MKT sweeps are unconditionally vetoed
MISSING_HARD_STOP Atomic bracket stop-loss required (or bounded binary collateral on Polymarket/Kalshi)
MAX_TRADE_RISK_EXCEEDED <= 1.5% NLV per equity trade / <= 1.0% fractional Kelly cap on binary markets
MAX_POSITION_NOTIONAL_EXCEEDED <= 20% gross NLV concentration cap
DAILY_DRAWDOWN_KILLSWITCH Fail-closed intraday halt at -3.0% PnL
NONCE_ALREADY_SPENT Single-use 120-second Ed25519 attestation nonce; replays rejected and logged

Every APPROVED, VETO, and VETO (REPLAY) decision appends to a SHA-256 hash-chained audit ledger (prev_hash -> entry_hash).


Drop-In Shims for Open-Source Trading Agents

Wrap TauricResearch/TradingAgents or virattt/ai-hedge-fund without rewriting their research pipelines:

from clearfills_firewall import FirewallService
from clearfills_firewall.shims import TradingAgentsShim, AIHedgeFundShim

Open Core vs. Pro Infrastructure Kit

  • Open Core (clearfills-firewall, Apache-2.0 — $0): Deterministic risk engine, Ed25519 120s TTL attestation authority, replay protection, kill-switch, SHA-256 audit ledger, MCP stdio server, FastAPI server, and TradingAgents / ai-hedge-fund shims.
  • Pro Infrastructure Kit ($299 one-time): Turnkey private source repo with Fly.io + Tailscale private mesh, headless IB Gateway + IBC + API-handshake watchdog, attested-only IBKR / Alpaca / Polymarket CLOB / Kalshi adapters, and Web Console → clearfills.com/#pricing.
  • Private Desk Install (MLDSAI Inc., $15k–$25k): Custom deployment for family offices and prop desks → Book 30-min call.

Risk engineering and execution software only. Not investment advice.

Metadata

Release files for clearfills-firewall 0.1.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 clearfills-firewall 0.1.0
File Size Uploaded Provenance Actions
clearfills_firewall-0.1.0.tar.gz 24.5 kB With provenance Details for clearfills_firewall-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clearfills-firewall 0.1.0
File Interpreter ABI Platform Actions
clearfills_firewall-0.1.0-py3-none-any.whl Python 3 none any Details for clearfills_firewall-0.1.0-py3-none-any.whl

Total release size: 49.2 kB

Release files / clearfills_firewall-0.1.0.tar.gz

Download URL clearfills_firewall-0.1.0.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b210d138245b3416b8deeb60d8bcf645a6bd568ef989da72cb8ed80b7919abb8
BLAKE2b-256 checksum
How to use checksums
4128ea9d5a63c44c1ca8f909545c228d60c6aba9cc661e9511c20d78103d988a
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 Nov 23, 2026.

Transparency log

Release files / clearfills_firewall-0.1.0-py3-none-any.whl

Download URL clearfills_firewall-0.1.0-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cc0a2c49e1fd45aefaac1eb3abe1ed5ec4f9e89c9889fbf3b4d7c67955bbade
BLAKE2b-256 checksum
How to use checksums
33c838e2d391bc47619f85979fdd3896deecfd57883585c53288eacaee738e3c
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 Nov 23, 2026.

Transparency log

Security for clearfills-firewall 0.1.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 clearfills_firewall-0.1.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 Nov 23, 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

0.1.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