# TF Market Intelligence Suite — specification lock

Version: 1.0.0  
Locked: 2026-09-04 before visual tuning  
Floating-point parity tolerance: absolute `1e-10`, relative `1e-8`, except displayed values rounded by the terminal.

## Regime Persistence Map

- Windows: efficiency ratio and sign entropy at 20, 50, 100 closed bars; use their median.
- Realized volatility: sample standard deviation of 20 log returns. Percentile compares the current value with the strictly older 252 rolling observations using midpoint rank for ties.
- Range expansion: median true range of the latest five bars divided by median true range of the preceding 60 bars. Flat/flat returns 1.0; positive/flat returns `DBL_MAX`.
- Raw states: SHOCK when volatility percentile >= 90 or expansion >= 1.8; otherwise TREND when median ER >= 0.35 and median entropy <= 0.90; otherwise RANGE when median ER <= 0.20 and median entropy >= 0.95; otherwise TRANSITION.
- Hysteresis: SHOCK activates on one bar. Every other different raw state must occur on two consecutive closed bars before the state changes.
- Bar 0 is shown as `PRELIMINARY`; closed-bar buffers use only same-bar and older data.

## Currency Network Strength

- Currencies: USD, EUR, GBP, JPY, CHF, CAD, AUD, NZD.
- Default graph: EURUSD, GBPUSD, USDJPY, USDCHF, USDCAD, AUDUSD, NZDUSD, EURGBP, EURJPY, GBPJPY, AUDJPY, EURCHF.
- Horizons and weights: 1/5/20/60 bars with 0.20/0.25/0.30/0.25.
- Per-horizon scaling: each horizon return is divided by `1.4826 * MAD` of one-bar log returns over 126 observations times the square root of the horizon, with a scale floor of `1e-6`.
- Pair weight: 1.0 normally; 0.5 when current spread exceeds three times its 126-observation median where spread history is available. Missing spread history does not invent a penalty.
- Solve weighted normal equations with the NZD node fixed temporarily to zero, then subtract the eight-score mean so all scores sum to zero. Require connected rank 7.
- Composite values are winsorized cross-sectionally to median +/- three cross-sectional robust standard deviations. Confidence is `max(0, 1 - residual_RMS/3)`.

## Portfolio Exposure & Stress

- Forex exposure includes only symbols whose broker base/profit currencies are recognized ISO-like three-letter codes and have a resolvable conversion to account currency.
- Stop risk uses `OrderCalcProfit` from current price to SL and reports absolute adverse P/L. No SL is `UNBOUNDED`, never zero.
- Stress scenarios use `OrderCalcProfit`: USD +1%, USD -1%, chart base +1%, and one daily true-range mean against every position as a deterministic conservative proxy.
- Missing conversion/specification is `UNKNOWN` and excluded from numeric totals with an explicit count.

## Economic Event Risk Map

- Query range: trade-server time -24 hours to +7 days; default filter is high importance for chart base and quote currencies.
- Refresh period: 60 seconds minimum. Cache age and the last successful server time are shown. Failed refresh retains prior entries only while explicitly marked stale.
- Events within the same currency and minute are grouped; alerts are off by default and de-duplicated per event ID and threshold.

## Locked edge cases

Short history, flat prices, zero denominators, missing symbols, prefixes/suffixes, unsynchronized pair bars, calendar timeout/offline state, hedging/netting, JPY digits, non-FX positions, missing SL, missing conversion, chart resize, history extension, and terminal restart must resolve to a documented safe state rather than a fabricated zero.
