A/B Book · Prop Forex Desk
Interactive Formula Engine · A/B Book
Client Toxicity Scoring
Determines A-book vs B-book routing based on trader profitability signals
Toxicity Score Formula
T = w₁·WinRate + w₂·Expectancy + w₃·NewsRatio + w₄·ScalpRatio
Where weights w₁=0.30, w₂=0.35, w₃=0.20, w₄=0.15 (sum to 1.0)
T > 0.65 → A-book route · T < 0.35 → B-book safe · 0.35–0.65 → partial hedge
Input Trader Metrics
Toxicity Calculation
Win Rate Score (×0.30)
Expectancy Score (×0.35)
News Ratio Score (×0.20)
Scalp Ratio Score (×0.15)
Expectancy ($/trade)
TOXICITY SCORE (T)
How to read this: Expectancy = (WinRate × AvgWin) − (LossRate × AvgLoss). A positive expectancy trader is dangerous on your B-book — they extract money from you consistently. News ratio captures latency arbitrage and macro scalpers. Scalp ratio >40% often signals algo or HFT activity. Route scores >0.65 to A-book immediately.

Example Trader Profiles
TraderWin%ExpectancyNews%Scalp%T ScoreRouting
Retail Joe42%-$12/trade8%5%0.18B-Book ✓
Swing Trader55%+$8/trade15%3%0.48Partial Hedge
News Scalper71%+$34/trade82%67%0.81A-Book ⚠
Algo HFT63%+$2/trade45%91%0.74A-Book ⚠
Net Delta & Gamma Exposure
Real-time P&L sensitivity of your B-book portfolio to price moves
Core Exposure Formulas
ΔP&L ≈ NetDelta × Δprice + ½ × NetGamma × (Δprice)²
NetDelta = Σ (position_i × lots_i × contract_size × direction_i)
NetGamma = dDelta/dPrice (sensitivity of delta to price change)
Direction: +1 for client SHORT (you are long), −1 for client LONG (you are short)
B-Book Position Inputs (EUR/USD)
Exposure Output
Client Net Long (lots)
Client Net Short (lots)
Your Net Delta (units)
Your Net Delta (lots)
1st Order P&L (Delta × Move)
2nd Order P&L (½ Gamma × Move²)
Total Estimated P&L Impact
Why Gamma matters: Most risk managers only watch delta (linear exposure). But as price moves, your delta changes — this is gamma. If you're net short gamma (clients hold options or you have convex stop-cluster risk), large moves hurt you disproportionately. The ½·Gamma·(Δprice)² term becomes significant after moves >30 pips. Always run scenarios at 50, 100, and 200 pip moves.
Value at Risk & Expected Shortfall
Maximum expected loss at a given confidence level; CVaR captures tail beyond VaR
Historical VaR & CVaR (Expected Shortfall)
VaR₉₉ = −Percentile(P&L returns, 1%)
CVaR₉₉ = −Mean(returns below VaR threshold)
Parametric VaR = μ − zα × σ × √T
z₉₉ = 2.326 · z₉₅ = 1.645 · T = holding period in days · μ = mean daily P&L · σ = daily P&L std dev
B-Book Portfolio Parameters
Risk Calculations
Selected z-score
Daily VaR
CVaR / Expected Shortfall
VaR as % of Risk Limit
Stress Loss (3σ event)
Sharpe-like B-book ratio (μ/σ)
Headroom remaining
VaR vs CVaR in plain english: VaR₉₅ of $7,000 means "on 95% of days, you won't lose more than $7,000." But CVaR tells you: on the worst 5% of days, you'll lose on average $X. CVaR is always bigger and more honest. Regulators and sophisticated prop desks use CVaR precisely because VaR ignores the shape of the tail. If your CVaR >2× VaR, your return distribution has fat tails — common in FX around news events.
Optimal Hedge Ratio
Minimises basis risk when partially hedging B-book positions to market
Minimum Variance Hedge Ratio
h* = ρ × (σclient / σmarket)
Hedged P&L Variance = σ²client × (1 − ρ²)
Hedge Effectiveness = ρ² × 100%
ρ = correlation between client flow P&L and market price move · σ = standard deviations of each
Hedge Ratio Inputs
Hedge Output
Optimal Hedge Ratio (h*)
Notional to Hedge
Notional to B-Book (retain)
Unhedged Variance (σ²)
Hedged Variance (σ²)
Hedge Effectiveness
Daily Hedge Cost
Practical meaning: h* = 0.78 means hedge 78% of the notional exposure, keep 22% on B-book. You're not hedging 100% because basis risk (ρ < 1) means a perfect hedge doesn't exist — over-hedging creates more variance than it removes. The hedge effectiveness of ρ² tells you what % of variance you've eliminated. At ρ=0.72, you eliminate ~52% of variance. If ρ < 0.5, the hedge is weak and the cost may not justify it.
VPIN — Volume-Synchronized Probability of Informed Trading
Detects toxic order flow in real time by measuring buy/sell imbalance per volume bucket
⚗️
⚠ Experimental Model — Live Data Connection Required
This module is currently running on simulated volume buckets for demonstration purposes. In a production environment, VPIN requires a real-time tick data stream with volume classification (buy-initiated vs sell-initiated) sourced directly from your MT4/MT5 Manager API or your liquidity provider's FIX 4.4 session. Without this connection, the scores shown are illustrative only and must not be used for live routing decisions. Consult your bridge provider (e.g. PrimeXM, OneZero, Gold-i) for integration options.
VPIN Formula
VPIN = (1/n) × Σ |Vbuy,τVsell,τ| / Vτ
τ = volume bucket (fixed volume interval) · n = number of buckets (typically 50) · V = volume in bucket
VPIN > 0.5 → high toxicity · VPIN < 0.25 → normal balanced flow · Classify volume using tick rule or bulk classification
Volume Bucket Data (Last 10 Buckets)
Click "Generate Buckets" or adjust scenario
VPIN Results
Number of Buckets
Average |Imbalance| per bucket
VPIN Score
Flow Regime
Recommended Action
Response thresholds:
VPIN < 0.25 → B-book normally, tight spread
0.25–0.50 → Monitor, consider widening spread 20%
0.50–0.70 → Widen spread, partial A-book routing
> 0.70 → Full A-book, refuse scalper trades
Stop-Loss Cluster Heatmap
Maps open client stop orders to identify cascade risk zones on your B-book
⚗️
⚠ Experimental Model — Live Data Connection Required
This heatmap is currently generated using synthetic stop distribution data for demonstration purposes. In production, stop cluster analysis requires a live feed of all open client positions and their stop-loss price levels, sourced via the MT4/MT5 Manager API (specifically the ManagerTradeRecordGet or equivalent call). Position data must update in real time as clients open, modify, and close orders. The cascade P&L figures shown are estimates based on simulated inputs and should not be used for live hedging decisions until a live server connection is established.
Cascade Risk at Price Level p
CascadeRisk(p) = Σ LotSizei × 1{Stopi = p±threshold}
GammaSpike(p) = dDelta/dp ≈ CascadeRisk(p) / Δp
When price sweeps through a stop cluster, your B-book delta suddenly shifts — this is a gamma event. Pre-hedge before price reaches cluster zones.
Stop Distribution Generator
Largest cluster above price
Largest cluster below price
Total B-book lots at risk (±50 pips)
Cascade P&L impact (estimate)
Stop Cluster Heatmap (±80 pips from current price)
Long stops (client take profit → your loss) Short stops (client stop loss → your gain)
How to act on this: When price is within 15 pips of a large cluster (>50 lots), pre-hedge that incremental delta to the market before the cascade. You know exactly what will happen — the cluster will trigger stop fills, suddenly shifting your net position. Gamma is highest near these zones. Post-cascade, your delta resets and you can re-evaluate B-book exposure.