$^1$Departamento de Ciência da Computação,

Universidade Federal de Minas Gerais,

Belo Horizonte, MG 31270-010, Brasil

Portfolio optimisation is widely acknowledged for its significance in investment decision-making. Yet, existing methodologies face several limitations, among them converting optimal theoretical portfolios into real investment is not always straightforward. Several classes of exogenous (real-world) constraints have been proposed in literature with the intent of reducing the gap between theory and practice, which have worked to an extent.

In this paper, we propose an optimisation-based framework which attempts to further reduce this gap. We have the explicit intention of producing portfolios that can be immediately converted into financial holdings. Our proposed framework is generic in the sense that it can be used in conjunction with any portfolio selection model, and consists of splitting the portfolio selection problem into two-stages. The main motivation behind this approach is in enabling automated investing with minimal human intervention, and thus the framework was built in such a way that real-world market features can be incorporated with relative ease. Among the novel contributions of this paper, this is the first work, to the best of our knowledge, to combine futures contracts and equities in a single framework, and also the first to consider borrowing costs in short positions.

We present extensive computational results to illustrate the applicability of our approach and to evaluate its overall quality. Among these experiments, we observed that alternatives from literature are susceptible to numerical errors, whereas our approach effectively mitigates this issue.

Keywords: portfolio optimisation, exogenous constraints, transaction lots, futures contracts, quantitative finance

§ INTRODUCTION

Portfolio selection is at the core of quantitative finance and spans decades of theoretical and applied research. Its roots stem from the seminal paper by [24], who introduced the modern portfolio theory (MPT), a mathematical framework for selecting portfolios based on a trade-off between expected return and risk. MPT constitutes a staple of financial practice with countless investment funds relying on it in one way or another. Yet, MPT and subsequent classical portfolio selection models tend to be sensitive to changes in the input data and often construct portfolios that are insufficiently diversified, and whose observed out-of-sample risk frequently surpasses the expected. To address these shortcomings, a body of literature has focused on model extensions, i.e., alternative portfolio selection criteria and improved data estimation.

Among these extensions is the adoption of exogenous (real-world) constraints. They help not only in shaping optimal portfolios in the hope of reducing out-of-sample risk, but also in building more “practical” portfolios, in the sense that one could more easily convert theoretical weights into real investment.

Despite the extensive literature on exogenous constraints, there are still disparities between theory and practice. As we discuss in this paper, it is not always trivial to convert optimal decisions into actual holdings when accounting for all particularities of real-world trading. In this paper, we build on top of the current literature in the hope of further reducing this gap. We do this by proposing a two-stage optimisation framework for solving the general portfolio selection problem. The two-stage approach takes into account several realistic features and produces, as output, suggested trades to be executed. Our framework is flexible enough so as to easily incorporate new relevant features that have been left out.

The main motivation for this work comes from difficulties observed when establishing low-frequency quantitative funds. In a quantitative fund, we assume that the entire fund management is controlled by algorithms, with minimal human intervention. In such funds, the decision process is ideally integrated with the actual purchase and sales of assets. More specifically, the theoretical portfolio composition must be converted into holdings that may require integral lots, may incur different types of costs and may make use of non-trivial features such as leverage and margin accounts. Our two-stage approach attempts to integrate these features into a single framework, and its flexibility makes it easier to adapt to different market conditions. It also has the added benefit of allowing more realistic simulation (backtesting) of potential candidate financial strategies.

Constructing portfolios in two steps offers advantages in terms of flexibility and computational efficiency. In the first stage, decision variables represent portfolio weights and, in the second stage, they represent the number of shares to be held. This allows a wider range of constraints to be considered without adding too much complexity to a single model. As an example, we show how the framework can take into account two different asset types, namely future contracts and equities, which comprise some of the most liquid financial instruments in markets worldwide. With regards to computational efficiency, the second stage is restricted to assets for which trading might occur, which often does not include the entire asset universe under consideration.

In the second stage we convert portfolio weights into holdings by considering, among other features, lots, transaction costs, margin accounts and borrowing costs in short positions. Lots represent minimum integral units of an asset that can be purchased in a single transaction. Assets for which lots apply can only be held in positions that are multiples of a lot. The introduction of lots implies that not all available cash can be invested due to the integral restrictions. Moreover, lots are inherently intertwined with transaction costs - a feasible portfolio division into valid integral lots of different assets depends directly on the portfolio value after the trades take place, i.e. after all costs are discounted.

In literature, optimal weights, lots and transaction costs have been generally considered as part of a single model, which requires both sets of decision variables described above. One major issue we observed empirically is that, when sums involved are large, these models suffer from numerical inaccuracies due to combining very large and very small coefficients. We have also observed other issues with single stage approaches, such as (i) having to impose arbitrary limits on the investable cash, (ii) having to solve nonlinear nonconvex models when rebalances are accounted for or (iii) having to balance conflicting objectives, such as, on top of the portfolio optimal criteria, investing as much of the available capital as possible while also spending as little as possible in transaction costs.

In our approach, we deal with these issues separately by employing a goal-programming framework: in the second stage we minimise both the costs involved and the deviation between real and desired portfolio weights. We propose a way to handle the conflict in mixing both objectives. With such an approach, the issues mentioned above are nonexistent.

