arXiv is now an independent nonprofit! Learn more
License: CC BY 4.0
arXiv:2607.00581v1 [cs.LG] 01 Jul 2026

Decision-focused Sparse Tangent Portfolio Optimization

Haeun Jeon    Seunghoon Choi    Hyunglip Bae    Yongjae Lee    Woo Chang Kim
Abstract

Sparse tangent portfolio optimization aims to learn an interpretable, low-cardinality portfolio in the tangency direction of the mean-variance frontier. However, the associated cardinality-constrained formulation is NP-hard, and standard predict-then-optimize pipelines often misalign forecasting accuracy with downstream portfolio quality. We propose an end-to-end decision-focused learning framework that reformulates Sharpe ratio maximization as a Disciplined Parametrized Programming (DPP)-compliant convex programming layer and replaces discrete selection with a smooth top-kk operator enforcing an exact cardinality kk. This enables gradient flow through prediction, asset selection, and re-optimization, allowing the predictive model to directly optimize portfolio performance. Across four major equity markets, our method achieves competitive and often superior out-of-sample Sharpe ratios compared with historical and prediction-focused baselines, with particularly strong gains in larger asset universes. Our code is publicly available.

Machine Learning, ICML

1 Introduction

Originating from Markowitz’s mean-variance model (Markowitz, 1952), modern portfolio theory views investment decisions through the lens of balancing risk and return at the portfolio level, rather than evaluating assets in isolation (Kim et al., 2021). By combining assets with heterogeneous risk-return characteristics, investors can construct diversified portfolios that deliver lower variance for a given level of expected return. This principle is formalized through the efficient frontier and performance measures such as the Sharpe ratio, which captures the trade-off between excess return and portfolio volatility (Sharpe, 1966). Although diversification is appealing in theory, holding too many assets is often impractical, as it raises monitoring and transaction costs and makes the portfolio harder to interpret (Woodside-Oriakhi, 2011).

For these practical reasons, portfolio managers often favor sparse allocations that concentrate exposure on a limited number of assets. A standard way to formalize this preference is through a cardinality constraint, which limits the number of nonzero positions. Enforcing such sparsity, however, introduces a fundamental tension: while restricting the number of holdings improves interpretability and reduces transaction costs, it turns portfolio construction into a challenging combinatorial problem. As a result, existing approaches must balance solution quality, computational efficiency, and flexibility under varying cardinality levels. Recently, heuristic pipelines that decouple asset selection from re-optimization have shown promise as practical tools for constructing sparse tangent portfolios, offering a favorable balance between solution quality and scalability. However, these pipelines still rely on upstream forecasts produced by a separate predictive model, and their effectiveness ultimately depends on the end-to-end interaction between prediction, discrete selection, and continuous re-optimization.

Even with strong heuristics for sparse optimization, a persistent disconnect remains between prediction and decision. Conventional frameworks typically fit models on historical data and then deploy the resulting rules to make future decisions (Fabozzi et al., 2007), but they often fail to adapt to non-stationary, fast-moving markets and shifting constraints (Schmitt et al., 2013; Hamilton, 2020; Hwang et al., 2025). To mitigate this, practitioners train machine-learning models to predict future returns and let an optimizer consume those predictions to construct portfolios. However, these predictors are usually trained under statistical losses, which are misaligned with the ultimate objective of portfolio optimization and do not account for the selection and re-optimization steps that drive realized performance. This predict-then-optimize mismatch is especially harmful under tight cardinality, where small forecast errors can cascade through the discrete selection stage and magnify into substantial utility losses.

In this paper, we show that decision-focused learning (DFL) can be effectively applied to portfolio optimization with explicit cardinality constraints (Mandi and others, 2024). Unlike conventional historical estimation or predict-then-optimize pipelines, DFL trains predictive models by directly optimizing downstream decision quality rather than intermediate forecasting accuracy. We develop an end-to-end decision-focused framework for sparse portfolio optimization that enables gradient-based learning through asset selection and portfolio re-optimization. The proposed approach aligns the learning objective with risk-adjusted portfolio performance under a fixed sparsity budget, allowing the predictive model to internalize the structure of the constrained optimization problem.

Our main contributions are threefold. First, to the best of our knowledge, this is the first work to apply DFL to sparse tangent portfolio optimization with explicit cardinality constraints, bridging two research directions that have traditionally evolved separately. Second, we propose a differentiable decision layer that combines a DPP-compliant convex reformulation of Sharpe ratio maximization with a smooth top-kk asset selection operator, enabling end-to-end gradient flow through prediction, asset selection, and re-optimization. Finally, we conduct experiments across four markets with different baselines: Historic, Prediction-focused Learning (PFL), and DFL pipelines, showing that DFL achieves competitive or superior performance, with more gains in larger asset universes.

2 Related Works

2.1 Portfolio Optimization

The portfolio optimization problem yields the optimal portfolio weights, which specify how capital is allocated across assets. Markowitz’s framework established portfolio construction as an optimization problem, and subsequent work expanded it in many directions: improved estimation of returns and covariances, alternative risk measures, and practical constraints that reflect portfolio management (Kim et al., 2024). In practice, holding many assets is costly and hard to manage, so managers often prefer sparse allocations that concentrate exposure on a small number of positions (Woodside-Oriakhi, 2011). A standard way to formalize this preference is through a cardinality constraint, which explicitly caps the number of nonzero weights.

While this constraint is conceptually straightforward, it fundamentally changes the computational nature of the problem: incorporating asset-selection discreteness into objectives turns an otherwise smooth continuous optimization into a combinatorial search, which is NP-hard in general and therefore difficult to solve exactly for large asset universes (Garey and Johnson, 2002). Controlling portfolio cardinality has been studied extensively and can be broadly categorized into three methodological directions. One line induces sparsity indirectly through regularization or norm-based penalties, trading exact asset selection for scalability (Brodie et al., 2009; Chen and Zhu, 2014; Kremer et al., 2020; DeMiguel et al., 2009). Another line tackles the discrete constraint more directly via exact or relaxation-based algorithms such as branch-and-cut and related formulations (Bienstock, 1996; Li et al., 2006; Gao and Li, 2013; Kim and Lee, 2016; Lee et al., 2020). A third line relies on heuristic methods that trade optimality guarantees for computational efficiency in large asset universes (Chang et al., 2000; Maringer and Kellerer, 2003).

Beyond mean-variance, portfolio optimization has been studied under a variety of objectives, among which risk-adjusted performance metrics naturally motivate Sharpe ratio maximization as a single-objective formulation. Several works study Sharpe ratio maximization under explicit sparsity requirements (Sharpe, 1966). The Sharpe ratio is a standard risk-adjusted performance metric that normalizes expected return by volatility, enabling comparisons across portfolios with different risk levels. Representative approaches include SDP-based relaxations that yield tractable convex approximations of the sparse Sharpe problem (Kim and others, 2016), as well as methods that reformulate the fractional objective and apply efficient first-order algorithms with theoretical guarantees (Lin et al., 2024). Complementing these optimization-centric approaches, OSCAR (Optimize, Select with Cholesky, and Re-optimize) is a practical heuristic pipeline that alternates between continuous optimization and discrete asset selection to obtain scalable, high-quality sparse portfolios in large universes (Bae et al., 2025).

2.2 Decision-focused Learning

Traditional workflows that perform optimization after learning typically follow a PFL paradigm, often referred to as predict-then-optimize or two-stage learning (Lee et al., 2024). A predictive model is first trained to output point estimates of unknown problem parameters using standard statistical losses like mean squared error or cross-entropy. These predictions are then treated as fixed inputs to a downstream constrained optimization model, which computes the final decision. However, PFL does not account for the structure of the downstream decision problem. It implicitly assumes that minimizing prediction loss will lead to high-quality decisions, an assumption that often fails in practice. Therefore, models trained purely on prediction loss may perform poorly in terms of the true task objective even when their forecasts are statistically accurate.

DFL was introduced to address this mismatch by aligning model training directly with decision quality rather than with intermediate prediction accuracy. In DFL, the prediction model and the optimization layer are integrated into a single end-to-end pipeline, and training minimizes a task loss that depends on the realized decision instead of a pure prediction loss (Mandi and others, 2024). This paradigm has been applied to diverse tasks including network design, resource allocation, routing, portfolio optimization, and goal-based investing, and typically yields substantial gains over PFL when decision quality is sensitive to structured errors in the predictions.

A central technical challenge in DFL is computing gradients of the task loss with respect to the prediction model parameters. The main difficulty lies in differentiating through the downstream optimization. One must characterize how the optimizer’s solution changes in response to perturbations in the predicted cost or parameters, even though the solution map is defined only implicitly as the argmin of an optimization problem and typically has no closed-form expression, leading to zero or undefined gradients over large regions of the parameter space. Accordingly, prior DFL work typically obtains usable learning signals either by analytically differentiating the optimizer’s optimality conditions when the solution map is smooth (Shah and others, 2022), or by regularizing the optimization to create stable gradients (Brodie et al., 2009; Chen and Zhu, 2014).

