NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Directly learning stock trading strategies through profit guided loss functions

Devroop Kar, Sheeraja Rajakrishnan, Zimeng Lyu, Hao Zhang, Travis Desell, Alexander Ororbia, Daniel E. Krutz

TL;DR

Researchers have developed a way to bypass the complexity of Reinforcement Learning (RL) by training standard neural networks to trade stocks using "Profit Guided Loss Functions." By directly optimizing for financial returns rather than just price prediction accuracy, their models—particularly the Crossformer—achieved consistent annual returns of over 50%, significantly outperforming state-of-the-art RL agents and traditional "buy and hold" strategies, even during the 2022 bear market.

What Problem Does This Paper Address?

In the world of AI-driven finance, there are generally two ways to play the game:

  1. Forecasting: Predict the future price, then use a separate heuristic to decide whether to buy or sell. The problem? A model can be "accurate" at predicting price trends but still fail to capture the magnitude of moves necessary to make a profit.
  2. Reinforcement Learning (RL): Train an agent to maximize a reward (profit) through trial and error. While powerful, RL is notoriously difficult to tune, computationally expensive, and often unstable in highly volatile environments like the stock market.

The authors identify a "middle path": Direct Learning. They want to allow any standard deep learning architecture (like a Transformer) to learn a trading strategy directly through its loss function. The challenge is that "profit" isn't naturally differentiable—you can't easily calculate a gradient for a "buy" or "sell" decision to tell the network how to improve.

Methods

The core contribution is the introduction of four novel loss functions: StockLoss, StockLoss-Max, StockLoss-L2, and StockLoss-Norm.

The Architecture

The researchers modified the final layer of various time-series models (Transformers like Autoformer and Crossformer, and MLPs like DLinear). The output layer consists of $N+1$ neurons (where $N$ is the number of stocks).

  • A tanh activation function bounds the outputs between -1 (Short) and 1 (Buy).
  • The $(N+1)^{th}$ neuron acts as a "Hold" node, allowing the model to keep cash on the sidelines to mitigate risk during periods of high uncertainty.

The "Smoothing" Trick

The biggest technical hurdle was the sign() function used to determine profit (e.g., if you buy and the price goes up, profit is positive; if you short and it goes up, profit is negative). Because sign() is a step function, it has a derivative of zero almost everywhere, making backpropagation impossible.

To solve this, the authors used a sigmoidal proxy: $\tanh(\gamma x)$. By setting $\gamma$ to a high value (like 10), the function behaves like a differentiable version of the sign function, allowing the network to "feel" the gradient and learn which decisions lead to more money.

Datasets

The study utilized a massive dataset:

  • Source: Center for Research in Security Prices (CRSP).
  • Scope: 30 years of daily data for 50 different S&P 500 companies.
  • Features: 8 numerical features per stock, including price, return, bid-ask spread, volume change, and market capitalization.
  • Testing Windows: The models were evaluated across three distinct one-year periods: 2021 (Bull), 2022 (Bear), and 2023 (Recovery).

Key Insights and Ideas

  • Cutting out the Middleman: By embedding the trading strategy into the loss function, the model learns "inter-stock patterns." It doesn't just learn that Stock A is going up; it learns how to balance Stock A against Stock B to maximize the portfolio's total return.
  • Price over Percentages: Interestingly, the authors found that using raw price changes ($PRC_t$) in the loss function yielded better results than using percentage returns ($Ret_t$). They speculate this is because stock prices are non-stationary, and neural networks are better at capturing the non-linear dynamics of raw price fluctuations.
  • The "Hold" Node as a Safety Valve: The inclusion of a dedicated node for not investing acted as a "risk mitigator," though the authors noted that for the highest-performing models, the network was often confident enough to stay fully invested.
  • Stability through Normalization: The "StockLoss-L2" variant (Loss III) proved the most stable. By squaring the individual stock expressions (an L2-norm approach), the model was less likely to be swayed by extreme, volatile outliers in a single stock.

Key Results

The results were striking, particularly when compared to state-of-the-art Reinforcement Learning (RL) baselines like PPO and DDPG.

Model Period Proposed Method (Crossformer + L3) Best RL (TD3/PPO) Buy and Hold
2021 (Bull) 48.62% 43.00% 36.05%
2022 (Bear) 51.04% 2.81% -20.64%
2023 (Recovery) 51.42% 40.96% 27.77%

The most significant "aha" moment is the 2022 performance. While the general market (Buy and Hold) crashed by 20% and RL agents barely broke even, the Profit Guided Loss approach maintained a 51% return, demonstrating incredible robustness in "bear" market conditions.

Limitations and Future Work

  • Forecast Frequency: The current study uses a one-year forecast horizon for testing. In a production environment, models would likely need to be re-trained or updated weekly or monthly to account for shifting market regimes.
  • Feature Dependency: The RL baselines were limited to a specific set of features required by the FinRL library. While the authors tried to level the playing field, the direct learning models had access to a slightly broader feature set.
  • Execution Costs: The paper doesn't explicitly detail the impact of transaction fees or slippage, which can eat into profits in high-frequency scenarios (though these are daily trades, so the impact is lower).
  • Future Direction: The authors suggest applying Neural Architecture Search (NAS) to automatically design custom network structures that are specifically optimized for these profit-guided loss functions.

Summary updated

BibTeX
@article{kar2026directly,
  author = {Devroop Kar and Sheeraja Rajakrishnan and Zimeng Lyu and Hao Zhang and Travis Desell and Alexander Ororbia and Daniel E. Krutz},
  title = {{Directly learning stock trading strategies through profit guided loss functions}},
  journal = {Applied Soft Computing},
  year = {2026},
  doi = {10.1016/j.asoc.2026.116052},
}
Figure