A Novel Loss Function for Deep Learning Based Daily Stock Trading System
Ruoyu Guo, Haochen Qiu, Xuelun Hou
TL;DR
The study tackles the problem of building an AI-driven daily stock trading system that remains effective in evolving markets using only publicly available price/volume data and sector information. It introduces a return-weighted loss function that multiplies cross-entropy by a capped daily return, $\text{loss}(y_{true}, y_{pred}) = \text{CE}(y_{true}, y_{pred}) \cdot |r_{cap}|$, with $r_{cap}=r_d$ if $|r_d|\le 0.5$ and $0.5$ otherwise, thereby prioritizing high-movement opportunities. The approach combines sector embeddings, 1D time-series convolutions or attention, and mixture-of-experts ensembles to produce a daily ranking over five signals (Strong Sell to Strong Buy) and achieve notable performance: $61.73\%$ annual return with $SR=1.18$ (2019–2024) and $37.61\%$ annual return with $SR=0.97$ (2005–2010). Statistical analysis and drawdown metrics indicate robust performance, particularly in the more recent period, while acknowledging limitations such as high daily return volatility and the lack of fundamental or textual inputs. The work demonstrates that aligning optimization with financial impact via a tailored loss function and sector-aware representations can yield practical, data-efficient trading systems with strong risk-adjusted returns.
Abstract
Making consistently profitable financial decisions in a continuously evolving and volatile stock market has always been a difficult task. Professionals from different disciplines have developed foundational theories to anticipate price movement and evaluate securities such as the famed Capital Asset Pricing Model (CAPM). In recent years, the role of artificial intelligence (AI) in asset pricing has been growing. Although the black-box nature of deep learning models lacks interpretability, they have continued to solidify their position in the financial industry. We aim to further enhance AI's potential and utility by introducing a return-weighted loss function that will drive top growth while providing the ML models a limited amount of information. Using only publicly accessible stock data (open/close/high/low, trading volume, sector information) and several technical indicators constructed from them, we propose an efficient daily trading system that detects top growth opportunities. Our best models achieve 61.73\% annual return on daily rebalancing with an annualized Sharpe Ratio of 1.18 over 1340 testing days from 2019 to 2024, and 37.61\% annual return with an annualized Sharpe Ratio of 0.97 over 1360 testing days from 2005 to 2010. The main drivers for success, especially independent of any domain knowledge, are the novel return-weighted loss function, the integration of categorical and continuous data, and the ML model architecture. We also demonstrate the superiority of our novel loss function over traditional loss functions via several performance metrics and statistical evidence.