Refer to caption
Figure 1: Overview of the proposed differentiable decision layer. Given predicted returns μ^\hat{\mu}, the layer performs optimize \rightarrow score transform \rightarrow soft top-kk selection \rightarrow re-optimize to produce sparse tangent portfolio weights, which define the task loss. Backpropagation flows through all steps, enabling end-to-end DFL. A central technical challenge is differentiating the optimization-based decision layer with respect to the prediction μ^\hat{\mu}.

3 Preliminaries

3.1 Cardinality-constrained Portfolio Optimization

A standard construction of portfolio optimization for maximizing the Sharpe ratio (Sharpe, 1966) can be written as:

maxwnμwwΣws.t.𝟏w=1\max_{w\in\mathbb{R}^{n}}\;\;\frac{\mu^{\top}w}{\sqrt{w^{\top}\Sigma w}}\quad\text{s.t.}\quad\mathbf{1}^{\top}w=1 (1)

where wnw\in\mathbb{R}^{n} denotes the portfolio weight vector, μn\mu\in\mathbb{R}^{n} denotes the expected excess return vector, Σn×n\Sigma\in\mathbb{R}^{n\times n} is the covariance matrix of asset returns, and 𝟏\mathbf{1} is the all-ones vector. Throughout this work, we allow short selling so negative entries in ww are permitted. The numerator represents the portfolio’s expected return, while the denominator corresponds to its risk induced by Σ\Sigma.

To enhance practical interpretability and to reduce transaction costs, one often restricts the number of assets held in the portfolio via a cardinality constraint. This leads to the sparse Sharpe ratio maximization problem:

maxwn\displaystyle\max_{w\in\mathbb{R}^{n}} μwwΣw\displaystyle\frac{\mu^{\top}w}{\sqrt{w^{\top}\Sigma w}} (2)
s.t. 𝟏w=1\displaystyle\mathbf{1}^{\top}w=1
Card(w)k\displaystyle\operatorname{Card}(w)\leq k

where Card(w)\operatorname{Card}(w) counts the number of nonzero components of ww with sparsity budget kk. As discussed in Section 2.1, adding this constraint makes the problem combinatorial rather than smoothly continuous. Since cardinality-constrained portfolio selection is NP-hard in general, exact methods are typically impractical for large asset universes.

Recent work proposes OSCAR (Bae et al., 2025) as a fast heuristic for sparse tangent portfolio optimization in the classical mean-variance framework. It avoids the combinatorial complexity of cardinality-constrained portfolio optimization by separating asset selection from weight optimization, while leveraging three key structural properties of the Sharpe ratio (Kim and Lee, 2016).

Proposition 3.1.

For any λ>0\lambda>0, the Sharpe ratio is scale-invariant with respect to ww, i.e.,

SR(wμ,Σ)=SR(λwμ,Σ).SR(w\mid\mu,\Sigma)=SR(\lambda w\mid\mu,\Sigma).

As a direct consequence, the budget constraint 𝟏w=1\mathbf{1}^{\top}w=1 in Eq. (2) can be removed without changing the optimal Sharpe ratio value.

Proposition 3.2.

Let w1,w2nw_{1},w_{2}\in\mathbb{R}^{n} be any two portfolios on nn assets, and let w^n\hat{w}\in\mathbb{R}^{n} be the tangent portfolio from Eq. (1) based on the market expected excess return μ\mu and the market covariance Σ\Sigma. Then,

SR(w1μ,Σ)SR(w2μ,Σ)SR(w_{1}\mid\mu,\Sigma)\ \geq\ SR(w_{2}\mid\mu,\Sigma)

if and only if

θ1θ2\theta_{1}\leq\theta_{2}

where

θi:=arccos((LΣwi)(LΣw^)LΣwi2LΣw^2)\theta_{i}:=\arccos\!\left(\frac{(L_{\Sigma}^{\top}w_{i})^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w_{i}\|_{2}\,\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)

which denotes the angle between LΣwiL_{\Sigma}^{\top}w_{i} and LΣw^L_{\Sigma}^{\top}\hat{w} where LΣL_{\Sigma} is the Cholesky factor of Σ\Sigma (i.e., Σ=LΣLΣ\Sigma=L_{\Sigma}L_{\Sigma}^{\top}).

According to Proposition 3.2, we can alternatively compare portfolio Sharpe ratios via the angle θ\theta to the tangency portfolio w^\hat{w}, where a smaller angle implies a larger Sharpe ratio. Let 𝒦\mathcal{K} denote the collection of all kk-subsets of {1,,n}\{1,\dots,n\} and define:

PK(n)={wnwi=0,iK}.P_{K}(\mathbb{R}^{n})=\{w\in\mathbb{R}^{n}\mid w_{i}=0,\ \forall i\notin K\}.

Then the original problem can be equivalently written as minimizing this angle as:

minK𝒦(minwPK(LΣ(n))arccos((LΣw)(LΣw^)LΣw2LΣw^2)){\small\min_{K\in\mathcal{K}}\left(\min_{w\in P_{K}\!\bigl(L_{\Sigma}^{\top}(\mathbb{R}^{n})\bigr)}\arccos\!\left(\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w\|_{2}\,\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)\right)} (3)

where

PK(LΣ(n))={wn(LΣw)i=0,iK}.P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))=\{w\in\mathbb{R}^{n}\mid(L_{\Sigma}^{\top}w)_{i}=0,\ \forall i\notin K\}.
Proposition 3.3.

Let K𝒦K^{*}\in\mathcal{K} be a subset corresponding to the indices of the kk largest elements of |LΣw^|\lvert L_{\Sigma}^{\top}\hat{w}\rvert, where ||\lvert\cdot\rvert is the element-wise absolute value operator. Then KK^{*} is an optimal solution to Eq. (3), i.e.,

K=argminK𝒦(minwPK(LΣ(n))arccos((LΣw)(LΣw^)LΣw2LΣw^2)).K^{*}=\arg\min_{K\in\mathcal{K}}\left(\min_{w\in P_{K}\!\bigl(L_{\Sigma}^{\top}(\mathbb{R}^{n})\bigr)}\arccos\!\left(\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w\|_{2}\,\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)\right).

It follows from Proposition 3.3 that the optimizer of Eq. (3) selects the kk largest components of |LΣw^|\lvert L_{\Sigma}^{\top}\hat{w}\rvert. Overall, OSCAR consists of three stages. It first solves the tangency portfolio in Eq. (1) to obtain w^\hat{w}. Using this solution, it identifies a sparse support by selecting the kk assets corresponding to the kk largest entries of |LΣw^|\lvert L_{\Sigma}^{\top}\hat{w}\rvert. Finally, it re-optimizes the Sharpe ratio objective restricted to the selected assets and derives the final optimal weight ww^{*}. Proofs of Propositions 3.2 and 3.3 are provided in Appendix A for completeness.

3.2 Gradients for Decision-focused Learning

A common formulation views the underlying decision problem as a parametric constrained optimization problem, where a solution map x(c)x^{\star}(c) returns the optimal decision for parameters cc. A standard example is regret \mathcal{R}, which measures the suboptimality of the decision under perfect information as =f(x(c),c)f(x(c^),c)\mathcal{R}=f\bigl(x^{\star}(c),c\bigr)-f\bigl(x^{\star}(\hat{c}),c\bigr), where f(x,c)f(x,c) denotes the task objective to be maximized for decision xx evaluated under the true parameters cc, and c^\hat{c} is the prediction produced by the model. By differentiating this loss through the optimization layer and updating the prediction model accordingly, DFL learns to produce parameter estimates that are explicitly tuned for downstream performance. The gradient can be calculated via the chain rule as

θ=x(c^)x(c^)c^c^θ\frac{\partial\mathcal{R}}{\partial\theta}=\frac{\partial\mathcal{R}}{\partial x^{\star}(\hat{c})}\cdot\frac{\partial x^{\star}(\hat{c})}{\partial\hat{c}}\cdot\frac{\partial\hat{c}}{\partial\theta} (4)

where θ\theta denotes the parameters of the prediction model. The first and last terms in Eq. (4) are straightforward to differentiate, whereas the middle term x(c^)/c^\partial x^{\star}(\hat{c})/\partial\hat{c} poses a substantial challenge, as the solution map is defined implicitly by an optimization problem and often lacks a closed-form expression. Moreover, for many practically relevant models, the mapping c^x(c^)\hat{c}\mapsto x^{\star}(\hat{c}) can be non-smooth or even piecewise constant, leading to zero or undefined gradients on large regions of the parameter space.

A common approach to addressing this challenge is the use of differentiable convex optimization layers when the downstream problem is convex. Frameworks such as OptNet and CVXPYlayers provide principled gradients by differentiating through the solver (Agrawal and others, 2019). To enable such differentiation, the optimization problem must satisfy the rules of Disciplined Convex Programming (DCP), and when problem data are treated as learnable inputs, the formulation must also obey Disciplined Parametrized Programming (DPP), ensuring affine dependence on parameters and well-behaved solution maps.

