Quant core

A mathematical layer above the strategies: levels as probabilistic objects, distributions with tails, risk by regime, real microstructure and a calibrated entry probability. Pure functions called on demand — heavy mathematics stays out of the hot loop.

01

Math core

mathcore.js · pure functions

A quantitative analysis library. Every function is input→computation→output, with no state and no side effects. It runs on demand (reports, charts, edge profiles) rather than on every backtest.

Quantised levels
Support and resistance as a probabilistic object: touches, P(rejection) / P(break), average R, false breaks, reaction speed, quality from 0 to 1, and probability by regime
Trend statistics
linear regression: angle, R² (stability), strength and probability of continuation — trend as a number, not a flag
ATR bands
a volatility percentile, ATR as a percentage of price, a LOW/NORMAL/HIGH/EXTREME band and a noise threshold
P&L distribution
expectancy, PF, payoff, skew, kurtosis, VaR95/99, tails and a histogram
Market memory
The Hurst exponent (>0.5 means trend and memory, <0.5 means reversion) plus autocorrelation
Signal entropy
Shannon entropy of the distribution — how chaotic or predictable the regime is
Fill probability
execProb: fill, slippage and partial fills — backtest realism that accounts for volatility
Time structure
biases by session and UTC hour (the EU/US overlap versus the dead zones)
Decay detector
decayModel: an edge dying quietly (expectancy falling) triggers an automatic email recommending withdrawal
02

Risk doctrine 2.0 — tail-aware

risk-guard.js

Trade size is no longer a fixed 1% divided by ATR, but adaptive to regime and tails. The multiplier depends on how the edge behaved in the current regime (expectancy and value-at-risk from history): a poor regime or a fat tail means a smaller size.

ConditionSize multiplier
High conviction (fit ≥ 1.1 — calibration: profit factor 8+)×1.25
Normal×1.0
An acceptable but not ideal regime×0.85
Negative expectancy in this regime×0.3 (micro)
The tail (value-at-risk) is markedly worse than overall×0.6

The full entry chain: signal → regime gate → tail-aware sizeMult → microstructure trim → Capital Guard → correlation limit → daily −6% / weekly −12% stop → ATR stop plus ratchet.

calibrationThe thresholds were validated on history (OANDA, crypto and equities, 6,140 trades): the 0.7 regime gate is confirmed, and at fit ≥ 1.1 the profit factor is robustly 8+ → the high-conviction tier (+25% size). The boost is granted only for demonstrated signal confidence (Kelly), never for the equity curve — and it is always overridden by protection when expectancy is poor or a drawdown is under way.
Profit Vault
a protected share of peak profit (30%) is taken out of trading and cannot be given back
Drawdown-shield
risk ×(1−d) during a drawdown — it limits how deep the dip goes
Vol-dampener
risk ×(1−σ) when the equity curve saws sideways — it smooths returns
Anti-Correlation Guard
a cluster of simultaneous losses across the book triggers risk-off for the whole group — protection against systemic storms
honestlyAsymmetric: Capital Guard only ever reduces reduces risk under stress and locks in profit — but and never inflates risk during a winning streak. Scaling up on the equity curve is deliberately avoided: a real edge's curve is close to random, so scaling on it means chasing noise. Growth comes from compounding — risk as a percentage of rising equity — not from playing the curve.
03

Market microstructure

microstructure-daemon.js · real data

A genuine order book, not a proxy built from candles. A daemon streams the Binance book (/depth) and aggressors (/aggTrades) for the major pairs and computes:

Book imbalance
the balance of bid and ask limits — who is pressing in the book
Aggressors (buy/sell)
who is hitting the market with market orders, read from the trade tape
CVD
the cumulative delta of aggressor volume
Spread (bps)
the actual spread at this moment
honestlyCrypto only. CFD and FX (OANDA, IG, Saxo) are over-the-counter dealers — a central order book simply does not exist there, so microstructure cannot be obtained. We show it in the chart widget; in the crypto bot it acts as a protective size trim rather than a gate, since the book has no history for walk-forward and we are still building forward statistics.
04

Structural probability

struct-prob.js · calibrated probability of success

Not a frequency but a probability. A logistic regression on 10 structural features (trend R², ATR band, Hurst, entropy, stretch, RSI2, momentum and others) is trained on real data and yields a calibrated probability of success for every entry. It is interpretable — the weights are visible, not a black box.

Predicted probabilityActual win rate (out of sample)
0.3 – 0.439%
0.4 – 0.546%
0.5 – 0.650%
activeCalibration is monotone: the higher the probability, the better the real outcome. Trained on 21,668 samples and retrained weekly. The probability genuinely tracks the result.
honestlyEdge modest (a spread of about 11 percentage points), most states sit near 0.5 — the market is mostly unpredictable. That is the truth, not a holy grail. For now does not affect live trades — like microstructure, it awaits forward proof and is available for reports and sizing.
05

On the chart

computed client-side, with no load on the server

Quantised support/resistance levels are drawn straight onto the chart (red for resistance, green for support) with a label R 86% ×6 — type, rejection probability and touch count. Plus microstructure widget bottom left: book imbalance, aggressors and spread for the major pairs in real time. Everything is computed in the browser from data already loaded.

×