Skip to content
All library documents

Why a Greedy Crystal-Ball Portfolio Strategy Can Fail With Fees

Article Quant Q&A · Author: KlaasNotFound

Summary

The document asks how to compute the hindsight-optimal sequence of holdings across a universe of stocks when an investor can trade daily, compounds returns, pays transaction fees, and cannot short. It considers dynamic programming and presents an attempted shortcut: move into the asset with the highest next-period growth, adjusting the comparison for a fee when switching. The post initially claims this greedy rule matches a dynamic-programming solution when trades are unrestricted.

An edit retracts that claim and gives a counterexample: with a constant-growth holding, a faster-growing alternative, and a sufficiently large switching fee, the adjusted one-step comparison can favor staying put even though the proposed path is not globally optimal. The key lesson is that local growth comparisons need not solve a multistep optimization problem once trading costs affect future choices. The document gives no corrected algorithm, formal complexity analysis, or general proof, so readers should treat the proposed shortcut as refuted and the optimization problem as unresolved here.

Key ideas

  • The problem seeks a hindsight-optimal sequence of holdings with compounding, trading fees, and no short selling.
  • A proposed greedy rule selects the asset with the strongest next-step growth, adjusted for switching costs.
  • The document later retracts the claim that this greedy method matches dynamic programming.
  • The counterexample shows that a one-step comparison can fail to capture the best multistep path.

Tags

Full text
# How to (efficiently) calculate the maximum possible return of a perfect "crystal ball" investment strategy?


# How to (efficiently) calculate the maximum possible return of a perfect "crystal ball" investment strategy?












I am new to the world of investing, so please excuse the clumsy wording of the question... there is probably a better term for what I am looking for or maybe this is even a known/classic problem. If so, please kindly point me in the right direction ;-)

#### Motivation

Investment strategies are compared against "the market", which is usually some weighted index of some / all securities in a given universe. However, the choice of market portfolio is somewhat arbitrary when it can be defined by the investor. A comparison of the alpha / performance of two investors' strategies could be quite difficult when one investor benchmarks her strategy against market portfolio A, while another benchmarks it against market portfolio B.

Thinking about this problem I ended up with the following idea: Why not compare every strategy against the hypothetical optimal return that could be achieved within the relevant universe and time frame if one had a crystal ball, i.e. by magically buying / selling the combination of securities that would lead to maximum return?

For each set of investment constraints, there is (usually) only one such optimal strategy and thus the "Crystal Ball Return" would be the ideal reference for objective comparisons of investment strategies.

#### The Problem

For the sake of simplicity let's assume we have a universe that consists of `n` stocks (with end-of-day prices) and are looking at an investment time frame of `d` trading days. We're investing a pre-defined amount of money `m` (enough to buy at least one of each stock) and there is small but non-negligible fee `f` for every transaction. We can change the portfolio (buy/sell stocks) once a day, but we don't have to. All returns are compounded. UPDATE: To keep it simple (and the returns bounded), short selling is not allowed.

My question is:

How does one efficiently calculate the sequence of buy/sell actions that leads to the maximum possible return?

To me this smells like dynamic programming, however, maybe I am missing something. The problem formulation seems so commonplace that I'm hoping there is a seminal paper / solution you can point me to.

If you provide a solution, please try to give some indication of its time / space complexity. Thank you.

Note: On first thoughts, fees seem to be a necessary constraint, since without them the optimal strategy would simply be to move all the money on a daily basis into the stock that's growing the most.

## Answer by wehnsdaefflae (score 3, accepted)

https://quant.stackexchange.com/a/53562

This answer seems to be wrong. Please read the edit and the comments.

To me, that smelled like dynamic programming too. After implementing a dynamic programming solution according to http://www.cs.rpi.edu/~magdon/courses/cf/notes/optimal.pdf and other sources from the same author, it dawned on me that dynamic programming might not really be necessary at all.

In the end, what you want is to put all your value into the single one asset $a_t $ whose price $r(a) $ will grow the most in the next time step among all assets $A $.

$$ a_t = \max_{x \in A}\Big(~\frac{r_{t+1}(x)}{r_t(x)}~\Big) $$

The "investment path" (series of target assets for each point in time) $[~a_0, a_1, ..., a_T ~] $ that results from the greedy solution above is identical to the one generated by the dynamic programming approach. In hindsight that also makes sense, really.

Things get a little more intricate when you have to consider fees, but not too much. To get the target asset at $t + 1 $ while considering fees, just take the $max $ like before but multiply the rate of growth of every asset different from the one you're holding at $t - 1 $ with $1. - fee $. (In case of constant fees, you'd have to multiply the ratio with the current value of your portfolio and subtract the fee from that for every $x \in A $.)

$$ a_t = \max_{x \in A}\Big(~\frac{r_{t+1}(x)}{r_t(x)} * \big(1. ~\text{if}~ x == a_{t-1} ~\text{else}~ (1. - fee) \big) ~\Big) $$

Dynamic programming still has a value here in case you have restrictions like maximum number of trades. If you don't however, I don't really see why to bother with it.

Edit: As mentioned in the comments, the simple greedy approach turned out not to be a replacement for the dynamic programming solution after all and it is not optimal.

Imagine two assets, the one you're holding is staying at the same valuation (continually growing by a factor of $ 1.0$), the other one continually growing by a factor of $ 1.1$, and the fees being 10% or $ 0.1$. Switching would require picking an immediate growth factor of $ \frac{1.1}{1} * (1 - 0.1) = 0.99 $ over a factor of $ 1.0$ for a constant growth by 10% in contrast to no growth at all. The method above, however, would never switch in such a scenario.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.