4 Methodologies

4.1 Differentiable Reformulation of Sharpe Ratio Maximization

We now turn to the methodological core of our approach. Our end-to-end decision framework follows a select-and-reoptimize pipeline, but is designed to be fully differentiable for learning. To embed Eq. (1) as a differentiable decision layer, the optimization problem must satisfy the rules of DPP. However, the standard Sharpe ratio formulation is non-convex and cannot be expressed using valid DPP atoms, preventing direct differentiation through a solver layer.

To obtain a tractable optimization program that is compatible with DPP, we follow the classical homogenization technique (Iyengar and Kang, 2005). Introducing a scaling variable t0t\geq 0 and defining y=twy=tw, Eq. (1) can be equivalently rewritten as the convex Quadratically Constrained Quadratic Programming (QCQP) problem. Note that this QCQP is convex, but still not DPP-compliant. The difficulty arises because the problem data Σ\Sigma appear inside the nonlinear term yΣy\sqrt{y^{\top}\Sigma y}, violating the requirement that parameters must enter the program affinely. Since the covariance matrix Σ\Sigma is positive semidefinite, we apply its Cholesky factorization Σ=LΣLΣ\Sigma={L_{\Sigma}}L_{\Sigma}^{\top}. Substituting this factorization into the QCQP yields a formulation that satisfies the requirements of DPP, enabling reliable differentiation of the solution map through CVXPYlayers and allowing the optimization step to be embedded within DFL as shown in Eq. (5).

maxy,tyμs.t.𝟏y=tyΣy1t0maxy,tyμs.t.𝟏y=tLΣy21t0\displaystyle\begin{aligned} \max_{y,t}\quad&y^{\top}\mu\\ \text{s.t.}\quad&\mathbf{1}^{\top}y=t\\ &\sqrt{y^{\top}\Sigma y}\leq 1\\ &t\geq 0\end{aligned}\;\Longrightarrow\;\begin{aligned} \max_{y,t}\quad&y^{\top}\mu\\ \text{s.t.}\quad&\mathbf{1}^{\top}y=t\\ &\|{L_{\Sigma}}y\|_{2}\leq 1\\ &t\geq 0\end{aligned} (5)

4.2 Differentiable Top-kk Operator

In the asset selection step, we classify assets in the Cholesky-transformed space by computing x=|LΣw|nx=|L_{\Sigma}^{\top}w|\in\mathbb{R}^{n} and selecting the top-kk indices. A hard top-kk produces a kk-hot mask but is discontinuous, and thus gradients do not flow through the selection step. To address this, we replace it with a simple differentiable top-kk operator that behaves like a soft kk-hot mask and still enforces a strict sum–to–kk constraint (Ahle, 2022).

Forward pass

Let xnx\in\mathbb{R}^{n} be the vector whose top-kk entries we want to select. In our model, x=|LΣw|x=\lvert L_{\Sigma}^{\top}w\rvert. Let σ:(0,1)\sigma:\mathbb{R}\to(0,1) denote the logistic sigmoid, which is a smooth, monotone function. We then look for a scalar shift tt\in\mathbb{R} such that:

i=1npi(x)=k,pi(x)=σ(xi+t)i=1,,n.\sum_{i=1}^{n}p_{i}(x)=k,\quad p_{i}(x)=\sigma\!\bigl(x_{i}+t\bigr)\quad i=1,\dots,n. (6)

Because σ\sigma is monotone, the left-hand side of Eq. (6) is monotone in tt as well. The unique solution t(x)t^{*}(x) can thus be obtained by a one-dimensional bisection search between two bounds at which the sigmoid is saturated. The result p(x)(0,1)np(x)\in(0,1)^{n} behaves like a softened top-kk mask: the kk largest coordinates of xx receive values close to 11, the others close to 0, and the total mass is exactly kk.

Backward pass

The mapping xp(x)x\mapsto p(x) is differentiable, but pi(x)=σ(xi+t(x))p_{i}(x)=\sigma(x_{i}+t(x)) depends on xx both directly through xix_{i} and indirectly through the shared shift t(x)t(x). For a fixed index jj, the chain rule gives:

pi(x)xj=σ(xi+t(x))(δij+t(x)xj)\frac{\partial p_{i}(x)}{\partial x_{j}}=\sigma^{\prime}\bigl(x_{i}+t(x)\bigr)\left(\delta_{ij}+\frac{\partial t(x)}{\partial x_{j}}\right) (7)

where δij\delta_{ij} is the Kronecker delta. Thus, the only missing piece is t(x)/xj\partial t(x)/\partial x_{j}. We obtain t(x)/xj\partial t(x)/\partial x_{j} by differentiating the normalization constraint Eq. (6) with respect to xjx_{j}. Then we get:

0=i=1nσ(xi+t(x))(δij+t(x)xj).0=\sum_{i=1}^{n}\sigma^{\prime}\bigl(x_{i}+t(x)\bigr)\left(\delta_{ij}+\frac{\partial t(x)}{\partial x_{j}}\right). (8)

Define:

vi(x):=σ(xi+t(x))andS(x):=i=1nvi(x).v_{i}(x):=\sigma^{\prime}\bigl(x_{i}+t(x)\bigr)\quad\text{and}\quad S(x):=\sum_{i=1}^{n}v_{i}(x).

Then Eq. (8) can be written as:

t(x)xj=vj(x)S(x).\frac{\partial t(x)}{\partial x_{j}}=-\,\frac{v_{j}(x)}{S(x)}. (9)

Substituting Eq. (9) into Eq. (7) shows that the Jacobian has a diagonal minus rank-one structure:

J(x)=diag(v(x))v(x)v(x)S(x).J(x)=\operatorname{diag}\bigl(v(x)\bigr)-\frac{v(x)\,v(x)^{\top}}{S(x)}. (10)

Backpropagation does not require the full matrix J(x)J(x). It only needs the vector–Jacobian product with an incoming gradient gng\in\mathbb{R}^{n}:

gJ(x)=gv(x)g,v(x)S(x)v(x)g^{\top}J(x)=g\odot v(x)-\frac{\langle g,v(x)\rangle}{S(x)}\,v(x) (11)

where \odot denotes elementwise multiplication. This expression reuses the same shift t(x)t(x) computed in the forward pass, and can be implemented without explicitly forming any large matrices, making the backward pass both numerically stable and efficient. In our implementation, we further introduce a sharpness parameter β>0\beta>0 to control the hardness of the soft top-kk operator. Instead of using pi(x)=σ(xi+t)p_{i}(x)=\sigma(x_{i}+t), we define:

pi(x)=σ(β(xi+t(x))),i=1,,np_{i}(x)=\sigma\!\left(\beta(x_{i}+t(x))\right),\qquad i=1,\ldots,n (12)

where a larger value of β\beta produces a steeper transition and approximates the hard top-kk mask more closely.

This differentiable top-kk operator has several properties that make it well-suited for our framework. By construction, it satisfies the cardinality constraint, ensuring that the soft mask always preserves the desired sparsity budget. It is also computationally efficient in both directions: the forward pass identifies the required shift via a lightweight one-dimensional bisection search, and the backward pass uses the closed-form vector-Jacobian product derived in Eq. (11), enabling fast and stable gradient evaluation. These properties enable the asset-selection module to be easily integrated into the end-to-end pipeline and allow the entire architecture to be trained with standard gradient-based optimizers.

We now describe how the proposed decision layer is embedded into a DFL framework for cardinality-constrained Sharpe ratio maximization. Figure 1 provides an overview of the proposed framework. A predictive model fθf_{\theta} parametrized by θ\theta takes as input a window of historical market data and outputs the quantities required by the optimization layer, such as a predicted mean return vector μ^\hat{\mu}. These predictions are then passed to the differentiable decision layer, which produces a sparse portfolio w(μ^)w^{\star}(\hat{\mu}) that satisfies the relevant budget, risk, and kk-asset selection constraints.

The key role of the decision layer emerges during training: we define the learning objective directly in terms of downstream portfolio quality. By backpropagating through the differentiable decision mapping, the parameters θ\theta are updated so that the predictive model learns to produce predictions aligned with the portfolio objective, rather than with a forecasting loss. As a result, the learned predictor is aligned with out-of-sample risk-adjusted performance under explicit cardinality constraints. The overall training procedure is summarized in Algorithm 1.

Algorithm 1 Training predictive model fθf_{\theta} with a Differentiable Decision Layer
Input: training set {(xi,yi)}i=1N\{(x_{i},y_{i})\}_{i=1}^{N}, where xix_{i} is the look-back window of past returns and yiy_{i} is the next-period return; learning rate η\eta, batch size BB, cardinality kk, mixing weight α\alpha.
 Compute rolling covariance matrix Σi\Sigma_{i} from the look-back window xix_{i}.
