In classical quantitative finance, trading is often treated as a two-stage pipeline: first, predict future asset returns; second, pass those predictions into an optimizer to determine portfolio weights. However, this "predict-then-optimize" approach frequently fails in practice. Because financial time series are notoriously noisy, even a slightly "accurate" prediction can suggest aggressive rebalancing. In the real world, the commissions, spreads, and market impacts of these frequent trades—collectively known as transaction costs—quickly erode any theoretical profits.
A growing body of research suggests a more robust alternative: training models to learn trading policies directly by internalizing market friction as a fundamental constraint within the learning objective.
The Friction Problem in End-to-End Learning
When we move from simple prediction to end-to-end (E2E) models—where a neural network outputs portfolio weights directly from raw data—the model must learn to navigate the trade-off between signal and noise. As Chao Zhang, Zihao Zhang, and Mihai Cucuringu observe in A Universal End-to-End Approach to Portfolio Optimization via Deep Learning, without an explicit penalty for turnover, these models tend to produce erratic, high-frequency signals that are unprofitable after execution.
The core intuition is that transaction costs act as a high-pass filter. By penalizing the model for the change in its position, we force it to ignore fleeting, low-confidence signals and focus only on persistent market trends that are strong enough to overcome the cost of entry.
Internalizing Costs through Reinforcement Learning
Reinforcement Learning (RL) provides a natural framework for this problem because it treats trading as a sequential decision process. In this framing, the "state" includes not just market indicators, but also the agent's current holdings.
Early work by Ralph Neuneier in Optimal Asset Allocation using Adaptive Dynamic Programming demonstrated that by integrating transaction costs directly into the Q-learning reward function, agents naturally develop a "hold" bias. Instead of chasing every minor price fluctuation, the agent learns to preserve capital unless the predicted return significantly exceeds the friction of execution fees.
This mechanism was further refined by John E. Moody and Matthew Saffell through Recurrent Reinforcement Learning (RRL). In Reinforcement Learning for Trading, they showed that by making the previous position an input to the current decision, the model internalizes the path-dependency of trading. The gradient of the reward function then reflects the financial penalty of switching assets, allowing the model to optimize for net risk-adjusted returns (like the differential Sharpe ratio) rather than raw price movement.
Turnover Regularization and Differentiable Objectives
To make these models stable and trainable, researchers often use specific mathematical penalties to "dampen" the model's enthusiasm for trading.
- L1 Regularization for Sparsity: Puja Das and colleagues in Online Lazy Updates for Portfolio Selection with Transaction Costs use an $\ell_1$ penalty to encourage "lazy" updates. This ensures the portfolio only rebalances when the potential gain is large enough to justify the cost, effectively creating a "no-trade zone" around the current position.
- Turnover Penalties in Loss Functions: In the context of momentum strategies, Stefan Zohren and S Roberts have shown that adding turnover regularization directly to the loss function—as seen in Spatio-Temporal Momentum—constrains the model to produce smoother, more stable trading signals.
- Differentiable Optimization Layers: Modern frameworks like IPMO, introduced by Zhiyuan Liu in Integrated Prediction and Multi-period Portfolio Optimization, use differentiable "mirror-descent" schemes. This allows the model to backpropagate through the entire multi-period optimization process, ensuring that the predictive part of the network learns to generate forecasts that are "easy" to trade under cost constraints.
Emergent Strategic Behavior
The most compelling reason to internalize costs is the emergent behavior it produces. When transaction costs are a first-class citizen in the objective function, the model doesn't just trade less; it trades differently.
- No-Trade Zones: As explored by Paul Friedrich and Josef Teichmann in Deep Investing in Kyle's Single Period Model, models trained with costs naturally discover game-theoretic equilibria where they submit zero-volume orders if potential profits are lower than execution overhead.
- Operational Compliance: In specialized markets like electricity trading, Malte Lehna and Christoph Scholz demonstrate in A Reinforcement Learning Approach for the Continuous Electricity Market of Germany that a hybrid reward structure—balancing profit against penalties for volume imbalances—forces a behavioral shift from speculative trading to risk-averse operational compliance as delivery deadlines approach.
- Conservative Pattern Recognition: Even in visual-based models, such as the Deep Q-Network developed by Jinho Lee and Jaewoo Kang in Global Stock Market Prediction Based on Stock Chart Images, adding a fixed penalty for every trade execution encourages the model to ignore "weak" visual patterns and only act on high-conviction signals.
By treating transaction costs not as an afterthought but as a core component of the learning signal, these researchers have moved toward trading agents that are not just theoretically optimal, but practically viable in the face of real-world market friction.