clearer-trade
Open-source post-trade execution auditing and zero-leakage telemetry primitives for clearer.trade.
clearer-trade is a lightweight, zero-dependency Python library for transforming raw trading ledgers and execution fills into zero-leakage, SHA-256 attested post-trade telemetry payloads (v1.0.0 contract).
Designed for systematic trading engines and execution routers that need to publish verifiable execution quality and Time-Weighted Return (TWR) benchmarks without exposing alpha signals, wallet addresses, raw tickers, or capital sizing.
Key Features
- Zero External Dependencies: Pure Python 3.11+ standard library implementation.
- Cashflow-Adjusted TWR Rebase (
compute_twr_series): Strips deposits/withdrawals and rebases daily returns to a normalized index (100.0base). - Execution Hygiene Aggregation (
compute_execution_hygiene): Computes maker fill ratio, average MAE/MFE (in basis points), post-entry adverse drift, and bucketed fill counts (to prevent exact tape-matching against public DEX/CEX feeds). - Deterministic Ticker Anonymization (
anonymize_baskets): Maps raw symbols (BTC-PERP,ETH-PERP, ...) to Excel-style anonymized asset aliases (Asset_A..Asset_Z,Asset_AA, ...) while preserving persistent cross-day symbol mappings. - Pre-Commitment SHA-256 Attestation (
compute_attestation_sha256): Produces a canonical, deterministic SHA-256 digest over raw ledger records + secretLEDGER_SALT. - End-to-End Contract Builder & Validator (
build_telemetry_payload,validate_telemetry_payload): Builds and validates payloads against theclearer.tradev1.0.0schema, enforcingT+24hpublication delay invariants, finite numeric bounds, and zero0x...wallet address leakage.
Installation
pip install clearer-trade
Or install directly from source:
pip install git+https://github.com/CnahtanoJ/clearer-trade.git
Quickstart
import os
from clearer_trade import build_telemetry_payload
daily_records = [
{"date": "2026-11-15", "nav_start": 100_000.0, "nav_end": 100_500.0, "net_flow": 0.0},
{"date": "2026-11-16", "nav_start": 100_500.0, "nav_end": 151_505.0, "net_flow": 50_000.0},
]
fills = [
{"symbol": "BTC-PERP", "order_type": "ALO", "mae_bps": 3.8, "mfe_bps": 18.2, "adverse_drift_bps": 1.1},
{"symbol": "ETH-PERP", "is_maker": True, "mae_bps": 4.6, "mfe_bps": 15.4, "adverse_drift_bps": 1.5},
]
payload = build_telemetry_payload(
node_id="clear-alpha-ref-01",
daily_records=daily_records,
fills=fills,
salt=os.environ["LEDGER_SALT"],
region="ap-northeast-1",
publication_delay_hours=24,
tick_stagger_bucket_ms=150,
decorrelation_cohort="tokyo-systematic-v1",
)
API Reference
build_telemetry_payload(*, node_id, daily_records, fills, salt, anonymize_symbols=True, ...): Assembles and validates a completev1.0.0telemetry dictionary (meta,equity_curve,execution_hygiene,anonymized_baskets). Setanonymize_symbols=Falseto preserve raw ticker names for internal or client-specific reports.validate_telemetry_payload(payload, *, strict_anonymization=True): Validates an existing dictionary against allv1.0.0contract rules (raisesValueErroron schema violations,NaN/Infinity,< 24hpublication delay, or0x...address leaks).compute_twr_series(daily_records, base=100.0): Accepts records withdaily_return_pct,nav_start/nav_end/net_flow, orpnl/capital_baseand returns a chronologically sorted TWR curve.compute_twr_summary(equity_curve, *, periods_per_year=365): Computestrading_days,total_return_pct,max_drawdown_pct,annualized_sharpe, andannualized_sortinofrom a TWR curve.compute_execution_hygiene(fills, bucket_size=50): Aggregatesmaker_fill_ratio,avg_mae_bps,avg_mfe_bps,adverse_drift_bps, andtotal_fills_bucketedin single-pass $O(1)$ memory (accepts generators and both*_bps/*_pctkeys).anonymize_baskets(fills, symbol_map=None, *, anonymize=True): Returns(baskets, resolved_symbol_map)withasset_alias(Asset_A,Asset_B, ... by default, or raw symbols whenanonymize=False),fill_share_pct, andavg_mae_bps.compute_attestation_sha256(raw_records, salt): Computes a streaming canonical SHA-256 hex digest overraw_records(supportsDecimal,datetime,date, and standard JSON types) +salt.verify_attestation(raw_records, salt, expected): Constant-time verification (hmac.compare_digest) ofraw_records+saltagainst a 64-char SHA-256 digest or fulltelemetry.jsonpayload.
Links
- Web Platform & Live Reference Telemetry: https://clearer.trade
- GitHub Repository & Schema (
telemetry.schema.json): https://github.com/CnahtanoJ/clearer-trade
License & Disclaimer
Released under the MIT License.
THE SOFTWARE IS PROVIDED AS-IS, WITHOUT WARRANTY OF ANY KIND (MIT NO_WARRANTY). clearer.trade is an open-source educational and post-trade analytical tool only. Nothing produced by this software or its reference telemetry constitutes investment advice, portfolio management, fund management, or a solicitation to buy or sell any financial instrument. Trading cryptocurrencies, equities, forex, and futures involves substantial risk of capital loss.
Metadata
Release files for clearer-trade 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clearer_trade-0.1.0.tar.gz | 23.5 kB | Without provenance | Details for clearer_trade-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clearer_trade-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for clearer_trade-0.1.0-py3-none-any.whl |
Total release size: 36.2 kB
Release files / clearer_trade-0.1.0.tar.gz
| Download URL | clearer_trade-0.1.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36df76b6353325edd3113084b1a7005d8d33e8cdf9f630719f501bd6f390b930
|
|
BLAKE2b-256 checksum How to use checksums |
9d3fac522cd43058ce2b21b50390b8bfbb23b02ea5975e8f7f50a51a74d6dcd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|
Release files / clearer_trade-0.1.0-py3-none-any.whl
| Download URL | clearer_trade-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50f15fe60c56cc6c1d34cd10c312e40b6861e3b34d64e1a9d1e290f1027e653f
|
|
BLAKE2b-256 checksum How to use checksums |
4b253ee56163bd003f28616bc79326d8ed899f585bbc6c00b260aed731ab5984
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|
Security for clearer-trade 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.
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.