mts1b-operations — public API surface
Compliance + audit chain + halt manager + 10 watchdogs.
Halt manager
from mts1b_operations.halt import HaltManager
mgr = HaltManager()
# Request a halt (auto from watchdog, or manual)
req = HaltRequest(
severity="FUND_HALT",
fund_id="paper-momentum",
reason="daily PL -3.2% breached -3.0%",
requested_by="mts1b-riskengine",
)
await mgr.request(req)
# Published to mts.v1.operations.halt.requested
# Resume (sticky — needs operator)
await mgr.resume(fund_id="paper-momentum", cosigned_by="operator:mondipsen")
# Status
halts = await mgr.list_active()
status = await mgr.status(fund_id="paper-momentum")
CLI:
mts cmd halt # firm-wide; type HALT to confirm
mts cmd cancel-all # cancel every open order; type CANCEL
mts cmd flatten-paper # flatten paper funds
mts cmd resume # firm-wide resume
mts cmd resume <fund_id>
mts cmd resume <strategy_id>
mts cmd restart-all # restart 5 mts1b-* services
Audit chain
from mts1b_operations.audit import audit_chain
# Append
entry = await audit_chain.append(
actor="mts1b-oms",
action="order_rejected",
subject_id=order.order_id,
data={"reason": "drawdown_halt", "envelope_id": "env-001"},
)
# AuditEntry(sequence=47832, hash="...", timestamp=...)
# Query
trail = await audit_chain.get_trail(subject_id="ord-abc")
# list[AuditEntry] in chronological order
# Verify integrity
ok = await audit_chain.verify(from_sequence=0)
# True or raises ChainIntegrityError
CLI:
mts mts1b-operations audit show --subject-id <order_id>
mts mts1b-operations audit verify --from-sequence 0
mts mts1b-operations audit tail
Watchdogs
10 background runners, each emits NATS events on alert:
| Watchdog | Subject | Triggers when |
|---|---|---|
predictive_health | mts.v1.operations.watchdog.health | NAV outside 99% CI |
drift_monitor | mts.v1.operations.watchdog.drift | strategy IC drift |
vpin | mts.v1.operations.watchdog.vpin | VPIN > 0.4 |
news_spike | mts.v1.operations.watchdog.news | news count > 5σ |
position_anomaly | mts.v1.operations.watchdog.position | unusual position delta |
db_watchdog | mts.v1.operations.watchdog.db | row count mismatch / slow query |
strategy_watchdog | mts.v1.operations.watchdog.strategy | per-strategy PL outside CI |
theta_watchdog | mts.v1.operations.watchdog.theta | net theta exposure breach |
dependency_watchdog | mts.v1.operations.watchdog.dependency | upstream /healthz red 3x |
portfolio_vol_dd | mts.v1.operations.watchdog.vol_dd | realized vol > 1.5× target |
Each watchdog has a CLI subcommand:
mts mts1b-operations watchdog status
mts mts1b-operations watchdog config --watchdog vpin --threshold 0.4
mts mts1b-operations watchdog pause --watchdog news_spike
Market-data API (public read-only)
GET /v1/quotes/AAPL → Quote
GET /v1/bars/AAPL?interval=1d → list[Bar]
GET /v1/funds → list[FundStatus]
GET /v1/halts → list[HaltRequest]
GET /v1/healthz → {"status": "ok"}
Rate-limited per IP. No auth needed for top-level read.
Compliance / reg reporting (Wave 3)
from mts1b_operations.compliance.reg_reporting import cat
await cat.report_event(
event_type="newOrderEvent",
order=order,
venue=venue,
actor=actor,
)
Hookable adapters for CAT (Consolidated Audit Trail), OATS (legacy), MIFID-II. Off by default; enable per-fund:
fund:
fund_id: live-equities
compliance:
cat_enabled: true
cat_subscriber_id: "ABCD12345"
NATS subjects
| Subject | Direction |
|---|---|
mts.v1.> (everything) | subscribe |
mts.v1.operations.audit.appended | publish |
mts.v1.operations.halt.requested | publish |
mts.v1.operations.watchdog.* | publish |
See also
- Concept — Risk envelopes — halt triggers
foundation.risk.HaltRequestrepos/operations