अध्याय ६ · The Mathematics
Eight equations the engine actually runs.
Not illustrations. Each is shown with the exact line of Rust that computes it and the file it
lives in. Each returns a measured value or a refusal that carries its reason.
Microprice
micro = bid · Qask + ask · QbidQbid + Qask
Fair value inside the spread. Each price is weighted by the opposite side's size, so a heavy offer pulls fair value down toward the bid. A crossed or one-sided touch refuses.
(bid * ask_qty as f64 + ask * bid_qty as f64) / total
src/flow_metrics.rs · microprice()
Touch imbalance
I = Qbid − QaskQbid + Qask ∈ [−1, 1]
Order-flow pressure at the touch. ±1 are real extremes. Both sides empty is an absent book, not a balanced one, so it refuses instead of returning zero.
if total == 0 { return Computed::refuse(..) }
src/flow_metrics.rs · touch_imbalance()
The compounding breakeven
p* = − ln Lln W − ln L
W and L are the ledger multipliers after every charge. Below p* full-capital compounding shrinks the ledger however many cycles run. At ₹0.20, one tick each way, p* is 56.79%.
let p = -ln_l / denom;
src/altron/economics.rs · breakeven_win_rate()
The 385-sample floor
n = z² · p(1 − p)E² = 1.96² · 0.250.05² = 384.16 → 385
Below 385 observations a worst-case proportion's 95% Wilson half-width exceeds five points, which is too vague to size on. Every estimator below its floor refuses.
pub const MIN_FLOW_SAMPLES: usize = MIN_CALIBRATION_SAMPLES;
src/flow_metrics.rs · MIN_FLOW_SAMPLES
VPIN
VPIN = 1n Σ |Vbuy − Vsell|Vbucket
Volume-synchronised probability of informed trading over the last n complete buckets. A partial bucket is an unfinished measurement, so it refuses until the window is full.
Computed::Measured(sum / self.window as f64)
src/flow_metrics.rs · Vpin::value()
Lee-Ready trade sign
sign = Buy if p > mid · Sell if p < mid · tick rule at mid
Who crossed the spread. An exact-midpoint print is broken by the price path. A zero tick is Indeterminate and adds nothing to any sum, rather than leaning it in a direction.
let mid = 0.5 * (bid + ask);
src/flow_metrics.rs · classify_lee_ready()
Statutory charges
STT 0.15% × sell · Exch 0.03553% × T · SEBI 0.0001% × T
IPFT 0.0005% × T · Stamp 0.003% × buy
GST 18% × (Exch + SEBI + IPFT + brokerage)
T is buy plus sell turnover. GST is charged on services only, never on STT or stamp duty, because those are taxes. Rates are dated: these apply from 1 April 2026.
let gst = (exchange_txn + sebi + ipft + brokerage) * self.gst_on_services;
src/mm/fees.rs · StatutoryRates::breakdown()
The promotion bound
lower95 = 0.051/n · n = 20 → 86.1%
Passing every day of a finite sample does not prove a perfect daily pass rate. The verdict carries the one-sided 95% Clopper-Pearson lower bound for n of n.
pub fn assess( .. ) // every counted day, or nothing
src/promotion.rs · assess()