Skip to main content

mts1b-operations

Compliance, audit chain, halt manager, market-data API. Plus watchdog policy (drift, vpin, news_spike, db_health, position_anomaly, dependency_watchdog, portfolio_vol_dd).

Repo: github.com/MTS1B/mts1b-operations Layer: 4 Wave: 2 (months 4-7) Depends on: foundation, platform, brokers, riskengine Audience: every service publishes events here; operators consume halt + audit views

What it is

The observability + governance surface. Subscribes to every NATS subject, persists audit, enforces halts, and runs ~10 watchdogs that emit alerts when something looks wrong.

Sub-areaWhat
Audit chainMerkle-hashed append-only log of every state transition
Halt managerPer-fund / firm-wide halt with operator co-sign
Watchdogs10 background runners observing different dimensions of system health
ComplianceReg-reporting (CAT/OATS/MIFID — v3)
Market-data APIPublic read-only API for demos and dashboards

Watchdogs

WatchdogWhat it watchesTriggerAction
predictive_healthoverall NAV trajectory vs. backtested envelopeNAV outside 99% CITelegram warn
drift_monitorlive IC vs. backtest IC per strategydrift_zscore < -1.0halve allocation
vpinbulk-volume probability of informed tradingVPIN > 0.4throttle aggressive orders
news_spikesudden news volume on held names> 5σ vs 30d avgTelegram + cooldown
position_anomalyunusual position size deltasδ > 2σ from typicalTelegram
db_watchdogPostgres / DuckDB integrityrow count mismatch, slow queriesalert + auto-vacuum
strategy_watchdogper-strategy P/L vs. expectedrolling 30d outside 95% CIshadow
theta_watchdogoption positions' theta exposurenet theta > Xenforce hedge
dependency_watchdogupstream service health/healthz red for 3 pollsalert + retry
portfolio_vol_ddrealized portfolio vol vs. targetrealized > 1.5× targetreduce gross

Each watchdog is configurable per fund via Vault.

Module layout

mts1b_operations/
├── audit/
│ ├── chain.py # Merkle-hashed log
│ └── verifier.py
├── halt/
│ ├── manager.py
│ └── operator_signoff.py
├── watchdogs/
│ ├── predictive_health.py
│ ├── drift_monitor.py
│ ├── vpin.py
│ ├── news_spike.py
│ ├── position_anomaly.py
│ ├── db_watchdog.py
│ ├── strategy_watchdog.py
│ ├── theta_watchdog.py
│ ├── dependency_watchdog.py
│ └── portfolio_vol_dd.py
├── compliance/
│ ├── audit_export.py # for regulators
│ └── reg_reporting/ # CAT, OATS, MIFID (v3)
├── api/
│ ├── rest.py # FastAPI — halt control, audit query, watchdog status
│ ├── grpc.py
│ └── nats.py # subscribes mts.v1.>
└── workers/
└── halt_enforcer.py # acts on HaltRequest events

Halt manager

The kill-switch architecture. Three halt levels:

LevelScopeHow triggeredReset
STRATEGY_HALTone strategydrawdown halt OR drift_zscore < -2.0 OR manualoperator mts cmd resume <strategy_id>
FUND_HALTone fundfund daily_loss_halt_pct breachedoperator mts cmd resume <fund_id>
FIRM_HALTeverythingmanual or news_spike on aggregateoperator co-sign required

Halts publish to mts.v1.operations.halt.requested. mts1b-oms listens and stops accepting matching orders.

mts cmd halt # firm-wide HALT (confirmation: type HALT)
mts cmd cancel-all # cancel every open order (CANCEL)
mts cmd flatten-paper # flatten every paper fund (FLATTEN)
mts cmd resume # lift all runtime halts
mts cmd resume <fund_id> # lift one fund's halt
mts cmd resume <strategy_id> # lift one strategy's halt

Audit chain

Every state-changing action is logged. The chain is Merkle-hashed for tamper detection:

class AuditEntry(BaseModel):
sequence: int
timestamp: datetime
actor: str
action: str
subject_id: str
data: dict
prev_hash: str
hash: str # sha256(prev_hash + serialize(everything else))

Verify integrity:

mts1b-operations audit verify --from-sequence 0
# ✓ 47832 entries, chain integrity OK, no gaps

Used for: compliance reporting, post-mortem RCA, debugging "why did this order get rejected?"

Market-data API (read-only public)

A small subset of market data exposed via REST/WebSocket for demo dashboards. Read-only, rate-limited, no auth needed for top-level endpoints:

GET /v1/quotes/AAPL → Quote
GET /v1/bars/AAPL?interval=1d&start=2024-01-01 → list[Bar]
GET /v1/funds → list[FundStatus]
GET /v1/halts → list[HaltRequest]

Used by mts1b.investmentparadisellc.com landing page for the "live status" widget.

Compliance + reg-reporting (v3)

CAT (Consolidated Audit Trail), OATS (legacy), MIFID-II transaction reporting. Hookable adapters:

from mts1b_operations.compliance.reg_reporting import cat

await cat.report_event(
event_type="newOrderEvent",
order=order,
venue=venue,
actor=actor,
)
# Writes to per-day CAT submission file; daily upload to FINRA

CAT and OATS are SEC-only and apply only if you're a US broker-dealer. Most MTS1B users don't need these; they're shipped for those who do.

Build + test

pip install -e ".[dev]"
pytest -m unit
docker compose up -d nats postgres
pytest -m integration

Roadmap

VersionItems
0.1 (Wave 2)Audit chain, halt manager, 10 watchdogs, market-data API
0.2 (Wave 2)Operator dashboard (consolidated halt + audit view in frontends)
0.3 (Wave 3)CAT / OATS / MIFID reg-reporting (community-driven)
1.0 (LTS)Stable halt + audit schemas

See also