Day 62 — Market Friction Modeling: Complete ExecutionDelaySimulator Workspace
This workspace delivers a production-grade
ExecutionDelaySimulatorthat measures real execution latency in Decimal, tracks P95/P99 percentiles without float contamination, and integrates directly withSlippageMonitorfrom Day 33 via a typedfriction_report()contract. It makes the gap between backtest fill assumptions and live execution visible and alertable.
What You’re Building
ExecutionDelaySimulator— the measurement and simulation layer for network-induced execution delay. It sits betweenSignalCombiner(Day 3–5) andOrderBuilder(Day 31), intercepting the signal price and fill price to computelatency_msandslippage_bpsas exactDecimalvalues.Supporting types:
DelayRecord(frozen dataclass — immutable audit record),LatencyStats(Decimal accumulator for percentile tracking),DelayStatus(enum:PENDING / MEASURING / RECORDED / ANOMALY),DelayAnomalyError(exception with attached record for alerting pipelines).This workspace extends the friction surface started in Day 33 (
SlippageMonitor) and feeds directly into the reconciliation pass from Day 34 (FillAuditLog).
Complete Implementation
See day62/src/execution_delay.py in the GitHub workspace. Key design decisions:
capture_time_ms() uses Decimal(str(time.time() * 1000)) — never Decimal(time.time() * 1000). The str() path captures display precision; the direct path captures the full IEEE 754 binary encoding including sub-microsecond noise.
LatencyStats.record() rejects float input with a TypeError. This is a hard boundary. If you’re passing float latencies into stats, you have a bug upstream — the error should surface there, not silently contaminate your P95.
friction_report() returns dict[str, Decimal | int] — all values typed, no floats. Designed to drop directly into SlippageMonitor.ingest_delay_report() without transformation.



