DiffQuant optimizes the Sharpe ratio directly through a differentiable trading simulator
Most ML models for trading learn to minimize MSE but are judged by the Sharpe ratio, and those are different problems. DiffQuant removes the gap: the entire path from market features to PnL and fees is built as a single differentiable graph, so the gradient flows through the real trading mechanics. On two held-out quarters, it posted Sharpe of +1.73 and +1.15 after fees. The code is open.
AI-processed from Habr AI; edited by Hamidun News
DiffQuant is an open-source prototype that tackles a basic contradiction in ML trading: models learn to minimize mean squared error but are judged by the Sharpe ratio. The authors closed that gap by turning the whole trading pipeline, from features to PnL and fees, into one differentiable graph.
The problem with surrogate objectives
In most ML systems for quantitative trading, the setup looks like this: train a neural network to predict returns or price direction by minimizing MSE or BCE. Then build a trading strategy on top of those predictions and evaluate it by the Sharpe ratio, the ratio of mean return to volatility.
The problem is that these two objectives are not mathematically linked. A better MSE does not guarantee a better Sharpe. In practice, the network spends capacity reducing prediction error in market regimes where it has no effect on the final trading result. A 15% improvement in forecast accuracy may produce no Sharpe gain at all, a problem documented both in academic work and among quant practitioners.
Partial fixes such as ranking loss functions, custom proxy metrics and post-hoc weighting do not address the core issue: during training, the gradient does not see the real trading mechanics.
How the differentiable simulator works
DiffQuant takes the direct route: the whole trading pipeline is implemented as a single computational graph of continuous operations:
- Market features → a neural block that predicts the signal
- Signal → a target position, subject to size and direction constraints
- Position → step-by-step PnL with an explicit slippage and fee model
- Cumulative PnL → the Sharpe ratio as a differentiable scalar loss function
The key technical question is how to make positioning and costs differentiable, since real trading operations are discrete. The authors use soft approximations: instead of sharp transitions between positions, they use continuous functions accurate enough for the gradient to pass through.
"This is not a finished trading system; it is a different problem formulation," the authors stress.
The result: the gradient of the Sharpe ratio propagates back through the whole pipeline to the neural network's weights. The model trains directly on the criterion by which it will be judged in production.
Sharpe +1.73 and +1.15 after fees
The prototype was tested on two consecutive held-out quarters, periods the model saw neither during training nor during hyperparameter tuning. Sharpe was +1.73 in the first quarter and +1.15 in the second, after accounting for real fees. Both values are above one, the accepted baseline for algorithmic strategies.
The code, data and full experimental protocol are publicly available. Anyone with access to comparable market data can reproduce the results. The authors deliberately avoided complications: no exotic architectures or unconventional features, only a change of loss function.
What this means
DiffQuant shows that framing the problem correctly matters more than choosing an architecture. If a strategy is judged by Sharpe in production, that is what training should optimize, not surrogates. For quant funds and independent researchers, this is a practical signal: the gap between the training objective and the real metric can be closed technically, and doing so changes not only the result but also what exactly the model learns.
- Feb 3, 2026China's 2 Trillion Yuan Market: Algorithms Take Over the Shanghai and Beijing Exchanges
- Jul 2, 2026Computer Vision on the Shelves: Coresight Research Puts a Number on Retail Losses from Shelf Execution Errors
- Nov 6, 2026A Second of AI Video in the Final Cut Costs $0.186, Not the $0.10 on the Price Sheet
- Oct 9, 2026PCAsplat Cleans Up Gaussian Splat "Floaters" With Local PCA on Three Benchmarks
Key Questions Answered
What are the key details on The problem with surrogate objectives?
In most ML systems for quantitative trading, the setup looks like this: train a neural network to predict returns or price direction by minimizing MSE or BCE. Then build a trading strategy on top of those predictions and evaluate it by the Sharpe ratio, the ratio of mean return to volatility. The problem is that these two objectives are not mathematically linked. A better MSE does not guarantee a better Sharpe.
How the differentiable simulator works?
DiffQuant takes the direct route: the whole trading pipeline is implemented as a single computational graph of continuous operations: Market features → a neural block that predicts the signal Signal → a target position, subject to size and direction constraints Position → step-by-step PnL with an explicit slippage and fee model Cumulative PnL → the Sharpe ratio as a differentiable scalar loss function The key technical question is how to make positioning and costs differentiable, since real…
What are the key details on Sharpe +1.73 and +1.15 after fees?
The prototype was tested on two consecutive held-out quarters, periods the model saw neither during training nor during hyperparameter tuning. Sharpe was +1.73 in the first quarter and +1.15 in the second, after accounting for real fees. Both values are above one, the accepted baseline for algorithmic strategies. The code, data and full experimental protocol are publicly available. Anyone with access to comparable market data can reproduce the results.
Ship AI Faster with Founders, Engineers & Weekly Architecture Reviews
Inside Vibe Club (hamidun.com/club) — weekly live masterminds with Zhemal Khamidun, Tech Radar, full LMS access, and 370+ production Claude Code skills.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.