driftbrake
A chain-agnostic simulation and drift-based halt guard for algorithmic trading strategies.
driftbrake pre-flight simulates transactions against local chain state, tracks simulated versus realized profit upon on-chain confirmation, and halts execution the moment realized profit drifts from prediction. It prevents simulation drift, revert bursts, and silent capital bleed across algorithmic trading strategies.
Installation
pip install driftbrake
Quickstart
from driftbrake import ReconcileHistory, ReconcilePolicy, StrategyHaltedError
# Configure institutional multi-guard policy
policy = ReconcilePolicy(
fast_window=3,
fast_threshold=0.50,
slow_window=20,
slow_threshold=0.70,
max_consecutive_reverts=3,
max_revert_gas_budget=500_000,
volume_weighted_window=15,
volume_weighted_threshold=0.65,
)
history = ReconcileHistory()
# In your execution loop:
# Append predicted vs realized profit pairs (in wei or native units)
history.append(predicted_profit=1_000_000, realized_profit=950_000)
# Evaluate halt decision:
decision = policy.evaluate(history)
if decision.is_halted:
raise StrategyHaltedError(f"Strategy halted: {decision.reason}")
Vectorized Backtesting Sweep
Run parameter sweeps over millions of historical trade rows in microsecond compiled Rust time:
from driftbrake import run_sweep_raw
# pairs: list of (predicted_profit, realized_profit)
results = run_sweep_raw(
pairs,
fast_windows=[2, 3, 4],
fast_thresholds=[0.40, 0.50, 0.60],
slow_windows=[15, 20, 25],
slow_thresholds=[0.65, 0.70, 0.75],
)
for r in results:
if not r.halted:
print(f"Optimal parameters: fast={r.fast_window}/{r.fast_threshold}, slow={r.slow_window}/{r.slow_threshold}")
Documentation & Whitepaper
- Whitepaper & Mathematical Invariants: xtley001.github.io/driftbrake/whitepaper.html
- Architecture & System Design: xtley001.github.io/driftbrake/ARCHITECTURE.html
- GitHub Repository: github.com/Xtley001/driftbrake
License
Released under the MIT License.
Metadata
Release files for driftbrake-py 0.2.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 | |
|---|---|---|---|
| driftbrake_py-0.2.0.tar.gz | 41.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| driftbrake_py-0.2.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
Total release size: 223.6 kB
Release files / driftbrake_py-0.2.0.tar.gz
| Download URL | driftbrake_py-0.2.0.tar.gz |
|---|---|
| Size | 41.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b31ea599b116df4ac02af3f68109e256420b8e1a9f84100ec5da12ed6e72c737
|
|
BLAKE2b-256 checksum How to use checksums |
0b6cf704d949ce289baaba06d0d4aba41ee0057a645e2afe0f1536f05b80d2d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / driftbrake_py-0.2.0-cp310-abi3-win_amd64.whl
| Download URL | driftbrake_py-0.2.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 181.9 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0c61fc59cf3ccb0b20282e7b2331ef5644516ea988bd00fb0faa569b75a62373
|
|
BLAKE2b-256 checksum How to use checksums |
2e2a7c3736cbbdba560061c0f32659cb9384b71f602e8ed2470649d60302dd8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|