Quick Start
Architecture
The compliance module is Python-only (not on the hot path) and uses a separate SQLite database so compliance data survives strategy changes. All components are thread-safe.Audit Trail
Every compliance event is recorded with a SHA-256 hash chain. Each event links to its predecessor, creating a tamper-evident log that auditors can verify end-to-end.Tracked Event Types
Trade Surveillance
Real-time detection of manipulative trading patterns using sliding-window analysis. Runs once per strategy cycle viaon_cycle().
Detectors
Accessing Alerts
Human-in-the-Loop Approval
Orders exceeding a notional threshold are held for manual review. The strategy loop is never blocked - pending orders are queued and submitted asynchronously when approved.Approval Workflow
Notification Callback
Role-Based Access Control (RBAC)
Five hierarchical roles control who can perform compliance-sensitive operations.Regulatory Limits
Firm-wide limits enforced before order submission, separate from strategy-levelRiskConfig.
Kill Switch
Emergency halt with RBAC enforcement. RequiresRISK_MANAGER role or higher. Snapshots all open positions at activation time for post-incident review.
Reporting
Generate regulatory-ready reports for internal review and filing.Daily Trade Report
Position Report
Full Compliance Report
Data Retention
SEC Rule 17a-4 requires 6+ years of record retention. Default is 2,555 days (~7 years).Pipeline Integration
Usecompliance_gate as the first function in your pipeline to automatically enforce compliance on every cycle.
compliance_gate returns None, which halts the pipeline for that cycle. Surveillance runs every cycle. Stale approvals are auto-expired.
Standalone Usage
The compliance module works independently fromhz.run():