One may argue that, if the sums involved are large, then none of this is necessary as simple rounding heuristics to the nearest lot are sufficient. Moreover, some financial services providers offer the possibility to purchase fractional shares (such as Robinhood[<https://robinhood.com/us/en/support/articles/fractional-shares/>, last visited $7^{\text{th}}$ May 2024.]). In the case of the latter, however, not every investment fund or individual investor worldwide has access to such platforms, and the platforms themselves must handle internally the complexity of lots in order to provide those services. In the case of the former, starter funds or individual investors do not necessarily have the advantage of large sums, and thus rounding heuristics are more likely to produce undesirable portfolios. In this case inexact solutions may act as an extra barrier to growth within competitive markets.

As an example, the E-Mini S&P500 futures contracts, one of the most liquid financial instruments in the U.S. market, was traded on April 2024 at around US$5,000, and the minimum purchasable contract unit is 50[<https://www.cmegroup.com/markets/equities/sp/e-mini-sandp500.contractSpecs.html>, last visited $7^{\text{th}}$ May 2024.]. If a fund wishes to purchase one contract with 2$\times$ leverage, then a deposit of US$125,000 in a margin account is required. A US$1 million fund which wants to invest 6-7% of its capital in S&P500 must choose between an actual holding of 0 or 12.5%.

Compared to the standard literature in lots, our two-stage approach has a potential disadvantage: the optimal portfolio is chosen in the expanded feasible set of non-integral portfolios. [2] has shown that, in general, the assets selected by the optimal solution of a model that considers lots may not be included in the set of assets selected if lots are not taken into account. Nevertheless, within the framework there is no incompatibility in employing a first stage portfolio selection model that does account for lots, retrieving the optimal lot-constrained weights and then feeding them into the second stage, where other particularities, potentially not previously considered, might be taken into account.

We present extensive computational experiments to validate our proposed framework. Since the main motivation behind our approach is in converting theory to practice, our main focus is in assessing how well the second stage does so. We assess it with regards to (i) how well it approximates theoretical solutions, (ii) the computational effort required to solve it and (iii) how it handles the conflict of minimising deviation from desired proportions and reducing the transaction costs spent. We compare our approach to that of [35], which includes holdings and proportions in a single stage, making it prone to numerical inaccuracies. We also present two case studies, where in the second we show a potential benefit of expanding an asset universe of stocks to include leveraged futures contracts.

The remainder of this paper is organised as follows. In Section <ref>, we present our literature review, where we discuss models that include lots and transaction costs in depth. In Section <ref>, we discuss aspect of futures contracts that differentiate them from equities. In Sections <ref> and <ref>, we present our framework, with the former introducing the first stage and the latter introducing the second stage. In Section <ref> we present our computational experiments. In Section <ref> we discuss some limitations and provide some insights regarding our two-stage approach and, finally, in Section <ref> we present our concluding remarks.

§ LITERATURE REVIEW

Optimal theoretical portfolios are likely to violate real-world “hard” constraints such as market rules, regulatory requirements and internal investment policies, and thus may be subject to risks incurred by little diversification or excessive exposure. The final goal of asset allocation models is to build portfolios that are applicable in practice, and exogenous constraints have historically helped bridging this gap. Some constraints help prevent undesirable risk properties while others are required in order to simulate real world investment requirements. In this section, we refer to several papers that have considered many of these constraints. For other papers that offer detailed reviews, we refer the reader to [22, 23, 16].

[27] was the first work, to the best of our knowledge, to consider real-world constraints in the context of the MPT. The author considered short sales, transaction costs, liquidity and taxes. [1] proposed minimising both variance and transaction costs in the same objective function. Turnover constraints were first introduced and studied in MPT, in the context of portfolio revision (rebalancing), by [30]. Other early relevant works are those of [29, 26].

[31] built on the work of [29] and proposed a linear-programming formulation for minimising the semi-$L_1$ dispersion measure, subject to several classes of exogenous constraints. The authors included lots, fixed and variable transaction costs, upper exposure bounds on individual assets and portfolio cardinality. Up to that moment, the vast majority of works in portfolio selection models had portfolio proportions as their decision variables. Here, the authors used portfolio holdings instead. Following their notation, we refer to the former as a relative model, and the latter as an absolute model.

[21] proposed a similar model in which transaction costs were incorporated as discounts in the assets expected returns. The authors showed the problem to be NP-Hard. [15] considered a similar model with fixed costs, applicable if the transaction value is above a lower bound. [9] introduced transaction costs in the form of a piecewise linear function, and [20] included a constraint to model capital-gain taxation and proposed a specialised exact algorithm to solve the problem. [2] compared CVaR and MAD models in the presence of these constraints, and [11] extended the model to consider portfolio rebalancing and transaction costs, but without lots.

[6] proposed a two-stage approach where portfolio weights are selected with any portfolio selection model and then a Mixed-Integer Programming (MIP) problem is solved to approximate the target portfolio as well as possible. The authors tried to balance transaction costs, liquidity (both through piecewise linear convex functions), number of transactions, closeness to the target portfolio and high return, with many objectives combined into a single objective function. They also consider a rebalancing scenario, where an existing portfolio is currently held and must be converted into a new portfolio. They adopt a somewhat similar two-stage approach to the one we propose here, but with key differences: their second stage employs portfolio proportions as decision variables, so the same as the first stage. They also combine objectives that we consider to be first-stage decisions rather than second stage, such as constraining sectors or cardinality. In summary their second stage has goals that fit in both our first and second stages, which is different from our proposal of looking into the practical aspect of generating tradable portfolios. Hence, we believe the two approaches to not be directly comparable, but we discuss it further in Section <ref>.

[8] developed heuristics for the cardinality-constrained portfolio selection problem, with upper exposure bounds, class constraints and buy-in thresholds. Class constraints enforce minimum and maximum exposure levels in subsets of assets. Buy-in thresholds help prevent (very) small positions by ensuring minimum holding levels.
[4] attempt to solve the Markowitz problem with cardinality constraints and buy-in thresholds without the use of integer variables, with non-convex constraints instead.

[14] and [25] proposed a model that is both relative and absolute, combining the works of [8] and [21]. The authors also consider portfolio rebalancing, with a limit on the number of trades that can be executed.

[13] were the first to discuss the realistic aspects of short-selling, in contrast to the assumption of unlimited shorting often considered. The authors proposed separating decision variables into two sets, one for long and another for short positions. [17] solved the Markowitz quadratic model with the presence of short limits as well as special assets for risk-free lending and borrowing. In their formulation, each asset was represented by four decision variables, two representing proportions and two indicating whether any of that asset was held. [33] employs a similar approach to model long-short constraints. The authors consider constraints on Regulation T, which prevents the proceedings of short sales from being used to purchase long positions in other assets. Here, we adopt a similar approach to [13] and [33].

[35] proposed a model that is both relative and absolute. The authors considered transaction costs, buy-in thresholds, exposure bounds, cardinality constraints and portfolio rebalancing, and the model can be easily extended to incorporate lots. In order to linearise their model, they define a limit on how much can be spent on transaction costs. [32] adopted a similar approach and raised the matter of unavoidable transaction costs, when assets held in the current portfolio must be liquidated. They separate the proposed model into multiple stages, where the third stage explicitly attempts to minimise transaction costs spent. Our second stage is an extension of their third stage.

What none of the papers above have discussed is the practicality of their approach, meaning the difficulties each model would face when implemented in practice. Here we have an explicit goal of producing portfolios that can be integrated with trading systems with little to none human intervention, and with minimal divergence between observed and simulated performance.

§.§ Transaction costs

When accounting for transaction costs, many papers do so with the goal of preventing the underestimation of risk or the overestimation of return. [21] incorporates the costs directly into asset prices, and hence do not explicitly include them in the corresponding portfolio selection model. Similarly, [18] deduct costs directly from asset returns. [15] adds fixed transaction costs as a penalty in the expected return constraint. [9], [20] and [2] adopt a similar extended approach with fractional costs and a capital-gains tax. [11] discount transaction costs in the CVaR calculation. These discounts are useful to avoid underestimating the balance between return and risk.

While important from a theoretical perspective, from a practical point of view, however, expressing transaction costs as discounts is insufficient to produce tradable portfolios. Suggested holdings would ideally match desired portfolio proportions based on the portfolio value after trading occurs, i.e. after costs are discounted. In this case transaction costs must be expressed as actual financial discounts, which requires an absolute or mixed model. This is especially important when lots are also considered, as discussed in the next section.

In our two-stage approach, we only consider costs in this manner, in the second stage. The main goal of including them is in correctly anticipating what the portfolio mark-to-market value will be after trading takes place, ensuring that the suggested holdings are both purchasable and obtainable at minimal cost. Despite that, it is possible to include costs as discounts in the first stage, such as in the papers cited above, without any conflict with the second stage decision.

There are different ways to model transaction costs as discounts in the future portfolio value. [23] summarises them as (i) fixed costs, (ii) variable costs, represented as a proportion of the trade value and (iii) convex or concave piecewise linear costs, which can be employed in the simulation of taxes and liquidity. In our second stage we only include variable costs and borrowing costs (charged when taking short positions and not yet considered in literature). In our experience these represents cost functions that are always charged, while other functions are either less common or can be eliminated by negotiating directly with brokers. Nevertheless, the second stage can also be extended to include the other cost functions (we leave that as future work).

§.§ Lots

When accounted for in portfolio selection models, lots and transaction costs reshape and limit the feasible region of optimal portfolios. [2] showed that optimal solutions to problems with and without lots may include different sets of assets. Portfolio weights are sufficient to accurately impose many real-world constraints, but lots on the other hand require assets to be represented by their purchasable units rather than their investment proportions. Additionally, converting portfolio proportions into integral holdings requires knowledge of the future value of the investment, after all costs are discounted. Depending on how the problem is modelled, this requirement results in some undesirable issues, as highlighted below.

The first formulation containing lots was that of [31], which also includes variable and fixed transaction costs. Let $N$ be the set of assets in which we may invest. For asset $i \in N$, let $V_i$ be the current price of a single lot, and let $f_i$ and $g_i$ be the fractional and fixed costs associated with trading asset $i$. Let $C$ be the available capital to invest. Let $x_i$ be an integer decision variable representing the number of lots to be purchased of asset $i$, and let $z_i$ be a binary decision variable indicating whether any amount of asset $i$ is to be purchased in the portfolio. In their absolute formulation, [31] incorporated the following constraint:

\begin{align}
\sum_{i \in N} (1 + f_i) V_i x_i + g_i z_i & = C
\label{eqlit1}
\end{align}

In Equation (<ref>), the term $f_i V_i x_i$ in Equation (<ref>) represents the fractional costs associated with starting a new position $x_i$ from holdings in cash, which means that Equation (<ref>) only works if no current assets are held in the portfolio, i.e. the available capital is entirely in cash. Since it is unlikely that there will be a combination of integral lots of different assets satisfying Equation (<ref>) exactly, [31] proposed a feasible interval for $C$:

\begin{align}
C_0 \leq \sum_{i \in N} (1 + f_i) V_i x_i + g_i z_i & \leq C_1
\label{eqlit2}
\end{align}

where $C_0$ and $C_1$ are arbitrary lower and upper bounds on the value of the portfolio after trading. In particular, the presence of the lower bound $C_0$ can be conflicting with the main objective. In fact, without the lower bound the optimisation of a risk function tends to invest the minimum amount of capital that guarantees the required expected return of the investment. [23].

[21] showed that if $C_0 \neq C_1$, the portfolio selection problem is NP-Hard. Transaction costs, however, were incorporated in this paper as discounts in the assets expected returns as opposed to [31], where costs are discounted from $C$. [15] showed that a portfolio selection model with variable and fixed costs, represented by Equation (<ref>), is NP-hard even if no lots are considered (if $x_i$ can be fractional). [20] used a similar approach, but with lump taxes instead of variable transaction costs. The lower bound $C_0$ was not included, and the incentive to be as close as possible to $C$ comes from enforcing the minimum expected return. [18] also employed a similar approach, without $C_0$, and with a more generic concave nondecreasing function modelling transaction costs and  an upper bound $C_1 - C > 0$ on borrowed cash. [2] and [3] used a similar model as [20] in order to optimise CVaR with real features, but including $C_0$.

As opposed to [31], all of the above papers ignore the discounts of transaction costs on the available capital. Let $\text{TC}$ be the total transaction costs required to purchase the entire portfolio $(x_1, \dots, x_N)$. In such cases it may happen that the portfolio produced may not be purchasable as it is possible that $\sum_{i \in N} V_i x_i \geq C_0 > C - \text{TC}$, so $C_0$ must be well defined.

[14] and [25] were the first to model lots in a relative formulation, but they did not include transaction costs. The fraction of the total portfolio value representing a lot of asset $i$ is given by $l_i$. Here $\gamma_i$ is the number of lots held and $l_i \gamma_i$ represents the proportion of the portfolio to be invested in asset $i$ as a multiple of $l_i$. As the budget requirement may be unattainable the authors added the following constraint:

\begin{align}
\sum_{i \in N} l_i \gamma_i + d^- - d^+ & = 1
\label{eqlit7}
\end{align}

where $d^-$ and $d^+$ are downward and upward deviations that are penalised in the objective function. Such penalty may not be easily applicable depending on the portfolio optimisation criteria. As transaction costs are not considered, the estimation of $l_i$ is based on an arbitrary value as the total portfolio value after trading is unknown. [14] also investigated the portfolio rebalancing problem with an alternative absolute formulation based on holdings instead of weights, but without accounting for lots nor transaction costs.

[5] extended the relative formulation with lots to explicitly include piecewise-constant fixed transaction costs and dividends. The objective function is amended to include transaction costs and dividends but, on the other hand, the deviation of the budget constraint is not considered.

[19] proposed a mixed (absolute and relative) formulation with lots, but without transaction costs. Let $w_i$ be the (unknown) proportion to be invested in asset $i$. The authors modelled the problem with:

\begin{align}
\sum_{i \in N} V_i x_i & \leq C \label{eqlit4} \\
w_i & = \frac{V_i x_i}{\sum_{i \in N} V_i x_i} \label{eqlit8}
\end{align}

which produces a difficult nonlinear optimisation model. Due to the integral constraints, part of $C$ may be left uninvested, but this amount is not considered in the formulation.

[7] modelled lots similarly, with the main difference being the introduction of a cash asset $w_c$, representing uninvested capital. Redefining $l_i$ as the number of shares in a lot of asset $i$, the authors proposed the following constraints:

\begin{align}
w_i & = \frac{V_i \gamma_i l_i}{C} \label{eqlit9} \\
w_c + \sum_{i \in N} w_i & =  1 \label{eqlit10}
\end{align}

As $C$ is a given budget parameter, the constraints above are linear. However, had transaction costs been included, $C$ would have to be replaced by $C - \text{TC}$, and since $\text{TC}$ is only known after optimisation, the problem would have become nonlinear. By omitting transaction costs, the optimal solution could yield a portfolio $(l_1 \gamma_1, \dots, l_N \gamma_N)$ whose cumulative financial value is greater than $C - \text{TC}$.

[4] tackled the original Markowitz quadratic programming formulation with a relative and absolute formulation that included buy-in thresholds and lots. The authors did not include transaction costs and remodelled the problem with nonlinear nonconvex constraints. While a specialised algorithm was developed, adapting the formulation to include other features is not straightforward.

Finally, the formulation that most closely produces implementable investment decisions is that of [35]. Their model takes into account fixed and variable costs as well as current portfolio holdings, and can be easily extended to include lots.

Let $X_i$ be the current holdings in asset $i$, with the total portfolio value prior to trading defined as $\sum_{i \in N} V_i X_i + C$. The authors define variable and fixed costs $f^b_i$ and $g^b_i$ associated with buying shares of $i$, and, accordingly, $f^s_i$ and $g^s_i$ associated with selling shares of $i$. Variable costs $f^b_i$ and $f^s_i$ are defined as financial values rather than proportions. They also defined additional decision variables $y^b_i$ and $y^s_i$ with the number of units of $i$ bought and sold respectively, and binary variables $\alpha^b_i$ and $\alpha^s_i$ on whether any amount of $i$ is bought/sold. Variables $\alpha^b_i$ and $y^b_i$ as well as $\alpha^s_i$ and $y^s_i$ are linked with the use of nonnegative lower and upper bounds on the amount of shares that can be sold/purchased at a given rebalance.

Let $\text{TC} = \sum_{i \in N} \left( f^b_i y^b_i + f^s_i y^s_i + g^b_i \alpha^b_i + g^s_i \alpha^s_i \right)$ be the total transaction costs spent in a rebalance. The constraints pertaining portfolio rebalancing and transaction costs are given by:

\begin{align}
\alpha^b_i + \alpha^s_i & \leq 1 \label{eqlit11}\\
X_i + y^b_i - y^s_i & = x_i   & \forall i \in N \label{eqlit12}\\
\sum_{i \in N} V_i X_i + C & = \sum_{i \in N} V_i x_i + \text{TC} \label{eqlit13}\\
w_i & = \frac{V_i x_i}{\sum_{k \in N} V_i X_i + C}  & \forall i \in N \label{eqlit14} \\
w^{\text{tc}} & = \frac{\text{TC}}{\sum_{k \in N} V_i X_i + C} \label{eqlit15}
\end{align}

In Equation (<ref>), a weight $w^{\text{tc}}$ is assigned to the proportion of the original portfolio value spent in transaction costs. By adding this extra variable, Equation  (<ref>) remains linear, but the sum of asset weights is less than one. Constraints (<ref>)-(<ref>) ensure consistency between the portfolio value before and after trading. Incorporating lots can be achieved by defining $x_i$ as integer variables.

Consider that the optimal portfolio is the one that minimises risk. As the authors themselves pointed out, a possible undesired consequence of this approach is that in such cases the formulation has an incentive to increase $w^{\text{tc}}$ and reduce $\sum_{i \in N} w_i$ as an artificial way to reduce risk. Hence, in order to prevent this, the authors impose an arbitrary limit on the amount of transaction costs that can be spent in a rebalance, which may possibly underestimate or overestimate the costs that would be associated with the risk-optimal portfolio of choice. This issue is similar to the one faced by [31] when defining $C_0$. Penalising costs in the objective function could be a way to tackle this problem. It is not clear, however, what an appropriate general penalty function would be considering that several different criteria are possible when choosing optimal portfolios.

An additional issue with mixed models is that they are more subject to imprecisions in floating point calculations. We have observed empirically that the model from [35] is prone to numerical inaccuracies since, if the sums involved are large, portfolio proportions and holdings yield models with coefficients having very different orders of magnitude. This is an issue with any mixed formulation. We empirically faced this issue in Section <ref>.

The difficulties highlighted in this section are, in our view, a strong motivator for our two-stage approach. By having a relative model in the first stage and an absolute model in the second stage, we prevent issues such as numerical inaccuracies and arbitrary limits. On the other hand, the unconstrained (lot-wise) optimal first stage portfolio could have different risk-return properties than the optimal portfolio constrained by lots. This issue is partly mitigated by the goal-programming approach, which attempts to find an implementable portfolio that is as close as possible to the optimal theoretical portfolio. We analyse this issue empirically in Section <ref>. Furthermore, it is still possible to formulate the first stage as any of the single-stage formulations presented in this section, so essentially limiting or eliminating the main issue with the two-stage approach.

§ KEY CONCEPTS OF FUTURES CONTRACTS

An advantage of a clear separation between proportions and holdings in wo stages is in making it easier to incorporate real-world features without adding too much complexity to any single model. Among these features, we propose integrating futures and equities into a single framework.

There are several operational differences between these two types of financial instruments, which need to be dealt with if the goal is in producing tradable portfolios. We refer to equities as assets that are traded in stock markets and which incur tangible ownership when purchased, such as stocks and exchange-traded funds. In the portfolio optimisation literature, a common implicit assumption is that all assets are equities, and to the best of our knowledge these operational differences have not yet been considered. In this section we focus on how to account for these differences in our framework rather than introducing the concept of futures contract. For a comprehensive overview of the mechanics of futures, we refer the reader to [12].

There are three main operational differences when trading futures:

(i) futures contracts have expiration dates,

(ii) purchasing a futures contract does not incur ownership of the underlying assets, but a deposit in a margin account is required as guarantee for fulfilling contractual obligations, irrespective of the party promising to buy (long) or sell (short) the asset,

(iii) positions held are leveraged since required margin accounts are usually a fraction of the underlying contract value.

These differences affect not only the two stages of our approach, but also how data must be prepared.

Since futures expire, the historical time series for any contract is limited to the duration of the contract (from issuance to expiration). Data vendors often provide a rolled or continuous series, one which automatically switches to the next-contract month when the current most-liquid contract expires. The rolled series provides long-term continuity often required by financial decision models that rely on historical data. Also, since the true investment in futures is the amount deposited in the margin account, the returns of the continuous time series must be multiplied by the leverage level to account for the actual returns that would have been observed.

Also, commonly, just before expiration the brokers “cancel out” most contracts by purchasing an equivalent long position for holders of short positions, and likewise by purchasing equivalent short positions for holders of long positions. At this point, if the investor wishes to maintain an exposure to that contract, it is necessary to purchase the next-month contract. This is called a rollover: the investor is forced to liquidate the entire current position and open a new one, which incurs more transaction costs than simply buying/selling the difference between current and desired holdings. This issue is accounted for in our second stage, when weights are converted into holdings.

The second stage links desired proportions to actual financial values invested in each asset. For future contracts, we model this by using the leverage level to relate weights with the amount to be deposited in the margin account. A further issue is that in futures both long and short positions require a cash deposit, as opposed to equities, where shorting does not (theoretically) require any investment upfront, rather creating a debt towards the lender. With regards to portfolio selection, while the portfolio weight associated with a short position in equities is negative, the weight associated with a short position in futures is positive. In practice, identical short and long positions in a futures contract represent the same positive proportion of the total portfolio. The difference lies in how they contribute to the portfolio returns: as the weighted negative and positive leveraged futures returns for short/long positions respectively.

As a general illustration, consider a contract worth $\$10\text{,}000$ in gold. Party  promises to buy $\$10\text{,}000$ from Party  at a later date. Let the required margin deposit be 20% of the contract value for both parties. Both deposit $\$2\text{,}000$ in their respective margin accounts. Suppose that, in the next day, due to gold price variations a new contract is now worth $\$11\text{,}000$. Even though the contract is not expiring today, the brokers transfer the difference from the margin account of  to the margin account of . This way, the margin account of  now has $\$3\text{,}000$ and the margin account of  has now fallen short to $\$1\text{,}000$.

Notice that if the margin account value falls below the minimum required value, the broker issues a margin call. In this case  must then add another $\$1\text{,}200$ in funds to its account to bring it to $\$2\text{,}200$, which is 20% of the current contract value. Likewise,  may optionally withdraw part of its margin account since it is above the required level, and make it available for investment in other assets. In practice, pre-expiry cash settlements occur often, hence, just prior to the second stage, we assume that the margin account in any currently held positions are maintained at the exact required level, with the excess being put into/taken from cash reserves.

Note that A had a $\$1\text{,}000$ profit on a $\$2\text{,}000$ investment, or a 50% return - 5 times the 10% increase in contract value. Accordingly, B had a -50% return. B invested $\$2\text{,}000$ and received $\$1\text{,}000$. If B had decided to short $\$10\text{,}000$ in gold directly, they would have borrowed this amount, sold then at that price and own $-\$10\text{,}000$ to the lender. At the next day, this debt would have grown to $-\$11\text{,}000$. The returns are the same (albeit deleveraged), but the proportion held is negative instead of positive.

The particularities of shorting in futures contracts are dealt with in both first and second stages. In Section <ref>, we show an application of leveraged futures contracts in producing market neutral portfolios with potential for positive return.

§ FIRST STAGE: CHOOSING OPTIMAL PORTFOLIO WEIGHTS

In this section, we present a general standardised framework for relative models that combines equities and futures. The formulation includes a selection of common real-world constraints, all of which can be accurately depicted with portfolio proportions instead of holdings. The goal at this stage is to simply produce a vector of portfolio weights. In the second stage, presented in Section <ref>, we convert these weights into suggested holdings and include features that require an absolute model, such as costs, lots and margin accounts. In the appendix accompanying this paper[Available at <https://github.com/cristianoarbex/portfolioSimulationData>], we present an extended version of the first stage that includes other classes of constraints. We also rewrite the standardised formulation for ratio-based portfolio models.

Let $N$ be the set of $|N|$ assets in which we may invest. We split $N$ into two sets, namely $N_1$ as the set containing all equities and $N_2$ as the set containing all futures contracts (assets that require margin accounts). We have that $N_1, N_2 \subseteq N$ and that $N_1 \cup N_2 = N$. We informally refer to assets in $N_1$ as “equities” and assets in $N_2$ as “futures”.

Let $C$ be the current mark-to-market valuation of the portfolio, and let there also be two optional risk-free assets $\ell, b \in N_1$ in which we may invest. Risk-free asset $\ell$ represents the interest rate obtained when we hold a long position in cash, that is, when we lend money to the bank. Asset $b$ represents the interest rate applied when we hold a short position in cash, that is, when we borrow money from the bank.

$w_i^+ \geq 0, w_i^- \geq 0$     be the proportion of the portfolio held in long/short positions in asset $i \in N$.

$z_i^+, z_i^-$     {  1     if any of asset $i$ is held in long/short positions
0     otherwise  .

Depending on which exogenous constraints are applicable to the problem at hand, binary variables $z^+_i$ and $z^-_i$ are not strictly necessary, although many commercial and open-source solvers automatically detect whether a binary variable can be removed during their presolve phase.

In portfolio selection literature, the proportion invested in asset $i$ is more often represented with a single variable $w_i$, where $w_i > 0$ means a long position and $w_i < 0$ means a short position. A single variable, however, prevents us from modelling certain classes of exogenous constraints, such shorting limits [13, 17] or even short positions in futures.

Let $\rho(\vec{w})$, where $\vec{w} = (w^+_1, w^-_1, \dots, w^+_n, w^-_n)$, be the objective function to be minimised (we assume a minimisation problem without loss of generality). The basic portfolio selection model is given by:

[]min     ρ(w⃗)

subject to     ∑_i ∈N_1 (w^+_i - w^-_i)  +  ∑_i ∈N_2 (w^+_i + w^-_i)    =     1

w^+_i     ≤    Uz^+_i     ∀i ∈N

w^-_i     ≤    Uz^-_i     ∀i ∈N

z^+_i + z^-_i     ≤    1     ∀i ∈N

z^+_i, z^-_i     ∈    𝔹

w^+_i, w^-_i     ≥    0     ∀i ∈N

Constraint (<ref>) is the budget constraint. For equities, the contribution of $w^-_i, i \in N_1$ towards the budget is negative, while for futures the contribution of $w^-_i, i \in N_2$ is positive. Constraints (<ref>)-(<ref>) link variables $\vec{w}$ and $\vec{z}$. We use the $U$ symbol loosely throughout this text to indicate any large enough constant. Constraints (<ref>) ensure that an asset, if picked, cannot be held in both long and short positions at the same time. Constraints (<ref>)-(<ref>) define variable bounds. Depending on the choice of $\rho(\vec{w})$, the specific formulation may require additional variables and constraints (i.e. minimising CVaR).

§.§ Shorting limits in equities

Let $\tau^-$, $\tau^+$ be the minimum and maximum proportions of $C$ allowed in a collection of short positions in equities. In order to enforce such limits, we add the following constraint:

\begin{align}
\tau^- \;\leq\; \sum_{i \in N_1} w^-_i \;& \leq\;  \tau^+ \label{eq8}
\end{align}

With this definition, we replace Constraints (<ref>)-(<ref>) by:

\begin{align}
w^+_i &  \leq \;(1 + \tau^+) z^+_i & \forall i \in N  \label{eq9} \\
w^-_i & \leq \;(1 + \tau^+) z^-_i & \forall i \in N_2  \label{eq10} \\
w^-_i & \leq \;\tau^+ z^-_i & \forall i \in N_1  \label{eq11}
\end{align}

If $\tau^+ > 0$, then it is possible to invest up to $1 + \tau^+$ in long positions.

Several constraints are expressed as limits applicable to individual assets or collections of assets. When shorting is allowed, it is possible to express these limits as either absolute or relative (with regards to the total long/short exposure). Absolute limits make it possible to include buy-in thresholds and work as a link between binary and continuous variables. Relative limits, on the other hand, make it easier to ensure model feasibility when the long/short exposure is variable ($\tau^- < \tau^+$). In this case, let $\tau = \sum_{i \in N_1} w^-_i$ represent the actual short exposure in equities (as decided by the model itself).

§.§ Shorting limits in futures

Let $\upsilon^-$, $\upsilon^+$ be the minimum and maximum proportions of $1 + \tau$ allowed in a collection of short positions in futures. To enforce these limits, we add the following constraint:

\begin{equation}
\left(1 + \sum_{i \in N_1} w^-_i \right) \upsilon^- \;\leq\; \sum_{i \in N_2} w^-_i \;\leq\;  \left(1 + \sum_{i \in N_1} w^-_i \right) \upsilon^+ \label{eq12}
\end{equation}

By defining these limits as relative to the total long exposure, we have that $0 \leq \upsilon^- \leq \upsilon^+ \leq 1$. As an illustration, let $\tau^- = \tau^+ = 0.5$ and $\upsilon^- = \upsilon^+ = 0.5$. In this case, the portfolio must hold 50% of $C$ in short positions in equities, 75% of $C$ must be held in short positions in futures and another 75% must be held in long positions in any of the assets.

§.§ Exposure limits in the risk-free assets

Risk-free assets generally behave as equities, with a slight difference: the asset representing a lend rate cannot be held in short positions, while the asset representing a borrow rate cannot be held in long positions. Let $c^-$, $c^+$ be the minimum and maximum proportions of $1 + \tau$ allowed in the risk-free assets, such that $-1 \leq c^- \leq c^+ \leq 1$. We add the following constraints:

\begin{align}
w^-_{\ell} & =\; 0  \label{eq13} \\
w^+_{b} & =\; 0  \label{eq14} \\
\left( 1 + \sum_{i \in N_1} w^-_i \right) \left(\max\{0, c^-\}\right) \leq w^+_{\ell} & \leq \; \left( 1 + \sum_{i \in N_1} w^-_i \right) \left( \max\{0, c^+\} \right)\label{eq15} \\
\left( \sum_{i \in N_1} w^-_i \right) \left(\max\{0, -c^+\} \right) \leq w^-_{b} & \leq \;  \left( \sum_{i \in N_1} w^-_i \right) \left( \max\{0, -c^-\} \right)\label{eq16}
\end{align}

§.§ Minimum expected return

Let $\mu_i$ be the expected return of asset $i \in N$. In scenario-based formulations, $\mu_i = \sum_{s \in S} p_s r_{is}$, where $S$ is the number of discrete scenarios, $p_s$ is the probability of scenario $s \in S$ and $r_{is}$ is the return of asset $i$ in scenario $s$. We also remind the reader that $\mu_i$ takes leverage into account. If a given futures $i$ has expected return 1% and leverage level equal to $5 \times$, then effectively $\mu_i = 5\%$.

The following constraint enforces minimum expected portfolio return given a target return $\bar{\mu}$:

\begin{align}
\sum_{i \in N} \mu_i (w_i^+ - w_i^-) & \geq \bar{\mu}
\label{eq17}
\end{align}

Note that short positions in futures contribute negatively to the portfolio expected return.

§.§ General lower and upper bounds

Let $l^+, l^-$ be the lower limits ($0 \leq l^+, l^-$) on the proportion invested in long/short positions in any asset if we choose to invest in that asset. Likewise, let $u^+, u^-$ be the upper limits ($0 \leq u^+,u^-$) on the proportion invested in long/short positions in any asset. The constraints that enforce these limits are given by:

\begin{align}
l^+ z^+_i \leq w^+_i & \leq u^+ z^+_i & \forall i \in N \setminus \{\ell, b\}\label{eq18} \\
l^- z^-_i \leq w^-_i & \leq u^- z^-_i & \forall i \in N  \setminus \{\ell, b\}\label{eq19}
\end{align}

The limits above are applicable (by our choice) to all but the risk-free assets. It is also possible to enforce different limits per asset, or even enforce them selectively. Lower bounds allow the enforcement of a minimum holding level, or as it is commonly referred to in literature, a buy-in threshold. This is especially important in cardinality constraints, since we can only enforce a minimum number of nonzero positions if $l^+$ and $l^-$ are both non-zero. Upper bounds, if applicable, usually define stronger (tighter) bounds than Constraints (<ref>)-(<ref>).

§ SECOND STAGE: FROM OPTIMAL PROPORTIONS TO REAL TRADES

The solution of the first stage is a vector $\vec{w^*} = (w^*_1, \dots, w^*_n)$ containing the desired portfolio proportions, obtained by calculating $w^*_i = w^{+*}_i - w^{-*}_i$ for all $i \in N$. The next logical step is to execute the necessary trades to convert the current portfolio into the desired one. Hence, at this stage, we introduce linear and mixed-integer formulations to find feasible holdings $\vec{x}$ that match $\vec{w^*}$ as well as possible.

At this stage, the two risk-free assets $\ell$ and $b$ are unnecessary since we know whether $w^*_{\ell} > 0$, $w^*_{b} < 0$ or $w^*_{\ell} = w^*_{b} = 0$. Let $c$ be the index of the cash asset (to which lots and transaction costs do not apply) and let $w^*_c = w^*_{\ell} + w^*_{b}$ be the desired proportion in cash.

We present two versions of the second stage formulation: without lots, and with lots. The former is modelled as a linear program while the latter requires integer variables. We then expand both formulations to include borrowing costs - costs associated with short selling shares from assets in $N_1$.

Let $X_i$ and $V_i$ be the current number of shares/units and the current price of asset $i$, and let $L_i \geq 1$ be leverage factor of asset $i$, where $L_i = 1$ for $i \in N_1$. Let $M_i = \frac{X_i V_i}{L_i}$ be the financial value invested in asset $i$. In the case of futures, we assume that the margin accounts hold the exact value required to secure the contracts in place, i.e. any surplus to the margin required levels has been added to $X_c$ and any deficit has been taken from $X_c$. We have $P = C + \sum_{i \in N} M_i$ as the current mark-to-market valuation of the portfolio, where in this context $C$ represents available capital to be invested in the portfolio. Note that $C$ might be negative if a cash withdrawal is about to take place. Let $f_i$ be the fractional cost of buying/selling a unit of asset $i \in N$. Parameters $V_c, L_c$ and $f_c$ are undefined.

For assets that require lots, $X_i$ represents the number of shares held, while for assets that do not (such as cash or cryptocurrencies), $X_i$ represents the number of units held.

Let $\N = c \cup \left\{ i \in N\setminus \{\ell, b\} \mid X_i \neq 0 \text{ or } w^*_i \neq 0 \right\}$ be the set of assets for which trading might occur. Often $|\N| \ll |N|$, which helps in reducing the computational burden of solving the second stage. Let $\N_1 \subseteq \N$ be the set of equities and $\N_2 \subseteq \N$ be the set of futures for which trading might occur, where $\N_1 \cup \N_2 = \N$ and $\N_1 \cap \N_2 = \emptyset$. Let $\N^+ = \left\{ i \in \N \mid w^*_i > 0 \right\}$, $\N^- = \left\{ i \in \N \mid w^*_i < 0 \right\}$ and $\N^0 = \left\{ i \in \N \mid w^*_i = 0 \right\}$.
Finally, let $\N^R \subseteq \N_2$ be the set of assets which require a rollover, such that the entire current position must be liquidated before purchasing a new one.

§.§ Second stage formulation, without lots

When lots are not included, it is possible to find $\vec{x}$ such that the discounted portfolio perfectly matches $\vec{w}^*$. Hence, in this formulation the objective is to minimise the transaction costs spent to purchase $\vec{x}$. Let us define the following decision variables:

$p$          the portfolio value after transaction costs are discounted,

$x_{i}$      number of shares of asset $i \in \N$ to be held,

$m_{i}$      financial value to be invested in asset $i \in \N$,

$c$          amount to be invested in cash,

$G_{i}$      fractional transaction costs associated with buying or selling asset $i \in \N$.

We assume for simplicity that $f_i > 0 \;\; \forall i \in \N$. If $\exists i \mid f_i = 0$, then it is not necessary to define the corresponding $G_i$.

The following linear programming finds $\vec{x}$ while spending as little as possible in transaction costs:

[]min       ∑_i ∈ G_i

subject to     c        =     w^*_c p

m_i      =     w^*_i p,           i ∈_1  ∪( _2 ∩(^+ ∪^0) )

m_i      =     -w^*_i p,          i ∈_2 ∩^-

m_i      =     V_i x_i/L_i,                             i ∈_1  ∪( _2 ∩(^+ ∪^0) )

m_i      =     - V_i x_i/L_i,                           i ∈_2 ∩^-

G_i      ≥    (x_i - X_i) f_i V_i,                        i ∈

G_i      ≥    (X_i - x_i) f_i V_i,                        i ∈

G_i      ≥    (- x_i - X_i) f_i V_i,                      i ∈^R

G_i      ≥    (X_i + x_i) f_i V_i,                        i ∈^R

p     =     P - ∑_j ∈ G_j

Constraints (<ref>)-(<ref>) ensure that the financial value held in each asset corresponds to the exact desired proportions. Constraints (<ref>)-(<ref>) calculate the necessary margin accounts (or financial valuation) invested in each asset. The $m_i$ variables are not strictly necessary but are kept to ease the mathematics presented. Constraints (<ref>)-(<ref>) calculate fractional transaction costs, including when rollover applies. Coupled with the “downward pressure" from Objective (<ref>), they ensure that the $G_i$ variables are equal to the costs spent. Finally, Constraint (<ref>) defines the discounted portfolio value. This constraint is also not strictly necessary, but simplifies the other formulations below.

Due to space reasons we do not consider piecewise convex or concave costs, nor fixed costs. However, these could be easily introduced with the addition of extra binary variables. We leave this for future work.

§.§ Second stage formulation, with lots

When integral lots are required, it is generally impossible to find a valid portfolio that perfectly matches the desired proportions. As opposed to most other works in literature (see Section <ref>), here we propose a goal programming approach that, within the set of lot-feasible portfolios, finds the one that minimises the deviation to the desired weights.

We do, however, still want to minimise the transaction costs spent, so there are two potentially conflicting objectives. On one hand, minimising the deviations to $\vec{w^*}$ may require spending more in transaction costs, on the other hand saving on transaction costs imply keeping the portfolio close to its current form, potentially deviating more than necessary from $\vec{w^*}$. We propose a weighted sum of both objectives. We adopt the policy that minimising the deviation takes precedence over minimising transaction costs, and discuss appropriate weights for the objective function.

Let $\N^L$ and $\N^{\centernot{L}}$ be the set of assets for which lots apply and not apply, respectively, with $\N^L \cup \N^{\centernot{L}} = \N$. Let us redefine $X_i$ as the current number of shares/units of asset $i \in \N^{\centernot{L}}$ or the current number of lots of asset $i \in \N^L$. Likewise, we redefine $V_i$ as the current price of one unit of asset $i \in \N^{\centernot{L}}$ or one lot of asset $i \in \N^L$.

With regards to the cash asset $c$, a negative deviation to $w^*_c$ may imply a portfolio with higher risk, which may not be acceptable. Therefore we also propose an optional control parameter $W_c$ as the lower accepted limit on the actual proportion invested in cash. If $w^*_c \geq 0$, then having $W_c = 0$ ensures that the actual portfolio does not borrow any cash. If $W_c = w^*_c$ (irrespective of the sign of $w^*_c$), then we ensure that the proportion in cash will be at least $w^*_c$, i.e. which ensures that if $w^*_c < 0$ no extra cash is borrowed. We make use of the following decision variables:

$x_{i} \in \mathbb{Z}$     redefined as number of lots of $l_i$ shares of asset $i \in \N^L$

$x_{i} \in \mathbb{R}$     as number of units of assets $i \in \N^{\centernot{L}}$

$d^+_c, d^-_c \geq 0$     as the upward and downward deviation from $w^*_c$ in the final portfolio.

$d^+_i, d^-_i \geq 0$     as the upward and downward deviation from the implied financial value of the number

of shares that perfectly represents the proportion $w^*_i, i \in \N$ of the final portfolio.

Expressing deviations as financial values allows us to combine them with transaction costs into a single objective function.

Let $\N_1^- = \{i \in \N_1 \mid X_i < 0\}$ be the set of assets in $\N_1$ for which we currently hold short positions. The second stage formulation with lots is given by:

[]min      d^+_c + d^-_c + ∑_i ∈ (d^+_i + d^-_i) + ∑_i ∈ W_i G_i

subject to     (<ref>)-(<ref>)

∑_i ∈ m_i + c     =        p,

c     ≥    W_c p,

c + d^-_c - d^+_c     =        w^*_c p,

m_i + d^-_i - d^+_i     =     w^*_i p      i ∈_1  ∪( _2 ∩(^+ ∪^0) )

m_i + d^-_i - d^+_i     =     -w^*_i p      i ∈_2 ∩^-

∑_i ∈^-_1 m_i     ≥    ∑_i ∈^-_1 w^*_i p

x_i     ≥    0      i ∈^+

x_i     ≤    0      i ∈^-

x_i     =     0      i ∈∖{^+ ∪^-}

where $W_i$ are weights that balance the two conflicting goals in Objective (<ref>). Constraint (<ref>) ensures that the individual positions add up to the discounted portfolio value. Constraint (<ref>) enforces the minimum allowed proportion in cash, while Constraints (<ref>)-(<ref>) calculate the deviations from $\vec{w^*}$. Optional Constraint (<ref>) prevents overexposure in short positions. Constraints (<ref>)-(<ref>) ensure that assets whose desired position is long (short) are not held in short (long) positions, and that assets whose desired exposure is zero are not to be held in any residual amounts.

§.§.§ Objective function

We mentioned previously the assumption that minimising the deviation takes precedence over minimising the transaction costs required to purchase the new portfolio. Since in Objective (<ref>) all terms are expressed as financial values, we may calculate $W_i$ such that the cost improvement in reducing deviation is not offset by the increase in transaction costs spent. Note that different fractional transaction costs may be applied to different asset classes or even assets, such as when we artificially increase $f_i$ as a penalty for illiquid assets.

To simplify, we standardise the definition of the objective function weights by letting $W_i = \theta \frac{1}{f_i L_i}, 0 < \theta \leq 1$, for $i \in \N$. If $\theta = 1$, then reducing the deviation by $1 incurs exactly $1 in transaction costs penalties in the objective function. For leveraged assets, the cost is paid with relation to the full contract, but the deviation is reduced according to the margin account required deposit, hence the $L_i$ term in the denominator. If $\theta = 0$, then a trivial optimal solution is any such that $p = \sum_{i \in N} G_i$. In that case, $c = 0$, $x_i = 0, i \in N$ and all deviations are trivially zero.

If we employ $\theta \gg 1$, transaction costs are heavily penalised and the optimal solution tends to trade as little as possible. As $\theta \to 0$, optimal solutions tend to artificially inflate transaction costs (meaning $G_i > |x_i - X_i|$) in order to achieve smaller deviations, resulting in wrong values of $p$. In Section <ref>, we evaluate how the model behaves for different values of $\theta$.

§.§ Borrowing costs

Short positions require the borrower to pay a “rent fee” to the lender. This fee is paid whenever a shorting contract is closed or expires. Borrowing costs are generally defined as a predefined yearly rate to be paid proportionally to the time the contract was held, with a reference price as basis for the calculation (usually the closing price of the day before the contract was opened). The actual borrowing rate is both asset and time-dependent (it varies over time).

Consider the following example. We initiate a shorting contract at Day 0 where we borrow 200 IBM shares at $20.00 each. Suppose the rent rate for IBM at the time was 5% a year, and that we liquidate the contract after 10 business days. The amount we pay in borrowing costs to the lender is based on the contract initial price, and is calculated proportionally to the period held. The actual costs to be paid may be calculated either with compounded returns or a simple average (here we assume compounded returns):

\begin{align*}
% 200 \times \$20 \times \left( 0.05 \times \frac{10}{252}\right) & \approx \$7.94 \\
200 \times \$20 \times \left( (1 + 0.05)^{\frac{10}{252}} - 1\right) & \approx \$7.75
\end{align*}

where 252 approximates the number of business days in a year. The calculation details depend on the broker and the stock market.

We may also partially close a contract. Consider that we are closing 100 shares in 10 days, and the other 100 shares in 15 days. We pay:

\begin{align*}
\text{On day 10: }  100 \times \$20 \times \left( (1 + 0.05)^{\frac{10}{252}} - 1\right) & \approx \$3.88 \\
\text{On day 15: }  100 \times \$20 \times \left( (1 + 0.05)^{\frac{15}{252}} - 1\right) & \approx \$5.82
\end{align*}

which make up a total of approximately $9.69.

The agreed rate is specific to each individual contract. For instance, we may currently hold a total short position of 300 shares in IBM, but we may have initiated 100 shares 10 days ago (Contract 1), 100 shares 5 days ago (Contract 2) and another 100 shares 2 days ago (Contract 3). The rates agreed for each contract may differ: let the rate for Contract 1 be 3%, the rate for Contract 2 be 5% and the rate for Contract 3 be 4%. For each of these contracts, the costs are calculated individually.

When partially closing a short position, we need to decide which of the contracts should be closed. Suppose in the example above that we want to liquidate 150 shares and keep another 150 in short positions. We may:

* Close them chronologically, effectively liquidating Contract 1 in its entirety (paying its borrowing costs) and 50 shares of Contract 2 (again, paying its partial costs).

* Close the most expensive first, so liquidating Contract 2 in its entirety, then partially liquidating 50 shares of Contract 3 while keeping Contract 1 in its entirety.

When rebalancing towards a given portfolio $\vec{w}^*$, we might have to close some shorting positions. On top of fractional transaction costs, borrowing costs might have to be deducted, impacting the calculation of the discounted portfolio value $p$. Since borrowing costs are entirely based on a predefined rate, the contract reference price and the number of days since it started, it is possible to calculate prior to the optimisation how much we would pay if an individual shorting contract was closed. In the case of partial closures, we may also sort the individual contracts based on which we would like to close first.

For assets in $\N_1^-$, $X_i$ is broken down into a sum of multiple open shorting contracts. Let $J_i$ be the number of open short contracts of asset $i$, and let $X^j_i$, $j = 1, \ldots, J_i$ (such that $\sum_{j = 1}^{J_i} X^j_i = X_i$), define the amount held originating from each contract, sorted from the most desirable to close first to the least desirable. Let $h^j_i$ be the monetary value to be paid in borrowing costs if we fully closed contract $X^j_i$ today, with every $h_i^j$ being calculated prior to the optimisation. For instance, if $X^j_i = -100$, and the corresponding contract has a reference price of $20 and a rate of 4%, 7 business days ago, then $h^j_i =  100 \times \$20 \times \left( (1 + 0.04)^{\frac{7}{252}} - 1\right) \approx \$2.18$.

§.§.§ Formulation with borrowing costs, no lots

Let $H^j_i : i \in \N_1^-, j = 1, \ldots, J_i$ be additional decision variables representing the borrowing costs paid in fully or partially closing contract $j$ from asset $i$. Let $\delta^j_i$, $j = 0, \ldots, J_i + 1$, be auxiliary binary variables, such that:

$\delta^0_i = 1$     if $x_i \leq X_i$, that is, we either keep or increase our shorting position in $i$,

$\delta^j_i = 1,\; j = 1, \ldots, J_i$     if $\sum_{k = 1}^{j-1} X^j_i \leq x_i - X_i \leq \sum_{k = 1}^{j} X^j_i$, that is, if we close all contracts up to $j-1$,

and partially or entirely close contract $j$. If $j = 1$, $\sum_{k = 1}^{j-1} X^j_i = 0$.

$\delta^{J_i+1}_i = 1$,     if $x_i \geq 0$, that is, if we close the entire shorting position in $i$.

The second stage formulation with borrowing costs and no lots is defined as:

[]min       ∑_i ∈ G_i + ∑_i ∈^-_1 ∑_j = 1^J_i H^j_i

subject to     (<ref>)-(<ref>)

p     =     P - ∑_i ∈ G_i - ∑_i ∈^-_1 ∑_j = 1^J_iH^j_i

∑_j = 0^J_i + 1 δ^j_i     =     1      i ∈^-_1

x_i - X_i     ≤    U(1 - δ^0_i)       i ∈^-_1

x_i - X_i      ≥    -U(1 - δ^1_i)      i ∈^-_1

x_i - X_i     ≤    -∑_k = 1^jX^j_i + U(1 - δ^j_i)       i ∈^-_1, j = 1, …, J_i

x_i - X_i     ≥    -∑_k = 1^j-1X^j_i - U(1 - δ^j_i)       i ∈^-_1, j = 2, …, J_i+1

H_i^j     ≥    0       i ∈^-_1, j = 1, …, J_i

H_i^j     ≥    h^j_i x_i - (X_i - ∑_k = 1^j-1X^k_i )/-X^j_i - U (∑_k = j+1^J_i+1 δ^k_i )     i ∈^-_1, j = 1, …, J_i

H_i^j     ≥    h^j_i - h_i^j (∑_k = 0^j δ^k_i )     i ∈^-_1, j = 1, …, J_i

Constraint (<ref>) calculates the discounted portfolio $p$ with deducted borrowing costs. Constraints (<ref>)-(<ref>) ensure that the appropriate binary variable $\delta_i^j, j = 0, \dots, J_i+1$, is correctly assigned. Constant $U$ can be calculated as the maximum possible difference $| x_i - X_i |$ (depending on $w^*_i$). Constraints (<ref>)-(<ref>), together with Objective (<ref>), calculate the borrowing costs to be paid per contract.

§.§.§ Formulation with borrowing costs and lots

Let $f^j_i = - \frac{h^j_i}{X^j_i V_i}$ be the proportion of the value of the short contract $j$ from asset $i$ to be paid in borrowing costs in case we fully close it. Let us redefine $W_i$, $i \in \N^-_1$ in such a way that reducing the deviation by $1 does not incur more than a $1 penalty in variable plus borrowing costs altogether. A natural approach to enforce this is to combine $f^j_i$ with $f_i$ in a single proportion - however, since $f^j_i$ is contract dependent, we must define $G_i^j$ and $W^j_i$ instead of $G_i$ and $W_i$, for $j = 0, \ldots, J_i + 1, i \in \N^-_1$. More specifically, for $0 < \theta \leq 1$:

* $W_i^0 = \theta \frac{1}{f_i}$, with $G^0_i > 0$ representing fractional costs associated with an increase in the short position currently held, so no contracts being closed.

* $W_i^{J_i + 1} = \theta \frac{1}{f_i}$, with $G^{J_i + 1}_i > 0$ representing fractional costs associated with opening a long position in $i$, if required.

* $W_i^j = \theta \frac{1}{\left( f^j_i + f_i\right)}, j = 1, \ldots, J_i$, with $G^j_i + H^j_i$ representing the sum of fractional and borrowing costs paid when closing, or partially closing, contract $j$.

Note that we have ignored the term $L_i$ since for $i \in \N^-_1$, $L_i = 1$.

For $i \in \N^-_1$, let

\begin{align*}
\Upsilon(i) = W_i^0 G_i^0 + W_i^{J_i + 1} G_i^{J_i+1} + \sum_{j = 1}^{J_i} W_i^j \left(H^j_i + G_i^j\right).
%\Upsilon(i) = W_i^0 G_i^0 + W_i^{J_i + 1} G_i^{J_i+1} + \sum_{j = 1}^{J_i}\frac{1}{f^j_i + f_i} \left(H^j_i + G_i^j\right).
\end{align*}

Let also $g^j_i = - f_i V_i X_i^j$ represent the fractional costs paid if the whole contract $j$ is closed. The second stage formulation with lots and borrowing costs is given by:

[]min      d^+_c + d^-_c + ∑_i ∈ (d^+_i + d^-_i) + ∑_i ∈∖^-_1 W_i G_i + ∑_i ∈^-_1 Υ(i)

subject to     (<ref>)-   (<ref>)   , (<ref>)-(<ref>), (<ref>)-(<ref>), (<ref>)-(<ref>)

G_i                        ≥    (x_i - X_i) f_i V_i,                        i ∈∖^-_1

G_i                        ≥    (X_i - x_i) f_i V_i,                        i ∈∖^-_1

G_i     =     ∑_j = 0^J_i+1 G_i^j      i ∈^-_1

G_i^j     ≥    0     i ∈^-_1, j = 0, …, J_i+1

G_i^j     ≥    g^j_i x_i - (X_i - ∑_k = 1^j-1X^k_i )/-X^j_i - U (∑_k = j+1^J_i+1 δ^k_i )     i ∈^-_1, j = 1, …, J_i

G_i^j     ≥    g^j_i - g_i^j (∑_k = 0^j δ^k_i )     i ∈^-_1, j = 1, …, J_i

G_i^0     ≥    f_i V_i (X_i - x_i)     i ∈^-_1

G_i^J_i+1     ≥    f_i V_i x_i      i ∈^-_1

Constraints (<ref>)-(<ref>) enforce the newly defined $G_i^j$ variables. More specifically, Constraints (<ref>)-(<ref>) enforce that the fractional costs for any single contract are only nonzero if the corresponding contract is partially or fully closed.

§ COMPUTATIONAL EXPERIMENTS

The motivation behind the two-stage framework is not to produce portfolios with superior out-of-sample performance with regards to risk/return properties. Rather its goal is in acting against the strategy by highlighting any difficulties an investor would face before investing (and potentially losing!) real money. That is the main reason why the framework is as generic as possible with an explicit goal of constructing a “bridge” between model and investment. A successful execution of the second stage should quickly and reliably produce holdings that match the desired portfolio as accurately as possible given any realistic market features applicable at any specific setting. Hence, the main focus of our computational experiments is in evaluating the second stage itself, with regards to its applicability, computational time and solution quality. We discuss limitations and related insights of the second stage in Section <ref>.

With regards to the first stage, the main difference to the literature is the inclusion of futures contracts, which give more liberty to fund managers in hedging and leveraging portfolios. In Section <ref> we present a case study illustrating these features.

We employ a custom-built backtesting tool which simulates negotiations and tracks individual contracts. When a portfolio rebalance takes place, the optimisation framework is invoked to produce optimal portfolio weights and to convert those weights into specific purchases and sales. Afterwards, the backtesting tool “executes” those transactions, discounting the necessary costs. Interest in cash is accrued every day, according to the risk free rate being applied at the time.

For all experiments, we employ [10] as linear and integer programming solver, with default configurations. Our backtesting tool is developed in Python and all optimisation models are developed in C++. We run all experiments in an Intel(R) Core(TM) i7-3770 CPU @ 3.90GHz with 8 cores, 8GB RAM and with Ubuntu 22.04.3 LTS as the operational system.

§.§ Dataset

We employ a single dataset with S&P500 stocks, selected futures contracts and two risk-free assets representing lent and borrowed cash. For S&P500 stocks, we take into account survivorship bias - at any given rebalance, the only stocks available for investment are those which were part of the index at the time. Depending on the context we assume that S&P500 stocks are traded in round lots (consisting of 100 shares each) or odd lots (any integral number of shares). With the increase in electronic trading, trading in odd lots in the U.S. is becoming easier due to increased liquidity[<https://www.investopedia.com/terms/r/roundlot.asp>, last visited $7^{\text{th}}$ May 2024.]. In other stock markets (such as Bovespa in Brazil or BSE in India) trading in odd lots is either not feasible or often illiquid.

In the S&P500 dataset we deal with around 500 assets at any point in time, which is a reasonable amount of assets when operating an investment fund. Surely it is possible to expand this asset universe to include larger indices (Russel 2000, Russel 3000) or to include small-caps. Compiling this data however is not trivial without access to specialised data providers (i.e. finding changes in indices compositions spanning many years). We leave the evaluation of the two-stage framework with larger asset universes for future work, but we believe the current dataset represents a realistic scenario.

The selected futures contracts are the following:

* Micro E-mini S&P500 futures[<https://www.cmegroup.com/markets/equities/sp/e-mini-sandp500.html>, last visited $7^{\text{th}}$ May 2024.], with a lot size of 5,

* Gold futures[<https://www.cmegroup.com/markets/metals/precious/gold.html>, last visited $7^{\text{th}}$ May 2024.], with a lot size of 100,

* Mini VIX futures[<https://www.cboe.com/tradable_products/vix/mini_vix/>, last visited $7^{\text{th}}$ May 2024.], with a lot size of 100.

We employ the 10-year US treasury bond (symbol TNX) return series as a synthetic asset representing the return on both lent and borrowed cash.

Apart from being part of the index at the time (with the exception of futures and cash), an asset is only considered eligible in a rebalance if there are at most 5% prices missing from the most recent historical series of 201 prices (200 returns). Any missing prices in the series of any asset that passes this filter is then completed with forward fill, then backwards fill. Whenever a simulation has costs involved, we assume 5 basis points as variable transaction costs and 3% a year as borrowing costs in equities.

In all experiments, portfolios are rebalanced at the last trading day of each month and evaluated daily until the data is exhausted. The out-of-sample period spans from $25^{\text{th}}$ December 2012 up to $29^{\text{th}}$ December 2023. During this period, a total of 132 rebalances are calculated. Unless explicitly noted we simulate an initial investment of $\$500\text{,}000$ and assume no cash additions/withdrawals throughout the investment lifespan. For each rebalance, we use the previous 200 historical daily returns as input to the portfolio optimisation model of choice. We assume trading at the end of the day based on closing prices. The return from the end of the previous day to the end of the current day is included in the in-sample historical data.

Due to futures contracts rollover, the second stage is executed more often than the first stage. Whenever a rollover happens on a non-rebalancing day, we invoke the second stage in order to, after accounting for the rollover, obtain a portfolio that is as close as possible to the currently held portfolio.

The time-series for every futures contract is the front-month contract with automatic rollover. Rollover dates for each contract are taken from their corresponding websites. The leverage level of each contract depends on the experiment.

All of the data here described is publicly available at:

§.§ Case study

We begin the computational experiments with a case study of our framework. The goal here is to evaluate whether the second stage works “against the strategy” and whether it is “practical” with regards to computational time and solution depreciation (when compared to that obtained in first stage). In later sections we evaluate the last two specific points in more detail.

As investment strategy we employ the [34] implementation of the second-order stochastic dominance (SSD) model for enhanced indexation proposed by [28]. We chose this specific configuration for one (scientifically unconventional) reason: because it looks appealing. The goal here is not to propose a promising strategy, but rather to evaluate what would happen to the strategy when we force it to abide by market rules, in this case by adding lots, costs and rollover. We report here both long only and 140/40 long/short strategies (where $\tau = 0.4$). We impose lower and upper bounds of $E_Q = 5\%$ and $\Delta_Q = 20\%$ for $Q$ defined as the set of all derivatives, and we set $L_i = 1$ for all $i \in Q$ (no leverage). When lots are applicable, in the second stage we set $W_c = w^*_c$ and $\theta = 0.05$.

We run three versions of both strategies: (i) without costs and lots (so no second stage needed), (2) with costs and odd lots in stocks and (3) with costs and round lots in stocks. For futures contracts, we use the lots described in Section <ref> for both (2) and (3). We display the cumulative out-of-sample returns of all strategies and that of the S&P500 in Figures <ref> and <ref>. The lines in the charts were smoothed with univariate splines for improved visualisation.

Out-of-sample cumulative performance, long only experiments with and without lots/costs.

Out-of-sample cumulative performance, long/short experiments with and without lots/costs.

On top of the charts, Table <ref> shows selected out-of-sample statistics for all six experiments and the S&P500. In the table, FV stands for Final Value, CAGR for the Compound Annual Growth Rate, Vol represents the annualised volatility and MDD stands for the maximum drawdown. Sharpe and Sortino are the annualised Sharpe and Sortino ratios respectively[An appendix available at <https://github.com/cristianoarbex/portfolioSimulationData> details all statistics calculations.].

1|c|Strategies     1cFV     1cCAGR     1cVol     1cMDD     1cSharpe     1c|Sortino

Long only                       5.23        16.23        17.42        24.68         0.82         1.20

Long only (odd lots)            4.88        15.49        17.41        25.08         0.78         1.15

Long only (round lots)          4.73        15.18        17.42        25.56         0.77         1.12

Long/short                      6.63        18.76        23.10        39.93         0.76         1.10

Long/short (odd lots)           5.12        16.01        23.13        42.43         0.66         0.95

Long/short (round lots)         4.98        15.72        23.11        42.74         0.65         0.93

SP500                           3.36        11.65        17.24        33.92         0.59         0.82

Comparative out-of-sample statistics

Without costs and lots, both carefully selected strategies vastly outperform the S&P500 in terms of performance (FV, CAGR) and risk-adjusted performance (Sharpe, Sortino). In the long only strategy, the only costs involved are fractional costs when buying and selling shares or contracts and costs associated with futures rollover, when the entire position is liquidated and repurchased. With regards to performance, the addition of odd lots and costs caused a decrease of 0.74% in CAGR and a $\approx4\%$ decrease in both Sharpe and Sortino ratios. When round lots are employed we are likely to observe worse second stage approximations of the first stage weights. With the expectation that the first stage weights are a good choice we observe with round lots a 1.05% drop in CAGR, a 6% drop in the Sharpe ratio and a 7% drop in the Sortino ratio.

On top of the other costs, borrowing costs are also applicable for the long/short experiments. With odd lots we observe a decrease of 2.75% in CAGR, 13% in the Sharpe ratio and 14% in the Sortino, while with round lots the results worsen a bit further with drops of 3.04% in CAGR, 14% in the Sharpe ratio and 15% in the Sortino ratio. In fact the long/short performance with round lots is just slightly better than the corresponding long only strategy, but with much higher risk (Vol, MDD) and hence worse risk-adjusted returns. This performance however is likely no worse than what would have been observed in practice since the asset universe under consideration is sufficiently liquid for the relatively small initial investment. Moreover, the rent and fractional costs applied possibly overestimate true costs that would have been charged by brokers.

With regards to the second stage applicability, an important consideration is the computational time required to solve it, especially when borrowing costs are included. This is critical since in a live trading environment, once a decision is made regarding portfolio weights, the system responsible for trading has to wait until the second stage is solved and weights are converted into trades. Table <ref> shows statistics related to the number of trades, portfolio cardinality (number of assets with non-zero weights) and the computational time required to solve each of the 132 second-stage instances (those due to portfolio rebalances). We remind the reader that the second stage is executed after each rebalance as well as rollover (non-rebalancing) days; the calculation of statistics however includes only those due to rebalances. In general the second stage execution due to rollover is faster as fewer trades are required, which could skew the statistics positively.

1|c|[c]2*Strategies     4c|Number of trades     4c|Portfolio cardinality     4c|Computational time (s)

1cMin     1cAvg     1cMedian     1c|Max     1cMin     1cAvg     1cMedian     1c|Max     1cMin     1cAvg     1cMedian     1c|Max

Long only (odd lots)             5      20.98     20.00       45          4      15.39     15.50       34       0.00       0.03       0.02       0.10

Long only (round lots)           5      18.63     18.50       40          4      15.39     15.50       34       0.00       0.02       0.02       0.08

Long/short (odd lots)           14      46.09     46.00       86          9      33.06     32.50       65       0.02       0.25       0.17       1.16

Long/short (round lots)         14      41.66     42.00       78          9      33.06     32.50       65       0.02       0.19       0.14       1.08

Number of trades, portfolio cardinality and second stage computational time per strategy

From the table we observe that the long only strategies required fewer trades and had less diversified portfolios in general when compared to the long/short strategies. Under these conditions, the second stage computational time is negligible. The long/short strategies had more diversified portfolios, more trades and required borrowing costs; yet in the worst case the second stage required only 1.16s to be solved to optimality. If this case study represents a relatively realistic setting for an investment fund, then in such case the second stage could be incorporated into a live trading system without major concerns.

Another important aspect in the second stage is the solution quality in terms of deviation from the desired first stage proportions. Table <ref> shows, for each experiment, selected statistics regarding the total deviation, per rebalance, from the corresponding desired proportions. The total deviation is the sum of the absolute values of all individual asset deviations. As an illustration, if the desired portfolio was 120% in asset A, -20% in asset B and 0% in cash, and the real portfolio invests 117% in A, 2% in cash and -19% in B, then the total deviation is 6%.

1|c|Strategies     1cMin     1c$P_{10}$     1c$P_{25}$     1cAvg     1cMedian     1c$P_{75}$     1c$P_{90}$     1c|Max

Long only (odd lots)          0.01       0.04       0.07       0.60       0.11       0.17       0.80      10.12

Long only (round lots)        0.84       1.58       2.41       4.92       4.34       6.49       8.95      21.81

Long/short (odd lots)         0.03       0.07       0.09       1.08       0.13       0.29       4.17      10.40

Long/short (round lots)       1.81       3.09       4.47       7.89       7.03      10.41      13.50      21.19

Total deviations (in %), per rebalance, from desired proportions. Selected statistics, where $P_{\alpha}$ denotes the $\alpha^{\text{th}}$ percentile.

From Table <ref> we had observed a decay in overall performance when employing round lots instead of odd lots. Non surprisingly, Table <ref> shows that total deviations under the more strict round lot policy is generally higher, meaning second stage solutions that are further from the desired first stage proportions. With odd lots, the average total deviation (including all assets) was only 0.6% and 1.08% for long only and long/short strategies. The median was even lower, at 0.11% and 0.13%, which suggests the presence of scattered outliers among the 132 rebalances. With round lots, not only the averages are higher (4.92% and 7.89%), but also the medians are relatively closer to the mean (4.34% and 7.03%). In the worst case, we observed around 21% total deviation. We emphasise, however, that this is the sum of deviations of around 20-80 trades (as observed in Table <ref>), so still not a high value overall.

§.§.§ Effect of initial investment

The smaller the portfolio financial value is, the less likely the second stage model is to find solutions that are close to the desired proportions. In this section, we vary the initial investment of both the long only and long/short strategies of this case study. The average deviation per rebalance as a function of the initial investment is shown in Figure <ref>, .

Average total deviation as a function of the initial investment.

For small investment values, such as $\$1\text{,}000$, we observe very large average deviations since a single lot of most assets surpasses the investment proportion allocated to it. We observe around $250\%$ and $200\%$ average deviation for the long/short and long only strategies with round lots. However, as the initial investment grows the average deviations drop substantially. With a $\$10\text{,}000\text{,}000$ investment, the average long/short total deviation with round lots drops to $0.41\%$.

§.§ Second stage, computational time

In the previous section, the computational time required to solve the second stage was negligible. In this section, we force more diversification and more trades in order to evaluate its execution time under more demanding scenarios. We make use of the long only and long/short strategies of Section <ref> with a few changes. In both, we force diversification by imposing upper bounds on all assets, that is, by defining appropriate values for $u^+$ and $u^-$.

We also increase the initial investment capital from $\$500\text{,}000$ to $\$50$ million to more easily diversify the portfolios, especially when lots are considered. We do not allow investment in cash, so as to prevent cash from taking a large proportion of the portfolios. We ignore rollover, so focusing only on the 132 rebalances. We also changed the threshold of accepted percentage of invalid prices from 5% to 20% with the goal of increasing the size of the asset universe. For the optimisation of the second stage, we set a time limit of 300s per rebalance.

We simulate all lot policies: none (no lots), odd and round. For the long only strategy, we include fractional costs and varied $u^+ = (1\%, 0.5\%, 0.25\%)$. For the long/short strategy, we include fractional and borrowing costs. Here, setting $u^+ = u^- = 0.25\%$ results in many infeasible problems. Hence with no lots we defined $u^+ = u^- = (2\%, 1\%, 0.5\%)$. For the odd and round lot policies, we also tested $u^+ = u^- = 5\%$. We display a summary of these experiments in Table <ref>.

1|c|[c]2*Strategy     1c|[c]2*Lots     1c|[c]2*$u^+, u^-$     3c|Cardinality     3c|Num. Trades     4c|Computational time (s)     4c|Optimality gap (%)

1cMin     1cAvg     1c|Max     1cMin     1cAvg     1c|Max     1cMin     1cAvg     1cMax     1c|TL     1cMin     1cAvg     1c$P_{90}$     1c|Max

[c]9*Long only     [c]3*None     1.0%           100        103        111        101        130        146        0.0        0.0        0.0          0     –         –         –         –

0.5%           200        202        209        201        238        259        0.0        0.1        0.1          0     –         –         –         –

0.25%          400        401        406        403        423        438        0.3        0.3        0.3          0     –         –         –         –

[c]3*Odd     1.0%           100        103        111        101        129        146        0.2        0.6        1.0          0     –         –         –         –

0.5%           200        202        209        201        237        259        2.7        5.9       12.7          0     –         –         –         –

0.25%          400        401        406        401        419        437       22.4      264.2     TL            105       0.01       0.06       0.14       0.32

[c]3*Round     1.0%           100        103        111        101        122        144        0.6        1.3        2.3          0     –         –         –         –

0.5%           200        202        209        173        205        243        5.2       16.3       26.3          0     –         –         –         –

0.25%          400        401        406        254        304        402       57.9      215.6     TL             52       0.01       0.25       0.19       8.82

[c]11*Long/short     [c]3*None     2.0%            90         98        117         93        128        156        0.0        0.1        0.2          0     –         –         –         –

1.0%           180        185        196        181        232        261        0.0        0.3        0.7          0     –         –         –         –

0.5%           360        364        375        361        422        458        0.2        2.8       11.1          0     –         –         –         –

[c]4*Odd     5.0%            37         49         78         48         66        105        0.0        0.3        1.6          0     –         –         –         –

2.0%            90         98        117         93        128        155        0.5       60.8     TL             16       0.01       0.01       0.01       0.02

1.0%           180        185        196        181        232        259        3.4      175.1     TL             71       0.01       0.04       0.06       0.09

0.5%           360        364        375        361        421        455       58.1      270.5     TL            103       0.01       0.08       0.17       0.23

[c]4*Round     5.0%            37         49         78         47         66        105        0.2        0.8       10.9          0     –         –         –         –

2.0%            90         98        117         93        126        152        1.5       38.3     TL             10       0.02       0.09       0.16       0.16

1.0%           180        185        196        181        220        249        5.8      190.6     TL             64       0.01       0.87       2.02       5.02

0.5%           360        364        375        320        372        424      226.6      299.4     TL            131       0.22       6.15      12.64      21.75

Computational time statistics for 132 rebalances for different strategies, where $P_{\alpha}$ denotes the $\alpha^{\text{th}}$ percentile.

For each one of the experiments, the table displays basic statistics regarding cardinality and the number of trades. The larger these numbers are, the larger the second-stage model is. The next columns show the average, minimum and maximum computational times. An instance that reaches the time limit is labelled TL. The column TL shows how many of the 132 instances reached the time limit. For these instances, the solution employed in the simulation is the best solution found as the solver is halted. Finally, the last set of columns shows optimality gaps statistics among the instances that are not solved within the time limit.

As an illustration, among the long only experiments with round lots and $u^+ = 0.25\%$, the 132 rebalances chose on average non-zero weights in 401 different assets. The output of the second stage suggested on average 304 trades to be executed, with a minimum of 254 and a maximum of 402. In 105 rebalances, the second stage was not optimally solved within 300s. The $90^{\text{th}}$ percentile optimality gap among these 105 instances was 0.19%, in the worst case it was 8.82%. These particular instances are considerably larger than the case study illustrated in Section <ref>.

Based on the data presented in the table, we draw the following conclusions:

* The rows labelled None do not include integer variables representing lots. The long only experiments only consider fractional costs, so the models are linear. In this case, the computational times are negligible. The long/short experiments on the other hand require binary variables to model borrowing costs. Yet, all 396 rebalances (for three different values of $u^+, u^-$) were solved quickly, with an average of 2.8s for the largest instances and a worst case of 11.1s.

* The long only experiments with both odd and round lots make use of general integer variables, but no binary variables for borrowing costs. The computational times grow considerably as for $u^+ = 0.25\%$, 157 instances were not solved to optimality. Yet among the unsolved instances, the optimality gaps were very small among the vast majority of instances, with averages of 0.06% and 0.25% for odd and round lots. An outlier ended with an 8.82% gap, but the second largest gap (not reported in the table) was 0.30%. We did not observe noticeable difference between odd and round lots.

* The hardest instances are those that include lots and borrowing costs. Among these, those with round lots stand out. The optimality gaps among unsolved long/short instances with odd lots have a worst case of 0.23%. With round lots and $u^+ = u^- = 0.5\%$, however, only one instance was solved within 300s. The average gap was 6.15% and the $90^{\text{th}}$ percentile was 12.64%, with a worst case of 21.75%. Figure <ref> shows the whole distribution of gaps. While at this point the second stage performance starts to deteriorate, the distribution is still concentrated on the smaller values, with 72 out of 132 instances exhibiting gaps of at most 5%. Nevertheless, as future work we intend to study alternative algorithms and reformulations in order to reduce its overall computational time for these hardest cases.

Optimality gaps distribution among 131 unsolved rebalances, long/short strategy with round lots and $u^+ = u^- = 0.5\%$.

§.§ Evaluation of the second stage objective function

As previously discussed, Objectives (<ref>) and (<ref>) combine two goals by minimising a weighted sum of deviation and costs. In order to compute these weights, parameter $\theta$ standardises potential different costs and rates and is defined as the relative importance of minimising costs as compared to minimising deviation. Since we adopt the policy that minimising deviation takes precedence, we employ $\theta < 1$.

In this section, we assess how different values of $\theta$ influence both deviation and costs. Within the formulation, fractional and borrowing costs are held in nonnegative variables $G_i$ and $H_i^j$ respectively, constrained by inequalities. When the inequalities are binding, these variables hold the exact required costs for moving from the current portfolio to the next. However, since minimising costs tends to be conflicting with minimising deviation, there is no assurance that at the optimal solution all inequalities are binding. A very small value of $\theta$ increases the chance of non-binding inequalities (surpluses), while a large value of $\theta$ might increase overall deviation. In all experiments reported in this paper, we allocated eventual surpluses into cash.

For both long only and long/short experiments, we vary $\theta = (0.50, 0.49, \dots, 0.01)$. Figures <ref> and <ref> display the long/short results with odd and round lots. The corresponding long only figures are shown in the appendix accompanying this paper[<https://github.com/cristianoarbex/portfolioSimulationData>].

In the figures, the left $y$-axis shows the average total deviation, calculated as 100 $\times$ the sum of all individual deviations for all assets and rebalances, divided by the number of rebalances. The right $y$-axis shows the average surplus in both fractional and borrowing costs, calculated as the sum of all surpluses for all assets in all rebalances divided by the number of rebalances.

Long/short with odd lots, various values of $\theta$.

Long/short with round lots, various values of $\theta$.

With odd lots, the average deviation drops from around $1.13\%$ when $\theta = 0.5$ to around $1.08\%$ when $\theta = 0.01$. Meanwhile, the cost surplus is zero from $\theta = 0.50$ down to $\theta = 0.06$, sharply increasing when $\theta = 0.02$. We empirically observe the average deviation plateauing for $\theta < 0.2$. With round lots, the average deviation drops from around $9.3\%$ when $\theta = 0.5$ to around $7.6\%$ when $\theta = 0.01$. The average deviations are higher as round lots are much more restrictive, but they also drop more strongly with no obvious plateau. At the same time, costs surpluses increasing rapidly for the smallest $\theta$ values.

In order to choose the “sweet spot” for $\theta$, we take into consideration that our main goal is minimising deviation, and that the further to the right on the chart, the smallest the average deviation. However we do not wish to distort the results by accepting large surpluses, although at least for the long/short strategy we might consider a minor (negligible) surplus to be acceptable. Hence we set, as an appropriate empirical choice, $\theta = 0.05$. The long only results shown in the appendix also support this choice.

§.§ Lots and costs in the first stage stage

In this section, we assess the trade-off between the two-stage approach and the alternative of incorporating lots and weights in a single formulation. For this purpose, we implemented the constraints proposed by [35] (hereby referred to as the Woodside model) into our framework[The details are shown in an appendix available at <https://github.com/cristianoarbex/portfolioSimulationData>.]. The major difference is that while the Woodside model restricts the search space into “lot-feasible” portfolios, in our approach we attempt to approximate the lot-unconstrained portfolio with no regards to how this affects the objective value achieved in the first stage.

Comparing both approaches, however, is not necessarily straightforward. Consider a risk minimisation approach and suppose that the portfolio is constrained to not invest in cash. Even so, in the Woodside model some investment in cash is unavoidable as it is generally impossible to satisfy all integrality constraints while using all available funds. At the same time, cash is low-risk, so there is also an incentive to invest as much as possible in it. Other objectives may require other actions, such as adapting the Woodside budget constraint when employing ratio models. In summary applying the Woodside model with different portfolio decision criteria requires careful examination to detect potential points of conflict.

Another difficulty comes from the mixed nature of the Woodside model, combining both relative and absolute variables. When the portfolio financial value is large, both very large and very small coefficients appear in the formulation, which makes the model susceptible to numerical inaccuracies. We had first chosen minimising CVaR as objective, and we immediatelly observed this issue: in numerous cases, the calculated CVaR from the second stage portfolio was lower (better) than the one from Woodside, which is theoretically impossible. Upon further inspection we detected the root cause of this behaviour to be numerical errors. We confirmed this issue by verifying its occurrence when employing different solvers (apart from CPLEX).

Due to this initial difficulty, we chose the simpler first stage objective of maximising the portfolio expected return. In the Woodside model, this objective eliminates the incentive to invest in cash unless the optimal solution within risky assets has a negative expected return. It is also easier to control for numerical inaccuracies as shown below.

Apart from the change in objective, we employ the long only strategy from Section <ref> with the following changes. We impose a time limit of 15 minutes (900s) for each Woodside rebalance, and we set the initial investment to $1 million. We define the cash (risk free) return as zero and we set $u^+ = c^+ = 0.05, c^- = 0$. The former defines an upper bound of 5% on all assets as well as cash, and it helps prevent trivial portfolios that invest everything in the asset with the highest expected return. We also do not employ shorting nor rollovers of futures contracts. In the absence of numerical errors, the Woodside single stage solution is always a portfolio with a higher or equal expected return than the second stage solution.

In order to mitigate numerical errors in the Woodside model we simply scale the objective function by multiplying all terms by a constant. Woodside model results are shown in Table <ref>.

1|c|[c]2*Strategy     1c|[c]2*Lots     1c|[c]2*Scale     1c|[c]2*Sol.
found     6c|Exp. return relative decline (%)     6c|Computational time (s)

1cMin     1c$P_{25}$     1cAvg     1cMedian     1c$P_{75}$     1c|Max     1cMin     1cAvg     1cMedian     1c$P_{90}$     1cMax     1c|TL

1|l|[c]10*Long only     1l|[c]5*Odd     1e0             132       6.14      87.48      89.12      90.67      93.15      98.66        0.1        0.1        0.1        0.3        0.6          0

1e1             132      70.07      91.43      93.18      94.02      96.30      99.28        0.1        0.5        0.3        0.9        3.4          0

1e2             132      91.09      98.48      98.85      99.25      99.66      99.98        0.1        0.6        0.3        1.2        8.1          0

1e3             132      99.57      99.91      99.93      99.95      99.96     100.00        0.1        1.6        0.6        5.1       11.1          0

1e4             132      99.66      99.95      99.95      99.96      99.97     100.00        0.1       10.0        2.0        7.9     TL              1

1l|[c]5*Round     1e0             132      91.58      97.33      97.78      98.01      98.68      99.41        0.1        0.5        0.3        1.2        4.8          0

1e1             131      92.48      98.60      98.76      98.99      99.26      99.69        0.1       23.7        0.5        4.2     TL              3

1e2             132      92.62      98.56      98.78      99.03      99.31      99.71        0.1       51.7        0.7        5.2     TL              7

1e3             131      92.62      98.60      98.78      99.03      99.32      99.71        0.1       58.4        0.7        7.5     TL              8

1e4             131      92.62      98.60      98.78      99.03      99.32      99.71        0.1       55.3        0.6        6.1     TL              7

Woodside model results, decay in expected returns (when compared to lot-unconstrained first stage solutions) and computational time  (with $P_{\alpha}$ as the $\alpha^{\text{th}}$ percentile).

Within each lots policy, the only difference between the models is the value multiplied by the objective function coefficients (column Scale). In some rare rebalances, the solver was unable to find any feasible solution within the time limit, under column Sol. found we show how many rebalances were successful. For each successful rebalance, we calculate the expected returns of the first stage in-sample portfolio and the Woodside optimal or best solution. We calculate the relative difference between both and show selected statistics under columns labelled Exp. return relative decline. Under label Computational time, we display time statistics as well as the number of rebalances without proven optimality under column TL.

As an example, with odd lots and scale $1 \times 10^0$ (so the original obj. function), all rebalances were solved to optimality within 0.6s. The Woodside optimal solutions were however on average 89.12% as high as the first stage expected returns. In a particular case, the Woodside expected return was only 6.14% of the first stage expected return. By simply scaling the obj. function, the solutions obtained were much better. With scale $1 \times 10^4$, the solutions were on average 99.95% as good as those of the first stage. This difference is directly caused by numerical inaccuracies, it also illustrates why we chose to adopt the simplistic objective of maximising return as it is not necessarily trivial to mitigate these problems with other objectives.

With round lots, the numerical issues still happen, but less prominently. The fact that the statistics with scales $1 \times 10^3$ and $1 \times 10^4$ are identical suggest that they might be non-existent for these particular values. On the other hand, the solver reaches the time limit more frequently. Even though most rebalances are solved quickly (as shown in the $90^{\text{th}}$-percentile), the solver still faced difficulties when faced with possibly the simplest portfolio optimisation problem.

In order to compare the quality of the Woodside solutions with those of our second stage, we employ the model with scale $1 \times 10^4$. We also include, in the second stage, the following additional constraints:

\begin{align}
m_i & \leq u^+ p &  i \in \N_1  & \label{eqLOT11}
\end{align}

Constraints (<ref>) are required or, otherwise, the second stage portfolio may invest above the upper limit in assets with high expected returns, which may unfairly lead to a portfolio expected return that is higher than the one obtained in the first stage. Note however that we do not impose this bound on cash, which could otherwise result in infeasible models. The cash limit must exist in the Woodside model since, on days with negative expected returns, the model may choose to invest everything in cash. While this could theoretically result in an advantage for the second stage, we observed that in all experiments in this section, all instances had positive expected returns as optimal solutions.

We display comparative results between Woodside and the second stage in-sample solutions in Table <ref>. We include results for various values for the initial investment.

1|c|[c]2*Lots     1c|[c]2*Initial
investment     4c|Woodside     3c|Second stage     7c|Difference

1cSuccess     1cMin     1cAvg     1c|Max     1cMin     1cAvg     1c|Max     1cMin     1c$P_{25}$     1cAvg     1cMedian     1c$P_{75}$     1cMax     1c|$< 0$

[c]5*Odd     100k            130      96.51      99.70      99.96      95.47      99.18      99.87       0.06       0.27       0.52       0.44       0.70       1.82          0

200k            132      98.59      99.84      99.99      98.10      99.60      99.93       0.04       0.13       0.25       0.21       0.34       0.66          0

500k            130      99.48      99.92     100.00      99.20      99.83      99.96      -0.00       0.04       0.09       0.07       0.12       0.33          1

1M              132      99.66      99.95     100.00      99.59      99.92      99.98      -0.03       0.01       0.03       0.03       0.05       0.17         20

5M              131      99.83      99.97     100.00      99.87      99.98     100.00      -0.14      -0.02      -0.02      -0.02      -0.01       0.03        114

[c]5*Round     100k            128      59.14      83.69      95.43      21.68      50.53      78.24      15.14      25.54      33.11      34.28      38.55      59.14          0

200k            128      82.70      93.16      98.57      43.81      73.29      90.50       6.31      13.67      19.74      18.47      25.18      40.82          0

500k            129      91.96      97.53      99.36      74.18      89.28      96.64       2.61       5.77       8.26       7.25      10.64      20.12          0

1M              130      92.62      98.77      99.71      87.84      94.70      98.32       1.16       2.80       4.10       3.58       5.09      10.45          0

5M              131      98.98      99.74      99.93      96.75      98.96      99.69       0.20       0.51       0.78       0.66       0.93       2.69          0

Comparison of expected return decay (against the first stage lot-unconstrained optimal solutions) between the Woodside model and the second stage for various values for the initial investment. $P_{\alpha}$ denotes the $\alpha^{\text{th}}$ percentile.

Under label Woodside, column Success shows in how many rebalances the solver was able to find a feasible solution within 900s. The other columns are basic statistics regarding the decay in expected return when comparing the solutions against the lot-unconstrained first stage solutions. The same statistics are also shown for the second stage under label Second stage. We then take the difference between the decays observed in Woodside and the second stage for each rebalance, and show corresponding statistics under label Difference. Only successful Woodside rebalances are included in this calculation. The last column, labelled $\mathbf{< 0}$, shows in how many rebalances the Woodside solution was actually worse than the second stage solution. Since all expected returns are positive this can be either caused by numerical inaccuracies or suboptimal Woodside solutions. In all rebalances where this happened, however, Woodside found the optimal, so numerical errors account for all of them.

With a smaller initial investment, and especially with rounds lots, the less likely both Woodside and the second stage are to find solutions that approximate well that of the first stage. With odd lots, with a small initial investment of $\$100\text{,}000$ the differences are minor: the second stage obtained expected returns that were on average 0.52% worse than those of Woodside. As the initial investment increases, numerical errors appear more often while solving Woodside: with $\$5$ million, in 114 out of 131 successful rebalances the Woodside solution was actually worse than that of the second stage.

With round lots, however, we observe more benefits in using a single-stage approach. In Table <ref> we had noticed a smaller effect of numerical errors in Woodside, here in every successful rebalance Woodside found a better solution than the second stage. This does not mean that numerical errors did not happen, but we also cannot state that they did. With an initial investment of $\$100\text{,}000$, the Woodside expected returns were on average $33.11$% closer than the second stage to the first stage solutions. This difference reduces gradually until, with $\$5$ million, they become all smaller than $1\%$.

From these results, we can conclude that there is clear a case where employing lots and costs in the first stage is advantageous, as observed in the round lots and small initial investment results in Table <ref>. However, any investor that chooses to do so must be careful with the accuracy of solutions due to the problems exposed in this section. In this sense, the second stage can be employed as a tool for judging the quality of the single stage approach since, due to the separation of relative and absolute variables in different models, numerical errors are much less likely to occur.

§.§ Case study: leverage

Let $\beta_{\text{S\&P500}} = \frac{\sigma(r, b)}{\sigma(b, b)}$, where $r$ represents the out-of-sample returns of the investment strategy, $b$ the out-of-sample S&P500 returns and $\sigma(x, y)$ the sample covariance between $x$ and $y$. Traditionally, one expects a long only strategy that only invests in S&P500 stocks to have $\beta_{\text{S\&P500}}$ close to 1. In a market neutral strategy, on the other hand, we look for $\beta_{\text{S\&P500}}$ to be close to 0. The potential advantage of this approach is reducing exposure to market risk.

A traditional way to create market neutral portfolios is by purchasing short positions in the index. Suppose a portfolio composed of 50% in long positions in S&P500 stocks and 50% in an unleveraged short position in S&P500 futures. If we isolate the long part of the portfolio and find that it has $\beta_{\text{S\&P500}} = 1$, then we have a perfect market neutral strategy. The only problem with this approach is that there is no assurance that the strategy expected return will be different from zero. We may adopt then an active strategy by looking to outperform the index while enforcing market neutrality, so with this objective we employ the same SSD approach from [34] for choosing SSD-dominating “market neutral” portfolios. This may not yield exactly $\beta_{\text{S\&P500}} = 0$, but may be good enough for the purpose of the investment policy in effect.

Now when we consider leverage we have further options in building market neutral strategies. If we adopt a $2\times$ leverage for the short position in S&P500 futures, then we might invest $66.7\%$  in long and $33.3\%$ in a short with the same effect. Likewise, with $3\times$ leverage we can adopt $75\%$ and $25\%$ proportions. A potential advantage of this approach is that the solver has more “freedom” in building SSD-dominating portfolios by having more capital available to invest in long positions.

In this section, we illustrate this approach. We adopt an odd lots policy and remove all derivatives from the long only strategy from Section <ref>, so with an asset universe with exclusively stocks participating in the S&P500. We restrict the out-of-sample period to be from $31^{\text{st}}$ December 2019 until $29^{\text{th}}$ December 2023. In the market neutral strategies, we set $\upsilon^- = \upsilon^+ = [0.50, 0.33, 0.25, 0.20]$. Let  be the asset identifier for S&P500 futures. We also set $\varepsilon_{\text{SP500FUT}} = \delta_{\text{SP500FUT}} = [-0.50, -0.33, -0.25, -0.20]$[This notation is found in the appendix.] and $L_{\text{SP500FUT}} = [1, 2, 3, 4]$.

Results for these strategies are shown Figure <ref> and Table <ref>. To avoid clutter, Figure <ref> displays only 3 of the 5 strategies, the lines are also smoothed with univariate splines.

Out-of-sample cumulative performance, long only and long/short market neutral experiments.

1|c|Strategies     1cFV     1cCAGR     1cVol     1cMDD     1cSharpe     1cSortino     1c|$\beta$

Long only                                         2.07        19.99        24.59        26.35         0.77         1.11        0.724

Market neutral, $L_{\text{SP500FUT}} = 1$         1.57        12.00        17.96        14.02         0.60         0.86        0.097

Market neutral, $L_{\text{SP500FUT}} = 2$         1.79        15.70        19.92        16.05         0.72         1.05        0.110

Market neutral, $L_{\text{SP500FUT}} = 3$         1.84        16.55        20.73        17.72         0.73         1.09        0.093

Market neutral, $L_{\text{SP500FUT}} = 4$         1.86        16.81        20.96        18.70         0.74         1.10        0.084

SP500                                             1.48        10.24        23.01        33.92         0.44         0.61     –

Comparative out-of-sample statistics

Table <ref> displays the same statistics as Table <ref>, with $\beta_{\text{S\&P500}}$ as an additional column. Here the long only strategy outperformed the S&P500, growing 107% in the period, but also had a (high) $\beta_{\text{S\&P500}} = 0.724$. By adopting the unleveraged market neutral strategy, $\beta_{\text{S\&P500}}$ was reduced to $0.097$, but we also reduced the out-of-sample returns (up 57%) by adopting a short position in S&P500 (which increased 48% in value during this period). By employing leverage, we are able to gradually improve returns (up to 86% with $L_{\text{S\&P500}} = 4$) while maintaining similar $\beta_{\text{S\&P500}}$ levels. Note also that, by adding leverage, we also observed a small increase in risk (Vol, MDD), not enough however to offset the increase in risk-adjusted returns (Sharpe, Sortino). Even with $4\times$ leverage, both drawdown and volatility were lower than the same statistics for both S&P500 and the long only strategy.

In summary, if used with care, leverage has the potential to improve returns in a strategy without necessarily increasing risk. This was one of the main motivators in including futures contracts in our two-stage framework, and in our view opens up different research possibilities.

§ MANAGERIAL INSIGHTS

So far, we have considered several real-world features in our standardised two-stage framework. While we hope that this helps bridging the gap between theory and practice in portfolio selection, the list of features included is far from exhaustive. Different exchanges enforce different rules and financial instruments are subject to area-specific conditions. In this section we discuss practical aspects and features not yet considered, and which could consist in future extensions of this framework.

In a practical sense, current (live) asset prices are required for applying the second stage. An assumption we made implicitly is that, once a second stage decision is made, assets are to be traded at prices $V_i$. In cases where solving the second stage requires a few seconds (or more), real trading prices might deviate from the expected, and which in extreme cases could render the suggested portfolio not directly investable. To mitigate this issue, one could (i) trade at the end of the day, which is generally less volatile and/or (ii) impose a penalty at the price used in the second stage (if we are expecting an asset to be bought, increase its current price by a factor). If the second stage execution time is negligible, most likely these changes will be minor and random (sometimes upwards, sometimes downwards), with little observable effect.

Another important issue not yet mentioned is liquidity. The second stage may suggest trades that are too illiquid when we compare its size to the average trading daily volume for the asset under consideration. There are three possible ways to tackle this: (i) by adding turnover constraints in the first stage, (ii) by limiting the size of trades that can be recommended in the second stage as a function of the investment size and volume or (iii) by adopting trading policies after the second stage. One example of policy commonly adopted (for infrequently rebalanced portfolios) is to split large trades into small ones, executed throughout multiple days. A possible extension of the two-stage approach is to make it multistage: Within the next days, suggest trades in multiple days such that not only the final portfolio matches the recommended one as close as possible, but so do the temporary portfolios within the limits of liquid trades.

[6] also proposed a two-stage approach which uses relative variables in both stages. It was constructed to satisfy the requirements of a specific enterprise with specific goals, also since it does not use absolute variables some functions (such as costs and liquidity) have to be approximated rather than being modelled with real values. However some considerations under that approach could be adopted into the second stage, such as minimising the number of trades or the deviation not only per individual asset, but also per asset class. Another possibility is to reformulate the objective function of the second stage in order to minimise the maximum deviation instead of the sum of deviations.

We have also not included dividends nor other cost functions. We have dealt with dividends so far at data level by assuming prices that are adjusted immediately prior to solving the first and second stages. Regarding costs, our limited practice suggests that other cost functions such as fixed or piecewise convex or concave cost are either less common or can be eliminated through negotiation with brokers (although the latter is sometimes used to approximate liquidity). The second stage could however be extended to include these.

Finally, we have not considered the issue of taxes, which might have to be paid when closing certain positions. This is very region-specific; in certain situations we have observed that funds are exempt from paying taxes during operations, but have to pay them when clients request a withdrawal. We have also observed a situation where the government charges taxes periodically. We are yet to study how to incorporate these generically into the two-stage framework.

§ CONCLUSIONS

In this paper, we propose a two-stage approach with the goal of building portfolios that can be directly translated into real-world investment. The main contribution of our paper is in providing a tool that more closely constructs directly investable portfolios, and we hope this approach helps in reducing the gap between computational financial decisions and actual investing. One particular application is in facilitating purely automated investment tools. In our framework we also explicitly consider, for the first time, mixing futures contracts and equities in the same portfolio.

The first stage consists in solving the portfolio selection problem and deciding appropriate weights. At this stage several real-world constraints, most previously proposed in literature, are applicable. In the second stage, we propose a goal-programming approach whose main decision variables are shares to be held for each asset. At this stage, we consider other real-world criteria which require an absolute formulation, such as lots and costs. Another novel contribution of this paper is in considering also borrowing costs for short positions.

We present extensive computational results that discuss the second stage applicability. We also compare our approach with a mixed approach from the literature, and conclude that among other issues mixed formulations are susceptible to numerical inaccuracies. Our results suggest that in most cases the benefits of employing a single stage with regards to a two-stage approach are somewhat marginal. Regardless, whenever it is advantageous this single stage approach can be “condensed” into our proposed first stage as part of the complete two-stage framework.

Several research lines can be explored as future work, some of them have been mentioned in Section <ref>. On top of that we also hope to expand the framework to support other asset classes such as options and fixed-income instruments. We intend to explore combinatorial optimisation techniques and possibly alternative reformulations for improving the second stage computational performance in more extreme scenarios.

§ CONFLICTS OF INTEREST

None declared.

§ ACKNOWLEDGEMENTS

Cristiano Arbex Valle was funded by FAPEMIG grant APQ-01267-18.

[1]
Chistopher J. Adcock and Nigel Meade.
A simple algorithm to incorporate transactions costs in quadratic
European Journal of Operational Research, 790
(1):0 85–94, 1994.

[2]
Enrico Angelelli, Renata Mansini, and M Grazia Speranza.
A comparison of MAD and CVaR models with real features.
Journal of Banking & Finance, 320 (7):0
1188–1197, 2008.

[3]
Enrico Angelelli, Renata Mansini, and M Grazia Speranza.
Kernel search: A new heuristic framework for portfolio selection.
Computational Optimization and Applications, 510
(1):0 345–361, 2012.

[4]
Mike C Bartholomew-Biggs and SJ Kane.
A global optimization problem in portfolio selection.
Computational Management Science, 60
(3):0 329–345, 2009.

[5]
Philipp Baumann and Norbert Trautmann.
Portfolio-optimization models for small investors.
Mathematical Methods of Operations Research, 770
(3):0 345–356, 2013.

[6]
Dimitris Bertsimas, Christopher Darnell, and Robert Soucy.
Portfolio construction through mixed-integer programming at
Grantham, Mayo, Van Otterloo and Company.
Interfaces, 290 (1):0 49–66, 1999.

[7]
Pierre Bonami and Miguel A Lejeune.
An exact solution approach for portfolio optimization problems under
stochastic and integer constraints.
Operations Research, 570 (3):0
650–670, 2009.

[8]
T-J Chang, Nigel Meade, John E Beasley, and Yazid M Sharaiha.
Heuristics for cardinality constrained portfolio optimisation.
Computers & Operations Research, 270
(13):0 1271–1302, 2000.

[9]
Luca Chiodi, Renata Mansini, and Maria Grazia Speranza.
Semi-absolute deviation rule for mutual funds portfolio selection.
Annals of Operations Research, 124:0 245–265,

[10]
CPLEX Optimizer 22.1.0.
IBM. Available from
last accessed October 17th 2023, 2023.

[11]
Gianfranco Guastaroba, Renata Mansini, and M Grazia Speranza.
Models and simulations for portfolio rebalancing.
Computational Economics, 330 (3):0
237, 2009.

[12]
John C Hull.
Options futures and other derivatives, 9th edition.
Pearson, 2014.

[13]
Bruce I Jacobs, Kenneth N Levy, and Harry M Markowitz.
Portfolio optimization with factors, scenarios, and realistic short
Operations Research, 530 (4):0
586–599, 2005.

[14]
Norbert J Jobst, Michael D Horniman, Cormac A Lucas, and Gautam Mitra.
Computational aspects of alternative portfolio selection models in
the presence of discrete asset choice constraints.
Quantitative Finance, 10 (5):0
489–501, 2001.

[15]
Hans Kellerer, Renata Mansini, and M Grazia Speranza.
Selecting portfolios with fixed costs and minimum transaction lots.
Annals of Operations Research, 990
(1-4):0 287–304, 2000.

[16]
Petter N Kolm, Reha Tütüncü, and Frank J Fabozzi.
60 years of portfolio optimization: practical challenges and current
European Journal of Operational Research, 2340
(2):0 356–371, 2014.

[17]
Ritesh Kumar, Gautam Mitra, and Diana Roman.
Long-short portfolio optimisation in the presence of discrete asset
choice constraints and two risk measures.
Available at SSRN 1099926, 2008.

[18]
Duan Li, Xiaoling Sun, and Jun Wang.
Optimal lot solution to cardinality constrained mean–variance
formulation for portfolio selection.
Mathematical Finance, 160 (1):0
83–101, 2006.

[19]
Chang-Chun Lin and Yi-Ting Liu.
Genetic algorithms for portfolio selection problems with minimum
transaction lots.
European Journal of Operational Research, 1850
(1):0 393–404, 2008.

[20]
Renata Mansini and M Grazia Speranza.
An exact approach for portfolio selection with transaction costs and
IIE Transactions, 370 (10):0 919–929,

[21]
Renata Mansini and Maria Grazia Speranza.
Heuristic algorithms for the portfolio selection problem with
minimum transaction lots.
European Journal of Operational Research, 1140
(2):0 219–233, 1999.

[22]
Renata Mansini, Wlodzimierz Ogryczak, and M Grazia Speranza.
Twenty years of linear programming based portfolio optimization.
European Journal of Operational Research, 2340
(2):0 518–535, 2014.

[23]
Renata Mansini, WĹodzimierz Ogryczak, and M Grazia Speranza.
Linear and mixed integer programming for portfolio
optimization, volume 21.
Springer, 2015.

[24]
H. Markowitz.
Portfolio selection.
The Journal of Finance, 70 (1):0
77–91, 1952.

[25]
Gautam Mitra, Triphonas Kyriakis, Cormac Lucas, and Mehndi Pirbhad.
A review of portfolio planning: models and systems.
In Advances in portfolio construction and implementation,
pages 1–39. Butterworth-Heinemann, 2003.

[26]
Andre F. Perold.
Large-scale portfolio optimization.
Management Science, 300 (10):0
1143–1160, 1984.

[27]
Gerald A. Pogue.
An extension of the Markowitz portfolio selection model to include
variable transactions' costs, short sales, leverage policies and taxes.
The Journal of Finance, 250 (5):0
1005–1027, 1970.

[28]
D. Roman, G. Mitra, and V. Zverovich.
Enhanced indexation based on second-order stochastic dominance.
European Journal of Operational Research, 2280
(1):0 273–281, 2013.

[29]
Andrew Rudd and Barr Rosenberg.
Realistic portfolio optimization, pages 21–46.
North-Holland Publishing Company, 1979.
ISBN 0444852794.

[30]
John Schreiner.
Portfolio revision: a turnover-constrained approach.
Financial Management, pages 67–75, 1980.

[31]
M. Grazia Speranza.
A heuristic algorithm for a portfolio optimization model applied to
the Milan stock market.
Computers & Operations Research, 230
(5):0 433–441, 1996.

[32]
C. A. Valle, N. Meade, and John E. Beasley.
Absolute return portfolios.
Omega, 450 (0):0 20–41,

[33]
C. A. Valle, N. Meade, and John E. Beasley.
Market neutral portfolios.
Optimization Letters, 80 (7):0
1961–1984, 2014b.

[34]
C. A. Valle, D. Roman, and G. Mitra.
Novel Approaches for Portfolio Construction Using Second Order
Stochastic Dominance.
Computational Management Science, 140
(2):0 257–280, 2017.

[35]
M Woodside-Oriakhi, C Lucas, and John E Beasley.
Portfolio rebalancing with an investment horizon and transaction
Omega, 410 (2):0 406–420, 2013.