Notes

Portfolio Optimization

Portfolio optimization is the problem of deciding how to divide money among investments—such as stocks, bonds, or cash—so the portfolio earns useful returns without taking more risk than intended. In reinforcement learning, this becomes a continuing sequence of decisions: the agent reallocates as prices, volatility, and market conditions change.

The decision loop
At each trading period, the agent observes a state: recent prices and returns, indicators, current holdings, available cash, and possibly estimates of volatility. It chooses an action, such as target weights of 60% in one asset and 40% in another. The market then moves, producing a reward based on the portfolio's performance. A basic reward is the period's log return, but realistic designs subtract transaction costs and penalize risk:

  • large drawdowns or excessive volatility,
  • concentrating too much capital in one asset,
  • frequent trading that loses money to spreads, fees, and market impact.

Why reinforcement learning fits
Unlike a model that predicts tomorrow's price in isolation, an RL policy learns the consequences of a sequence of allocations. Selling an asset today changes what can be earned tomorrow and incurs a cost now. The agent must also balance actions that exploit a seemingly strong signal against caution when that signal is uncertain. Algorithms such as PPO can output continuous portfolio weights, while a Gymnasium-style trading environment supplies market observations, executes rebalancing, and calculates rewards.

What makes it difficult
Financial data is limited, noisy, and non-stationary: a policy that looks excellent in a historical training period can fail when correlations, liquidity, or market regimes shift. Reward design is equally critical. An agent rewarded only for raw return can discover a dangerous shortcut—using extreme leverage or repeatedly chasing volatile assets. Training and evaluation therefore need strict time-ordered splits, realistic execution costs, constraints, and testing across distinct market periods. Portfolio optimization matters because it turns prediction into a decision process: it learns not just what might happen, but how much capital to commit given risk, costs, and the effects of prior choices.

Portfolio optimization is the sequential selection and rebalancing of asset holdings to maximize risk-adjusted returns under constraints such as transaction costs, liquidity, leverage, and exposure limits. In reinforcement learning, an agent learns trading and allocation decisions from portfolio rewards over time, accounting for how current actions affect future wealth and risk. It matters because financial allocation is inherently dynamic: decisions must balance immediate gains against long-term performance and trading costs.

Imagine packing for a trip with limited suitcase space. You could fill it with only one type of item, but that is risky: if the weather changes, you may be stuck. A better plan is to pack a mix that gives you useful options without overloading the bag.

Portfolio optimization is the financial version of that choice. It means deciding how to spread money across investments, such as shares, bonds, or cash, to seek worthwhile returns while avoiding unnecessary risk. In reinforcement learning, a system can learn this through experience: choices that lead to better long-term results are rewarded, while costly or overly risky choices are discouraged.