for each training epoch do
  for mini-batch {1,,N}\mathcal{B}\subset\{1,\dots,N\} with ||=B|\mathcal{B}|=B do
   for each (xi,yi)(x_{i},y_{i})\in\mathcal{B} do
    μ^ifθ(xi)\hat{\mu}_{i}\leftarrow f_{\theta}(x_{i})
    wi(0)w(μ^i;Σi)w_{i}^{(0)}\leftarrow w^{*}(\hat{\mu}_{i};\Sigma_{i}) by solving Eq. (5)
    si|LΣiwi(0)|s_{i}\leftarrow\bigl|L_{\Sigma_{i}}^{\top}w_{i}^{(0)}\bigr|
    μiSoftTop-k(μ^i;si,k)\mu^{\prime}_{i}\leftarrow\mathrm{SoftTop}\text{-}k(\hat{\mu}_{i};\,s_{i},k)
    wiw(μi;Σi)w_{i}^{*}\leftarrow w^{*}(\mu^{\prime}_{i};\Sigma_{i}) by solving Eq. (5)
    DFL(i)yiwi\mathcal{L}_{\mathrm{DFL}}^{(i)}\leftarrow-\,y_{i}^{\top}w_{i}^{*}
    MSE(i)μ^iyi22\mathcal{L}_{\mathrm{MSE}}^{(i)}\leftarrow\|\hat{\mu}_{i}-y_{i}\|_{2}^{2}
    (i)αDFL(i)+(1α)MSE(i)\mathcal{L}^{(i)}\leftarrow\alpha\mathcal{L}_{\mathrm{DFL}}^{(i)}+(1-\alpha)\mathcal{L}_{\mathrm{MSE}}^{(i)}
   end for
   1||i(i)\mathcal{L}\leftarrow\frac{1}{|\mathcal{B}|}\sum_{i\in\mathcal{B}}\mathcal{L}^{(i)}
   θθηθ\theta\leftarrow\theta-\eta\nabla_{\theta}\mathcal{L}
  end for
end for

5 Experiments

5.1 Loss Function

We describe the training loss used when applying DFL to Sharpe ratio maximization. The decision-focused component is a regret-style loss based on the maximization problem in the objective of Eq. (5). Given the true mean returns μ\mu^{*} and the predicted mean returns μ^\hat{\mu}, we compare the portfolio w(μ^)w^{*}(\hat{\mu}) that is optimal under the prediction with the portfolio w(μ)w^{*}(\mu^{*}) that is optimal under the ground-truth parameters. The resulting loss is:

DFL\displaystyle\mathcal{L}_{\mathrm{DFL}} =(w(μ^),μ)\displaystyle=\mathcal{R}\bigl(w^{*}(\hat{\mu}),\mu^{*}\bigr) (13)
=f(w(μ),μ)f(w(μ^),μ)\displaystyle=f\bigl(w^{*}(\mu^{*}),\mu^{*}\bigr)-f\bigl(w^{*}(\hat{\mu}),\mu^{*}\bigr)
=μw(μ)μw(μ^).\displaystyle=\mu^{*\top}w^{*}(\mu^{*})-\mu^{*\top}w^{*}(\hat{\mu}).

Since the first term on the right-hand side is constant with respect to the model parameters, we omit it from the loss to reduce computational cost.

Purely decision-focused loss can suffer from noisy or vanishing gradients, especially when the optimization landscape is relatively flat around the optimum. To alleviate this limitation, we augment the regret loss with a standard prediction term that penalizes the squared error between μ^\hat{\mu} and μ\mu^{*}. Concretely, we train the network using the task loss Task\mathcal{L}_{\mathrm{Task}}:

Task=αDFL+(1α)MSE\mathcal{L}_{\mathrm{Task}}=\alpha\mathcal{L}_{\mathrm{DFL}}+(1-\alpha)\mathcal{L}_{\mathrm{MSE}} (14)

where α[0,1]\alpha\in[0,1] controls the balance between decision quality and prediction accuracy. Note that the MSE loss is defined as MSE=1Ni=1Nμiμ^i22\mathcal{L}_{\mathrm{MSE}}=\frac{1}{N}\sum_{i=1}^{N}\|\mu_{i}^{*}-\hat{\mu}_{i}\|_{2}^{2}. This combined loss leads to more stable training and encourages the model to produce forecasts that are both accurate and well aligned with the downstream portfolio optimization task.

5.2 Experimental Setup

We use a 10-year daily closing price dataset from Yahoo Finance covering four markets: EuroStoxx50, FTSE100, KOSPI200, and Nikkei225. The sample period spans from January 2016 to December 2025. We restrict attention to constituents with stable index membership, omitting any firms that enter or leave the index during the period.

For the prediction model, we first preprocess the time series into rolling windows of daily returns with a 100-day look-back horizon. Each input feature vector XtX_{t} consists of the past 100 days of returns up to day tt, and the network is trained to predict the one-step-ahead return μ^t+1\hat{\mu}_{t+1}. This predicted mean vector is then passed to the optimization layer, which solves the portfolio problem and outputs the corresponding optimal weights w(μ^t+1)w^{*}(\hat{\mu}_{t+1}). The full dataset is split chronologically into training and test sets with an 80/20 ratio. Throughout all experiments, the input covariance matrix is estimated in a rolling-window manner for each sample, using the same historical look-back window that forms the model input. Once computed for a given sample, covariance is held fixed within the corresponding downstream optimization layer and is not learned or predicted by the neural network. In other words, the covariance structure varies across samples through the rolling window, but remains exogenous with respect to the predictive model parameters. This design avoids feeding noisy model outputs into the risk constraints of the downstream optimization, which can otherwise lead to unstable or infeasible problem instances, while still allowing the risk estimate to reflect local market conditions.

Refer to caption
Refer to caption
Refer to caption
Figure 2: Portfolio return time-series of FTSE100 on the test set across three cardinality levels ρ{10%,15%,20%}\rho\in\{10\%,15\%,20\%\}. We compare our DFL framework with the PFL baselines. Across most time periods, DFL attains higher returns than the competing methods.
Table 1: Out-of-sample Sharpe ratios on four equity markets. Values are reported as mean and standard deviation over five random seeds. The Historic results are estimated using the full training set and thus have zero standard deviation. The best-performing method for each market-cardinality pair is bold-lettered.
Historic PFL DFL
Market NN kk OSCAR SD-relaxation mSSRM OSCAR SD-relaxation mSSRM Ours
EuroStoxx50 47 5 0.156 ±\pm 0.000 0.077 ±\pm 0.000 0.148 ±\pm 0.000 0.809 ±\pm 0.025 0.982 ±\pm 0.087 0.821 ±\pm 0.074 0.955 ±\pm 0.014
7 0.198 ±\pm 0.000 -0.037 ±\pm 0.000 0.149 ±\pm 0.000 0.827 ±\pm 0.023 1.041 ±\pm 0.066 0.846 ±\pm 0.089 0.972 ±\pm 0.016
9 0.228 ±\pm 0.000 -0.045 ±\pm 0.000 0.152 ±\pm 0.000 0.841 ±\pm 0.020 1.116 ±\pm 0.058 0.889 ±\pm 0.081 0.983 ±\pm 0.016
FTSE100 93 9 0.269 ±\pm 0.000 0.198 ±\pm 0.000 0.167 ±\pm 0.000 0.776 ±\pm 0.025 0.931 ±\pm 0.052 0.782 ±\pm 0.044 0.983 ±\pm 0.016
14 0.322 ±\pm 0.000 0.245 ±\pm 0.000 0.234 ±\pm 0.000 0.853 ±\pm 0.022 1.073 ±\pm 0.061 0.841 ±\pm 0.049 1.049 ±\pm 0.034
19 0.396 ±\pm 0.000 0.254 ±\pm 0.000 0.237 ±\pm 0.000 0.888 ±\pm 0.020 1.142 ±\pm 0.057 0.873 ±\pm 0.047 1.071 ±\pm 0.021
KOSPI200 162 16 0.426 ±\pm 0.000 0.727 ±\pm 0.000 0.319 ±\pm 0.000 0.887 ±\pm 0.017 1.182 ±\pm 0.042 1.372 ±\pm 0.052 1.958 ±\pm 0.022
24 0.485 ±\pm 0.000 0.814 ±\pm 0.000 0.332 ±\pm 0.000 0.918 ±\pm 0.010 1.684 ±\pm 0.037 1.491 ±\pm 0.058 2.030 ±\pm 0.062
32 0.527 ±\pm 0.000 0.845 ±\pm 0.000 0.325 ±\pm 0.000 0.935 ±\pm 0.009 1.793 ±\pm 0.118 1.586 ±\pm 0.171 2.098 ±\pm 0.016
Nikkei225 208 21 0.258 ±\pm 0.000 0.198 ±\pm 0.000 0.273 ±\pm 0.000 0.567 ±\pm 0.014 0.743 ±\pm 0.103 0.614 ±\pm 0.092 0.862 ±\pm 0.060
31 0.284 ±\pm 0.000 0.243 ±\pm 0.000 0.276 ±\pm 0.000 0.620 ±\pm 0.012 0.812 ±\pm 0.111 0.662 ±\pm 0.094 0.878 ±\pm 0.040
42 0.295 ±\pm 0.000 0.248 ±\pm 0.000 0.280 ±\pm 0.000 0.649 ±\pm 0.011 0.886 ±\pm 0.126 0.721 ±\pm 0.107 0.946 ±\pm 0.130

