jankrepl / deepdow

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

Dealing with Cash Asset #81

Closed turmeric-blend closed 3 years ago

turmeric-blend commented 3 years ago

Hi thanks for this project it is very insightful. I was wondering how does deepdow deal with cash asset?

For example, cash could be inserted with any other asset price, but the prices would all be 1 in this case as asset prices are all relative to the dollar. On the other hand, cash also could be added at the end as a bias as described in Figure 2 of this paper.

jankrepl commented 3 years ago

Hey there, thank you for the question!

deepdow has no additional logic that would treat cash differently from other assets. So personally I would do as you suggested - represent it as an asset with a constant price (zero returns).

I quickly browsed through the paper and it is not really clear to me what exactly they are doing with the "cash bias" and how do they combine it with the softmax over assets.

turmeric-blend commented 3 years ago

I quickly browsed through the paper and it is not really clear to me what exactly they are doing with the "cash bias" and how do they combine it with the softmax over assets.

well they just add an extra dimension (n+1) to the asset dimension (n) at a last layer, pass it through a linear layer to learn this cash asset, and then softmax.

I guess the different ways of including cash is just determined by the performance as its unclear how well a neural network would learn if one of its input features doesn't change (constant 1s for cash).

jankrepl commented 3 years ago

I quickly browsed through the paper and it is not really clear to me what exactly they are doing with the "cash bias" and how do they combine it with the softmax over assets.

well they just add an extra dimension (n+1) to the asset dimension (n) at a last layer, pass it through a linear layer to learn this cash asset, and then softmax.

I see, so that means that their cash bias is learned and it represents the absolute value (e.g. in dollars) of cash we hold? That also means that we always hold the same amount of cash once their network is trained, doesn't it?

I guess the different ways of including cash is just determined by the performance as its unclear how well a neural network would learn if one of its input features doesn't change (constant 1s for cash).

I guess the network will just use this asset to decrease risk (as expected). It should quickly learn during training that the value never changes and that it is a "safe bet". Personally, I do not really see any downsides to this approach. But maybe I am missing something:)

turmeric-blend commented 3 years ago

I see, so that means that their cash bias is learned and it represents the absolute value (e.g. in dollars) of cash we hold? That also means that we always hold the same amount of cash once their network is trained, doesn't it?

the cash bias is parameterized and learned so the output (fractional weights) changes depending on the in put asset (non-cash) prices.

I guess the network will just use this asset to decrease risk (as expected). It should quickly learn during training that the value never changes and that it is a "safe bet". Personally, I do not really see any downsides to this approach. But maybe I am missing something:)

yes I agree with you, but I guess the point they are making is that there might be a more computationally efficient way to encode cash into the network since it could be treated as a constant anyway.

This might be a bit tricky since most applications of neural networks I've seen usually do not apply constants in such a way (as of my knowledge anyway), and you could say this cash bias method is one way of doing so, although how useful it is could be questionable in its effectiveness.

Having said this, cvxpy and doing convex optimization could be an interesting way of imposing this cash constant as a hard constraint.

jankrepl commented 3 years ago

Yeh, using cvxpy can definitely be a way how to control the cash. Anyway, if you have any specific ideas feel free to create a pull request!:))

turmeric-blend commented 3 years ago

yep once I get familiar with cvxpy and have any ideas I'll let you know! Thanks.