This post breaks down the math behind Tachyon, the tool I built for a quant trading competition. If you haven’t read the project page yet, start there for context.
Fair Value #
The core of Tachyon is a real-time fair value estimator. For each stock \(i\) at time \(t\):
$$FV_i(t) = P_{\text{base}} + \beta_i \cdot \Delta\text{INDX} + \sum_{k} w_{i,k} \cdot \Delta S_k \cdot e^{-\lambda(t - t_k)}$$It stacks three additive terms:
1. Anchor price \(P_{\text{base}}\), the last known baseline price of the stock, updated when you enter a shock.
2. Index drift \(\beta_i \cdot \Delta\text{INDX}\), where \(\Delta\text{INDX} = \text{INDX}(t) - \text{INDX}_{\text{base}}\) is the index move since last calibration. Each stock moves with it proportionally to its beta. NOVA (\(\beta = 1.3\)) amplifies index moves; AURA (\(\beta = 0.7\)) dampens them.
3. Shock superposition, where every news event \(k\) is stored with a sector, a signed magnitude \(\Delta S_k\) (in decimal, converted from basis points), and a timestamp \(t_k\). Its contribution to stock \(i\) is scaled by \(w_{i,k}\), the stock’s sector exposure weight, and decays exponentially over time. The exponential kernel \(e^{-\lambda(t - t_k)}\) is the Green’s function of a first-order dissipative system: it is the exact solution to \(\frac{dV}{dt} = -\lambda V\), meaning the market is modelled as digesting each shock at a rate proportional to how much is left. Shocks stack additively by the principle of superposition, valid because the system is linear.
Decision Rule #
The raw fair value gap is thresholded into a discrete signal:
$$\text{signal}_i = \frac{FV_i(t) - P_{\text{market}}}{P_{\text{market}}}$$- If \(\text{signal}_i > \tau_i\) : BUY (stock is cheap relative to fair value)
- If \(\text{signal}_i < -\tau_i\) : SELL (stock is expensive relative to fair value)
- Otherwise : HOLD
The threshold \(\tau_i\) is a per-ticker spread estimate. It ensures a recommendation is only issued when the mispricing is large enough to be profitable after crossing the bid-ask spread.
Inventory-Aware Sizing #
Raw trade size is penalised by a quadratic function of current inventory:
$$\text{size}_i = \text{base\_size}_i \times \left(1 - \left(\frac{\min(|\text{inv}_i|,\ L_{\text{soft}})}{L_{\text{soft}}}\right)^2\right)$$where \(L_{\text{soft}} = 35{,}000\) shares. Squaring the inventory ratio creates a flat-bottomed potential well: the penalty is negligible at low inventory and becomes a hard wall as inventory approaches the soft limit. The result is clipped by remaining hard-limit room (\(L_{\text{hard}} = 50{,}000\)) and, for buys, by available cash.
This is adapted from the Avellaneda-Stoikov market-making model, where inventory risk grows nonlinearly and position size must be scaled accordingly.
Overshoot Detection #
Every second during the decay countdown, Tachyon checks:
$$\text{basis} = P_{\text{market}}(t) - FV_i(t)$$- If \(\text{basis} > \frac{\text{spread}}{2} + m_i\) : SHORT fade signal, the crowd has pushed price above fair value
- If \(\text{basis} < -\frac{\text{spread}}{2} - m_i\) : BUY fade signal, the crowd has pushed price below fair value
The margin \(m_i\) is a per-ticker volatility buffer that filters out normal price noise. When the basis exceeds it, the deviation is statistically anomalous, the crowd has overshot the mathematical equilibrium, and mean reversion is the expected outcome.
Lambda Calibration #
After the first shock, \(\lambda\) is back-calculated from two observed prices:
$$\lambda = -\frac{1}{\Delta t} \ln\left(\frac{P_{\text{obs}} - P_{\text{base}}}{P_{\text{peak}} - P_{\text{base}}}\right)$$\(P_{\text{peak}}\) is the price immediately after the shock. \(P_{\text{obs}}\) is the price \(\Delta t\) seconds later, once initial panic subsides. The ratio is the fraction of the original shock still remaining, taking its log and dividing by \(-\Delta t\) gives the exponential rate at which the market is digesting news. This \(\lambda\) is used for all subsequent shocks in the heat.
Optimal Exit Time #
The remaining edge from a shock decays as \(\Delta S \cdot e^{-\lambda t}\). The transaction cost to exit is approximately the spread. The optimal exit time is when these are equal:
$$\Delta S \cdot e^{-\lambda t_{\text{exit}}} = \text{spread}$$Solving for \(t_{\text{exit}}\):
$$t_{\text{exit}} = -\frac{1}{\lambda} \ln\left(\frac{\text{spread}}{|\Delta S|}\right)$$Holding past this point means the remaining mathematical edge is smaller than the cost of closing the position. The trade is no longer profitable in expectation.