5.3 Baselines and Evaluation Metric

We evaluate our proposed framework against two conventional learning-optimization frameworks and three state-of-the-art portfolio optimization models for cardinality-constrained Sharpe ratio maximization.

Conventional frameworks

  1. 1.

    Historic: In the historic baseline, we do not train a prediction model and instead use the historical expected return vector μ\mu directly in the optimization problem, i.e., the portfolio weights are obtained as w(μ)w^{*}(\mu) from the mean-variance objective.

  2. 2.

    PFL: In the PFL framework, we first learn a predictive model fθf_{\theta} and use its output μ^=fθ(x)\hat{\mu}=f_{\theta}(x) as the expected return in the downstream optimization, yielding portfolio weights w(μ^)w^{*}(\hat{\mu}).

Optimization models

For the optimization, we consider three state-of-the-art models for cardinality-constrained Sharpe ratio maximization:

  1. 1.

    OSCAR (Bae et al., 2025): A three-stage heuristic that solves the tangency portfolio, selects the top-kk assets in the Cholesky-transformed space, and re-optimizes weights over the selected support.

  2. 2.

    SD-relaxation (Kim and others, 2016): This approach relaxes the cardinality-constrained Sharpe ratio maximization into a tractable semidefinite program by lifting the portfolio weights to a positive semidefinite matrix and replacing the nonconvex sparsity structure with a convex surrogate.

  3. 3.

    mSSRM-PGA (Lin et al., 2024): This method tackles mm-sparse Sharpe ratio maximization by first rewriting the fractional objective into an equivalent mm-sparse quadratic program, and then running a proximal-gradient algorithm whose proximal step simply keeps the largest positive entries (up to the sparsity budget) and truncates the rest to zero.

Evaluation metric

Our primary evaluation metric is the out-of-sample Sharpe ratio computed from the realized portfolio returns. For a given sequence of portfolio weights {wt}t=1T\{w_{t}\}_{t=1}^{T} and next-period realized returns {rt+1}t=1T\{r_{t+1}\}_{t=1}^{T}, we form the realized return series:

rp,t=wtrt+1,t=1,,T.r_{p,t}=w_{t}^{\top}r_{t+1},\qquad t=1,\dots,T.

The (daily) Sharpe ratio is then defined as:

SR=r¯psp=1Tt=1Trp,t1T1t=1T(rp,tr¯p)2\mathrm{SR}=\frac{\bar{r}_{p}}{s_{p}}=\frac{\frac{1}{T}\sum_{t=1}^{T}r_{p,t}}{\sqrt{\frac{1}{T-1}\sum_{t=1}^{T}(r_{p,t}-\bar{r}_{p})^{2}}}

where r¯p\bar{r}_{p} and sps_{p} denote the sample mean and sample standard deviation of the realized portfolio returns. We report this Sharpe ratio for every method and market as the main measure of risk-adjusted performance. Higher Sharpe ratios indicate better return–volatility trade-offs.

6 Results

Table 1 summarizes the out-of-sample Sharpe ratios obtained across the four equity markets and cardinality levels ρ{10%,15%,20%}\rho\in\{10\%,15\%,20\%\}. Note that our objective is to maximize the Sharpe ratio. The cardinality kk is derived by multiplying each level by the number of assets NN and rounding to the nearest integer as k=round(ρN)k=\mathrm{round}(\rho\cdot N). The Historic baselines, which directly optimize on sample mean returns without any learning component, consistently underperform. This confirms that purely backward-looking estimates are insufficient in non-stationary markets.

PFL delivers substantial improvements over Historic, but its performance varies substantially depending on the optimization model. In EuroStoxx50 and partly in FTSE100, the SD-relaxation-based PFL baseline achieves slightly higher average Sharpe ratios than the proposed framework. However, our method remains highly competitive in these cases, with only small performance gaps, while exhibiting smaller standard deviations across seeds. This suggests that although SD-relaxation can occasionally obtain strong average performance, its results are relatively more sensitive to training randomness.

In contrast, the advantage of the proposed framework becomes much clearer in larger asset universes. On KOSPI200 and Nikkei225, the gap between our method and the PFL baselines widens noticeably across most cardinality levels, particularly for KOSPI200 where our framework consistently achieves substantially higher Sharpe ratios than all PFL variants. These results demonstrate that aligning prediction, selection, and re-optimization through end-to-end training is highly effective for Sharpe ratio maximization under sparsity constraints.

In addition to the Sharpe ratio, we further compare the portfolio returns achieved by each model over the test period. Figure 2 presents illustrative portfolio return time-series results on FTSE100 across different cardinality levels. The results show that our DFL framework consistently attains higher portfolio returns than the PFL baselines across most time periods. Similar patterns are also observed in the other equity markets, as reported in Appendix C.3. At the same time, because our current formulation allows short selling, higher Sharpe ratios may be accompanied by a more aggressive downside-risk profile. To examine this aspect, Appendix C.2 reports additional Maximum Drawdown (MDD) results and discusses the risk trade-off of the learned portfolios.

Overall, the evidence shows that decision-focused training can optimize predictions directly for the sparse Sharpe ratio objective through a differentiable decision layer. This produces sparse portfolios that outperform Historic and PFL baselines, particularly in larger asset universes, while remaining competitive in smaller markets.

7 Conclusion

We present a DFL framework for Sharpe ratio maximization under cardinality constraints. Our approach enables end-to-end training by differentiating through the sparse decision pipeline, allowing gradients to propagate through prediction, soft top-kk selection, and re-optimization. As a result, the learning objective is directly aligned with downstream portfolio quality, in contrast to traditional PFL approaches that rely on forecasting loss as a proxy.

Extensive experiments confirm that the proposed framework provides an effective way to train predictive models for sparse Sharpe ratio portfolio construction. Rather than treating return prediction as a separate intermediate task, our approach aligns the predictor with the downstream selection and re-optimization procedure. The empirical results show that this DFL alignment leads to competitive and often superior risk-adjusted performance, especially in larger asset universes where the sparse selection problem becomes more challenging.

Despite these advantages, the framework has three main limitations. First, differentiating through the sparse selection module, especially the soft top-kk operator, introduces computational overhead as the asset universe or the sparsity budget grows. Second, our framework allows short selling and does not impose practical constraints such as long-only positions, leverage limits, or turnover penalties. Lastly, our approach is tailored to sparse tangent portfolio optimization, and extending it to other cardinality-constrained portfolio objectives with different downstream goals is nontrivial.

Future work includes designing more efficient differentiable selection mechanisms to improve scalability, incorporating practical constraints to make the framework more realistic, and exploring broader applications where DFL can improve decision quality beyond sparse portfolio construction.

Impact Statement

This paper presents work whose goal is to advance the field of Machine Learning in Finance. There are many potential societal consequences of our work, none of which we feel must be specifically highlighted here.

Acknowledgement

This work was supported by the National Research Foundation (NRF) of Korea grant funded by the Ministry of Science and ICT (MSIT) of Korea (No. RS-2022-NR068758, No. RS-2025-02216640, No. RS-2025-24803208) and the Institute of Information & Communications Technology Planning & Evaluation (IITP) grant funded by the Ministry of Science and ICT (MSIT) of Korea (No. RS-2020-II201336, Artificial Intelligence Graduate School Program (UNIST)).

