jankrepl / deepdow

Portfolio optimization with deep learning.
https://deepdow.readthedocs.io
Apache License 2.0
875 stars 136 forks source link

What is the relationship between mean-variance based Allocator layer and loss function? #95

Closed turmeric-blend closed 3 years ago

turmeric-blend commented 3 years ago

Hi sorry for so many questions this is a learning process for me.

What is the relationship between mean-variance based Allocator layer and loss function?

From my limited understanding, there are other mean-variance approaches besides Markowitz, for example Sharpe Ratio and Risk Parity. So if were to be using Sharpe Ratio as my loss function, wouldn't it be more suitable to also use an allocator based on Sharpe Ratio as well, thus performing convex optimization on a convex version of Sharpe Ratio. Similar with Risk Parity and other mean-variance approaches that are able to be converted to a convex form. Does this makes sense? Or would the performance be similar to using Sharpe Ratio as loss function with Markowitz allocator for example.

jankrepl commented 3 years ago

I more than appreciate the questions:)

The general philosophy behind deepdow is that the loss function is king. It represents the actual performance of your strategy. Ideally, one would want to throw a lot of data at the network (that has a reasonably flexible architecture) and not even care what it does in the background.

With that being said, the network architecture and especially the final allocation layer, can be used as a prior. In other words, it is a way how to encode some domain knowledge that could potentially help the network do a better job than having let's say a plain softmax at the end.

To comment on what you said, matching the loss and the cvxpy objective is definitely a possibility. Check out this example where it is demonstrated that deepdow can actually arrive at the same results standard convex optimization https://deepdow.readthedocs.io/en/latest/auto_examples/end_to_end/iid.html#sphx-glr-auto-examples-end-to-end-iid-py

However, in general the final allocation cvxpy layer can be preceded by multiple other layers that output a covariance matrix and expected return vector that do not correspond to their empirical counterparts at all. In this case, one can see the cvxpyallocation layer as a nice way how to guarantee that the weights sum up to 1 + other constraints. However, one cannot really give the convex optimization any real word interpretation. That is why the loss function is the only thing that really matters.

turmeric-blend commented 3 years ago

Thank for your insights. I might try to code up some Risk Budgeting/Parity and Sharpe Ratio allocation layers if its possible.

jankrepl commented 3 years ago

The corresponding PR #98

jankrepl commented 3 years ago

The risk budgeting was done.