Skip to main content

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:

WatchdogSubjectTriggers when
predictive_healthmts.v1.operations.watchdog.healthNAV outside 99% CI
drift_monitormts.v1.operations.watchdog.driftstrategy IC drift
vpinmts.v1.operations.watchdog.vpinVPIN > 0.4
news_spikemts.v1.operations.watchdog.newsnews count > 5σ
position_anomalymts.v1.operations.watchdog.positionunusual position delta
db_watchdogmts.v1.operations.watchdog.dbrow count mismatch / slow query
strategy_watchdogmts.v1.operations.watchdog.strategyper-strategy PL outside CI
theta_watchdogmts.v1.operations.watchdog.thetanet theta exposure breach
dependency_watchdogmts.v1.operations.watchdog.dependencyupstream /healthz red 3x
portfolio_vol_ddmts.v1.operations.watchdog.vol_ddrealized 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

SubjectDirection
mts.v1.> (everything)subscribe
mts.v1.operations.audit.appendedpublish
mts.v1.operations.halt.requestedpublish
mts.v1.operations.watchdog.*publish

See also