References

  • A. Agrawal et al. (2019) Differentiable convex optimization layers. In Advances in Neural Information Processing Systems, Vol. 32. Cited by: §B.1, §3.2.
  • T. D. Ahle (2022) A differentiable Top-k layer for PyTorch. Note: https://thomasahle.com/blog/differentiable_topk.htmlAccessed: 2026-05-24 Cited by: §4.2.
  • H. Bae, H. Jeon, M. Park, Y. Lee, and W. C. Kim (2025) A cholesky decomposition-based asset selection heuristic for sparse tangent portfolio optimization. Note: arXiv preprint External Links: 2502.11701 Cited by: Appendix A, §2.1, §3.1, item 1.
  • D. Bienstock (1996) Computational study of a family of mixed-integer quadratic programming problems. Mathematical Programming 74 (2), pp. 121–140. Cited by: §2.1.
  • J. Brodie, I. Daubechies, C. De Mol, D. Giannone, and I. Loris (2009) Sparse and stable markowitz portfolios. Proceedings of the National Academy of Sciences 106 (30), pp. 12267–12272. Cited by: §2.1, §2.2.
  • T.-J. Chang, N. Meade, J. E. Beasley, and Y. M. Sharaiha (2000) Heuristics for cardinality constrained portfolio optimisation. Computers & Operations Research 27 (13), pp. 1271–1302. Cited by: §2.1.
  • L. Chen and Y. Zhu (2014) Sparse portfolio selection via quasi-norm regularization. IEEE Transactions on Signal Processing 62 (24), pp. 6554–6568. Cited by: §2.1, §2.2.
  • V. DeMiguel, L. Garlappi, F. J. Nogales, and R. Uppal (2009) A generalized approach to portfolio optimization: improving performance by constraining portfolio norms. Management Science 55 (5), pp. 798–812. Cited by: §2.1.
  • F. J. Fabozzi, P. N. Kolm, D. A. Pachamanova, and S. M. Focardi (2007) Robust portfolio optimization and management. John Wiley & Sons. Cited by: §1.
  • J. Gao and D. Li (2013) Optimal cardinality constrained portfolio selection. Operations Research 61 (3), pp. 745–761. Cited by: §2.1.
  • M. R. Garey and D. S. Johnson (2002) Computers and intractability. Vol. 29, wh freeman New York. Cited by: §2.1.
  • J. D. Hamilton (2020) Time series analysis. Princeton university press. Cited by: §1.
  • Y. Hwang, Y. Lee, J. Lee, S. Zohren, J. H. Kim, W. C. Kim, Y. Lee, and F. J. Fabozzi (2025) Deep learning in asset management: architectures, applications, and challenges. The Journal of Portfolio Management 52 (2), pp. 233–271. Cited by: §1.
  • G. Iyengar and W. Kang (2005) Inverse conic programming with applications. Operations Research Letters 33 (3), pp. 319–330. Cited by: §4.1.
  • H. Jeon, H. Bae, C. Kim, Y. Lee, and W. C. Kim (2025) Prediction loss guided decision-focused learning. arXiv preprint arXiv:2509.08359. Cited by: §C.1.
  • J. H. Kim, Y. Lee, W. C. Kim, and F. J. Fabozzi (2021) Mean-variance optimization for asset allocation. Journal of Portfolio Management 47 (5), pp. 24–40. Cited by: §1.
  • J. H. Kim, Y. Lee, W. C. Kim, T. Kang, and F. J. Fabozzi (2024) An overview of optimization models for portfolio management.. Journal of Portfolio Management 51 (2), pp. 101–117. Cited by: §2.1.
  • M. J. Kim et al. (2016) Sparse tangent portfolio selection via semi-definite relaxation. Operations Research Letters 44 (4), pp. 540–543. Cited by: §B.2, §2.1, item 2.
  • W. C. Kim and Y. Lee (2016) A uniformly distributed random portfolio. Quantitative Finance 16 (2), pp. 297–307. Cited by: Appendix A, §2.1, §3.1.
  • P. J. Kremer, S. Lee, M. Bogdan, and S. Paterlini (2020) Sparse portfolio selection via the sorted 1\ell_{1}-norm. Journal of Banking & Finance 110, pp. 105687. Cited by: §2.1.
  • Y. Lee, M. J. Kim, J. H. Kim, J. R. Jang, and W. C. Kim (2020) Sparse and robust portfolio selection via semi-definite relaxation. Journal of the Operational Research Society 71 (5), pp. 687–699. Cited by: §2.1.
  • Y. Lee, J. H. Kim, W. C. Kim, and F. J. Fabozzi (2024) An overview of machine learning for portfolio optimization.. Journal of Portfolio Management 51 (2), pp. 131–148. Cited by: §2.2.
  • D. Li, X. Sun, and J. Wang (2006) Optimal lot solution to cardinality constrained mean–variance formulation for portfolio selection. Mathematical Finance: An International Journal of Mathematics, Statistics and Financial Economics 16 (1), pp. 83–101. Cited by: §2.1.
  • Y. Lin, Z.-R. Lai, and C. Li (2024) A globally optimal portfolio for mm-sparse sharpe ratio maximization. In Advances in Neural Information Processing Systems, Vol. 37, pp. 17133–17160. Cited by: §B.3, §2.1, item 3.
  • J. Mandi et al. (2024) Decision-focused learning: foundations, state of the art, benchmark and future opportunities. Journal of Artificial Intelligence Research 80, pp. 1623–1701. Cited by: §1, §2.2.
  • D. Maringer and H. Kellerer (2003) Optimization of cardinality constrained portfolios with a hybrid local search algorithm. OR Spectrum 25 (4), pp. 481–495. Cited by: §2.1.
  • H. Markowitz (1952) PORTFOLIO selection. The Journal of Finance 7 (1), pp. 77–91. External Links: Document, Link, https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1540-6261.1952.tb01525.x Cited by: §1.
  • T. A. Schmitt, D. Chetalova, R. Schäfer, and T. Guhr (2013) Non-stationarity in financial time series: generic features and tail behavior. Europhysics Letters 103 (5), pp. 58003. Cited by: §1.
  • S. Shah et al. (2022) Decision-focused learning without decision-making: learning locally optimized decision losses. In Advances in Neural Information Processing Systems, Vol. 35, pp. 1320–1332. Cited by: §2.2.
  • W. F. Sharpe (1966) Mutual fund performance. The Journal of business 39 (1), pp. 119–138. Cited by: §1, §2.1, §3.1.
  • M. Woodside-Oriakhi (2011) Portfolio optimisation with transaction cost. Ph.D. Thesis, Brunel University, School of Information Systems, Computing and Mathematics. Cited by: §1, §2.1.

Appendix A Additional Proofs

The following proofs are included to make the paper self-contained. They follow the geometric Sharpe ratio arguments of Kim and Lee (2016) and the OSCAR derivation of Bae et al. (2025), with notation adapted to the present paper.

A.1 Proof of Proposition 3.2

Let w=w^w^{*}=\hat{w} denote the tangent portfolio. First note that the tangent portfolio is given by

w=argmaxwnSR(wμ,Σ)=Σ1μ,w^{*}=\operatorname*{arg\,max}_{w\in\mathbb{R}^{n}}\mathrm{SR}(w\mid\mu,\Sigma)=\Sigma^{-1}\mu,

up to a positive scaling factor, and the maximum Sharpe ratio is

SR(wμ,Σ)\displaystyle\mathrm{SR}(w^{*}\mid\mu,\Sigma) =μwwΣw\displaystyle=\frac{\mu^{\top}w^{*}}{\sqrt{w^{*\top}\Sigma w^{*}}}
=μ(Σ1μ)μΣ1ΣΣ1μ\displaystyle=\frac{\mu^{\top}(\Sigma^{-1}\mu)}{\sqrt{\mu^{\top}\Sigma^{-1}\Sigma\Sigma^{-1}\mu}}
=μΣ1μμΣ1μ\displaystyle=\frac{\mu^{\top}\Sigma^{-1}\mu}{\sqrt{\mu^{\top}\Sigma^{-1}\mu}}
=μΣ1μ.\displaystyle=\sqrt{\mu^{\top}\Sigma^{-1}\mu}.

Then,

θ1\displaystyle\theta_{1} =arccos((LΣw1)(LΣw)LΣw12LΣw2)\displaystyle=\arccos\left(\frac{(L_{\Sigma}^{\top}w_{1})^{\top}(L_{\Sigma}^{\top}w^{*})}{\|L_{\Sigma}^{\top}w_{1}\|_{2}\|L_{\Sigma}^{\top}w^{*}\|_{2}}\right)
=arccos(w1LΣLΣw(LΣw1)(LΣw1)(LΣw)(LΣw))\displaystyle=\arccos\left(\frac{w_{1}^{\top}L_{\Sigma}L_{\Sigma}^{\top}w^{*}}{\sqrt{(L_{\Sigma}^{\top}w_{1})^{\top}(L_{\Sigma}^{\top}w_{1})}\sqrt{(L_{\Sigma}^{\top}w^{*})^{\top}(L_{\Sigma}^{\top}w^{*})}}\right)
=arccos(w1Σww1Σw1wΣw)\displaystyle=\arccos\left(\frac{w_{1}^{\top}\Sigma w^{*}}{\sqrt{w_{1}^{\top}\Sigma w_{1}}\sqrt{w^{*\top}\Sigma w^{*}}}\right)
=arccos(w1μw1Σw1μΣ1μ)\displaystyle=\arccos\left(\frac{w_{1}^{\top}\mu}{\sqrt{w_{1}^{\top}\Sigma w_{1}}\sqrt{\mu^{\top}\Sigma^{-1}\mu}}\right)
=arccos(SR(w1μ,Σ)SR(wμ,Σ)),\displaystyle=\arccos\left(\frac{\mathrm{SR}(w_{1}\mid\mu,\Sigma)}{\mathrm{SR}(w^{*}\mid\mu,\Sigma)}\right),

and similarly,

θ2=arccos(SR(w2μ,Σ)SR(wμ,Σ)).\theta_{2}=\arccos\left(\frac{\mathrm{SR}(w_{2}\mid\mu,\Sigma)}{\mathrm{SR}(w^{*}\mid\mu,\Sigma)}\right).

Since arccos(x)\arccos(x) is a decreasing function of xx, we have

θ1θ2if and only ifSR(w1μ,Σ)SR(w2μ,Σ).\theta_{1}\leq\theta_{2}\quad\text{if and only if}\quad\mathrm{SR}(w_{1}\mid\mu,\Sigma)\geq\mathrm{SR}(w_{2}\mid\mu,\Sigma).

This proves the proposition. \square

A.2 Proof of Proposition 3.3

Let

LΣw^=(x1,x2,,xn)n.L_{\Sigma}^{\top}\hat{w}=(x_{1},x_{2},\ldots,x_{n})\in\mathbb{R}^{n}.

Without loss of generality, assume

|x1||x2||xn|.|x_{1}|\geq|x_{2}|\geq\cdots\geq|x_{n}|.

Then, K={1,2,,k}K^{*}=\{1,2,\ldots,k\}.

Since arccos\arccos is a monotonic decreasing function on [0,1][0,1],

argminK𝒦(minwPK(LΣ(n))arccos((LΣw)(LΣw^)LΣw2LΣw^2))\displaystyle\operatorname*{arg\,min}_{K\in\mathcal{K}}\left(\min_{w\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))}\arccos\left(\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w\|_{2}\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)\right)
=argmaxK𝒦(maxwPK(LΣ(n))(LΣw)(LΣw^)LΣw2LΣw^2).\displaystyle=\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\max_{w\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))}\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w\|_{2}\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right).

Let (LΣw^)K(L_{\Sigma}^{\top}\hat{w})_{K} be a projection where the component of LΣw^L_{\Sigma}^{\top}\hat{w} corresponding to the index not included in KK is changed to 0. Then, we have

argmaxK𝒦(maxwPK(LΣ(n))(LΣw)(LΣw^)LΣw2LΣw^2)\displaystyle\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\max_{w\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))}\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})}{\|L_{\Sigma}^{\top}w\|_{2}\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)
=argmaxK𝒦(maxwPK(LΣ(n))(LΣw)(LΣw^)KLΣw2LΣw^2)\displaystyle=\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\max_{w\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))}\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})_{K}}{\|L_{\Sigma}^{\top}w\|_{2}\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)
=argmaxK𝒦(maxwPK(LΣ(n))(LΣw^)K2LΣw^2(LΣw)(LΣw^)KLΣw2(LΣw^)K2)\displaystyle=\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\max_{w\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))}\frac{\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}}{\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\frac{(L_{\Sigma}^{\top}w)^{\top}(L_{\Sigma}^{\top}\hat{w})_{K}}{\|L_{\Sigma}^{\top}w\|_{2}\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}}\right)
=argmaxK𝒦((LΣw^)K2LΣw^2(LΣw^)K(LΣw^)K(LΣw^)K2(LΣw^)K2)\displaystyle=\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\frac{\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}}{\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\frac{(L_{\Sigma}^{\top}\hat{w})_{K}^{\top}(L_{\Sigma}^{\top}\hat{w})_{K}}{\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}}\right)
(w=(LΣ)1(LΣw^)KPK(LΣ(n)))\displaystyle\qquad\left(\because\ w=(L_{\Sigma}^{\top})^{-1}(L_{\Sigma}^{\top}\hat{w})_{K}\in P_{K}(L_{\Sigma}^{\top}(\mathbb{R}^{n}))\right)
=argmaxK𝒦((LΣw^)K2LΣw^2)\displaystyle=\operatorname*{arg\,max}_{K\in\mathcal{K}}\left(\frac{\|(L_{\Sigma}^{\top}\hat{w})_{K}\|_{2}}{\|L_{\Sigma}^{\top}\hat{w}\|_{2}}\right)
=K.\displaystyle=K^{*}.

Thus, K={1,,k}K^{*}=\{1,\ldots,k\} is the optimal solution. \square

Appendix B Experiment Settings Details

B.1 Experimental Setup

The experiments were implemented in Python, using PyTorch for the predictive model and CVXPYlayers for the optimization module (Agrawal and others, 2019), which enabled differentiation through the portfolio optimization step and thus an end-to-end decision-focused learning pipeline. The prediction network consists of two fully connected hidden layers with 512 and 256 neurons, respectively, trained with a learning rate of 0.001 and a mini-batch size of 64. The combined loss uses a weighting parameter α=0.5\alpha=0.5 to balance prediction accuracy and decision quality, which we found to improve training stability and efficiency. In the differentiable top-kk selection layer, the bisection procedure is run for 32 iterations.

Since the covariance matrix is estimated from rolling windows, it can occasionally become rank-deficient or numerically ill-conditioned. To ensure positive semidefiniteness and stable Cholesky factorization, we apply diagonal shrinkage to each rolling covariance matrix by shrinking it toward a scaled identity matrix, followed by a small eigenvalue-based jitter when necessary. Specifically, for each rolling covariance estimate Σ^t\hat{\Sigma}_{t}, we use

Σ~t=(1λ)Σ^t+λtr(Σ^t)nI,\tilde{\Sigma}_{t}=(1-\lambda)\hat{\Sigma}_{t}+\lambda\frac{\mathrm{tr}(\hat{\Sigma}_{t})}{n}I,

with λ=0.10\lambda=0.10, and add a small diagonal jitter if needed to guarantee a valid Cholesky factorization. In addition, because short selling is allowed in the portfolio optimization layer, the learned portfolio weights can exhibit extreme fluctuations during training. To mitigate this numerical instability, we add a small offset to the QCQP scaling variable cc when recovering the portfolio weights. All experiments were carried out on a machine equipped with an Intel Xeon Silver 4310 CPU (@2.10GHz) and an NVIDIA RTX A6000 GPU with 48GB of memory, and repeated over 5 random seeds with mean and standard deviation reported, providing sufficient computational resources to train the model and solve the embedded optimization problems.

B.2 Details of the SD-relaxation baseline

Kim and others (2016) relax the kk-sparse Sharpe ratio maximization by lifting the weight vector to a positive semidefinite matrix variable Y0Y\succeq 0 (a surrogate of wwww^{\top}). With M:=μμM:=\mu\mu^{\top}, the squared numerator becomes a linear trace objective Tr(MY)\mathrm{Tr}(MY), while the risk normalization can be enforced by Tr(ΣY)=1\mathrm{Tr}(\Sigma Y)=1. The auxiliary scalar z=Tr(Y)z=\mathrm{Tr}(Y) captures the scale of the lifted variable, and sparsity is imposed via the convex surrogate 1|Y|1kz1^{\top}|Y|1\leq kz (originating from w12kw22\|w\|_{1}^{2}\leq k\|w\|_{2}^{2} for kk-sparse vectors). This yields the following tractable SDP:

maxY,z\displaystyle\max_{Y,z} Tr(MY)\displaystyle\mathrm{Tr}(MY)
s.t. Tr(Y)=z\displaystyle\mathrm{Tr}(Y)=z
𝟏|Y| 1kz\displaystyle\mathbf{1}^{\top}|Y|\mathbf{1}\leq kz
Tr(ΣY)=1\displaystyle\mathrm{Tr}(\Sigma Y)=1
Y0.\displaystyle Y\succeq 0.

Since this optimization does not strictly enforce the target cardinality, a single run can yield a portfolio whose realized number of selected assets differs from our proposed framework. To ensure a fair comparison, we repeat the SD-relaxation baseline experiment while adjusting the sparsity parameter used by the baseline until the obtained portfolio attains the same realized cardinality as our proposed method. This procedure may correspond to using a looser effective cardinality level than the nominal kk in the baseline formulation, but it aligns the final number of selected assets across methods.

B.3 Details of the mSSRM-PGA baseline

Lin et al. (2024) solve the mm-sparse Sharpe ratio maximization via a projected gradient (PGA) scheme that performs gradient ascent on the Sharpe ratio objective while enforcing sparsity at every step:

maxwμ^wwΣws.t.w0k.\max_{w}\ \frac{\hat{\mu}^{\top}w}{\sqrt{w^{\top}\Sigma w}}\quad\text{s.t.}\quad\|w\|_{0}\leq k. (15)

Starting from an initialization w(0)w^{(0)}, the iterate is updated by a gradient step followed by a hard-thresholding projection onto the top-kk support:

w(t+1)=Πk(w(t)+ηSR(w(t)))w^{(t+1)}=\Pi_{k}\!\Bigl(w^{(t)}+\eta\,\nabla\mathrm{SR}\bigl(w^{(t)}\bigr)\Bigr) (16)

where Πk()\Pi_{k}(\cdot) keeps the kk largest entries in magnitude and sets the rest to zero.

Appendix C Additional Experiments and Results

C.1 α\alpha Sensitivity

In the main experiments, we use the mixed training objective

Task=αDFL+(1α)MSE,\mathcal{L}_{\mathrm{Task}}=\alpha\mathcal{L}_{\mathrm{DFL}}+(1-\alpha)\mathcal{L}_{\mathrm{MSE}}, (17)

with α=0.5\alpha=0.5 as a default setting. Here, the MSE term is not introduced as a new loss function or as a separate methodological contribution. Rather, it is the standard prediction loss used as an auxiliary supervised signal to stabilize the decision-focused training procedure. Thus, the role of the mixed objective is not to claim a novel loss design, but to provide a stable default training formulation for the proposed differentiable sparse portfolio optimization pipeline.

This choice is motivated by the fact that pure decision-focused learning can suffer from weak, noisy, or locally unstable gradients. In our setting, this issue can be more pronounced because the downstream pipeline contains both a differentiable sparse-selection step and a convex re-optimization layer. As a result, the decision loss may provide gradients that are small in magnitude or poorly informative in some regions of the training landscape. By contrast, the MSE term provides a direct predictive supervision signal on the expected returns. Recent studies on prediction-loss-guided decision-focused learning provide a related geometric motivation. In particular, Jeon et al. (2025) analyze the Hessian eigenvalue density of prediction, decision, and mixed losses, and show that the eigenvalues of the decision loss are highly concentrated near zero, indicating a largely flat decision-loss landscape. In contrast, the prediction loss exhibits a broader eigenvalue spectrum, including negative eigenvalues and several larger positive eigenvalues, while the convex combination of prediction and decision losses yields a more balanced spectrum. This suggests that the prediction loss can enrich the curvature and gradient signal of decision-focused objectives, especially when the pure decision loss provides weak or unstable gradients. Therefore, the mixed objective is used as a practical compromise that preserves decision-level alignment while improving optimization stability.

To examine the effect of α\alpha, we conduct a small case study on EuroStoxx50. We vary α{0,0.1,0.5,0.9,1.0}\alpha\in\{0,0.1,0.5,0.9,1.0\} and evaluate three cardinality levels, ρ{10%,15%,20%}\rho\in\{10\%,15\%,20\%\}. Each setting is trained with five random seeds, using the same data split, model architecture, covariance estimation procedure, and optimization pipeline as in the main experiments. The case α=0\alpha=0 corresponds to pure prediction-focused training with MSE loss, whereas α=1\alpha=1 corresponds to pure decision-focused training.

Table 2: α\alpha sensitivity case study on EuroStoxx50. Values are out-of-sample Sharpe ratios, reported as mean ±\pm standard deviation.
α\alpha ρ=10%\rho=10\% ρ=15%\rho=15\% ρ=20%\rho=20\%
0.0 0.809±0.0250.809\pm 0.025 0.827±0.0230.827\pm 0.023 0.841±0.0200.841\pm 0.020
0.1 0.826±0.0250.826\pm 0.025 0.852±0.0240.852\pm 0.024 0.862±0.0130.862\pm 0.013
0.5 0.955±0.0140.955\pm 0.014 0.972±0.0160.972\pm 0.016 0.983±0.0160.983\pm 0.016
0.9 1.041±0.0811.041\pm 0.081 1.084±0.0831.084\pm 0.083 1.140±0.1541.140\pm 0.154
1.0 1.165±0.1061.165\pm 0.106 1.056±0.1251.056\pm 0.125 0.940±0.0970.940\pm 0.097

Table 2 shows that the choice of α\alpha has a noticeable effect on performance. Very small values of α\alpha, such as α=0\alpha=0 and α=0.1\alpha=0.1, are dominated by the MSE term and consistently produce lower Sharpe ratios across all cardinality levels. This suggests that prediction accuracy alone is insufficient to fully capture the downstream sparse portfolio objective. As α\alpha increases, the average Sharpe ratio generally improves, indicating the benefit of incorporating the decision-focused objective. However, larger values of α\alpha also lead to noticeably higher variability across seeds. For example, α=0.9\alpha=0.9 achieves the highest average Sharpe ratios for ρ=15%\rho=15\% and ρ=20%\rho=20\%, but its standard deviations are substantially larger than those of α=0.5\alpha=0.5. Similarly, the pure DFL setting α=1\alpha=1 achieves the best average performance at ρ=10%\rho=10\%, but its performance becomes less consistent as the cardinality level increases, and it underperforms α=0.9\alpha=0.9 at ρ=15%\rho=15\% and both mixed settings at ρ=20%\rho=20\%.

Overall, these results suggest that larger decision-focused weights can improve average decision quality, but may also make training more sensitive to random initialization and mini-batch sampling. In contrast, α=0.5\alpha=0.5 provides a stable performance-variance trade-off: it consistently improves over the MSE-dominated settings while maintaining the smallest standard deviations across all cardinality levels. Therefore, we use α=0.5\alpha=0.5 as a stable default rather than a validation-tuned optimum. More broadly, the gains should be interpreted as coming from the full mixed training formulation, rather than from the decision-focused loss term in isolation.

C.2 Additional Risk Metrics

The main experiments focus on the out-of-sample Sharpe ratio because our downstream objective is sparse Sharpe ratio maximization. However, the Sharpe ratio alone does not fully characterize the practical risk profile of the learned portfolios. In particular, it does not directly measure downside risk or the severity of cumulative losses over the investment horizon. To provide an additional diagnostic, we report Maximum Drawdown (MDD) for the learned portfolios.

Since our current formulation allows short-selling, the learned portfolios may take both long and short positions. Therefore, we compare DFL and PFL under the same OSCAR-based portfolio construction pipeline and examine whether decision-focused training leads to portfolios with a larger downside-risk profile. For each market and cardinality level, we report the MDD evaluated on the test period.

Table 3 shows that although DFL improves the downstream Sharpe ratio objective in the main experiments, it often leads to larger MDD values than PFL. This suggests that the DFL portfolios can be more aggressive under the current short-selling-allowed formulation. Therefore, the higher Sharpe ratios of DFL should be interpreted together with its increased drawdown risk. Overall, this analysis highlights an important limitation of the current formulation. Our contribution is primarily methodological: we show that decision-focused learning can be successfully applied to cardinality-constrained sparse Sharpe ratio optimization. Incorporating more practical constraints, such as long-only positions, leverage limits, turnover penalties, or margin constraints, remains an important direction for future work.

Table 3: Additional MDD metrics across four equity markets. MDD is evaluated on the test period. Values are reported as mean ±\pm standard deviation over five random seeds.
Market Method ρ=10%\rho=10\% ρ=15%\rho=15\% ρ=20%\rho=20\%
EuroStoxx50 PFL 0.474±0.2570.474\pm 0.257 0.340±0.0790.340\pm 0.079 0.317±0.1130.317\pm 0.113
DFL 0.310±0.1050.310\pm 0.105 0.403±0.1090.403\pm 0.109 0.390±0.0550.390\pm 0.055
FTSE100 PFL 0.497±0.0950.497\pm 0.095 0.495±0.0990.495\pm 0.099 0.497±0.1020.497\pm 0.102
DFL 0.710±0.1000.710\pm 0.100 0.605±0.2090.605\pm 0.209 0.607±0.1290.607\pm 0.129
KOSPI200 PFL 0.775±0.1090.775\pm 0.109 0.790±0.1210.790\pm 0.121 0.796±0.1280.796\pm 0.128
DFL 0.952±0.0210.952\pm 0.021 0.945±0.0330.945\pm 0.033 0.925±0.0550.925\pm 0.055
Nikkei225 PFL 0.484±0.1920.484\pm 0.192 0.528±0.1990.528\pm 0.199 0.558±0.2020.558\pm 0.202
DFL 0.543±0.0950.543\pm 0.095 0.559±0.1000.559\pm 0.100 0.599±0.1360.599\pm 0.136

C.3 Additional Time-series Results

We provide three additional equity markets (EuroStoxx50, KOSPI200, and Nikkei225) comparisons across three cardinality levels 10%10\%, 15%15\%, and 20%20\% in Figure 3, 4, and 5, reporting the portfolio return at each time step for our DFL framework and PFL baselines: OSCAR and mSSRM-PGA. The SD-relaxation baseline shows markedly higher volatility and occasional extreme swings depending on training, which is also reflected in the larger variability summarized in Table 1. Due to this excessive instability, we exclude SD-relaxation from the remaining three markets reported in the subsequent appendix results. Notably, the performance gap tends to widen as kk increases, suggesting that our decision-focused training becomes particularly effective when the allocation space is less restrictive, and the model can better exploit improved mean estimates for downstream risk-adjusted performance.

Refer to captionRefer to captionRefer to caption
Figure 3: Portfolio return time-series of EuroStoxx50 on the test set for ρ=10%\rho=10\%, 15%15\%, and 20%20\%. We report our DFL framework and PFL baselines: OSCAR and mSSRM-PGA.
Refer to captionRefer to captionRefer to caption
Figure 4: Portfolio return time-series of KOSPI200 on the test set for ρ=10%\rho=10\%, 15%15\%, and 20%20\%. We report our DFL framework and PFL baselines: OSCAR and mSSRM-PGA.
Refer to captionRefer to captionRefer to caption
Figure 5: Portfolio return time-series of Nikkei225 on the test set for ρ=10%\rho=10\%, 15%15\%, and 20%20\%. We report our DFL framework and PFL baselines: OSCAR and mSSRM-PGA.