jankrepl / deepdow

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

Is horizon = 1 possible? #144

Closed craig3141 closed 1 year ago

craig3141 commented 1 year ago

Thanks for deepdow, which I'm trying to understand.

I ran your getting started example code, but with lookback, gap, horizon = 40, 2, 1 rather than lookback, gap, horizon = 40, 2, 20 and it produced test_loss=nan.

Is there something wrong with setting horizon to 1?

Many thanks!

jankrepl commented 1 year ago

@craig3141 Thanks for your interest.

There should be nothing wrong with it:)

craig3141 commented 1 year ago

Ok, thanks. But then test_loss is always nan and the code fails. I put this example in https://colab.research.google.com/drive/1Xik7EM0uCfUiQ-Q-lXzQkp8ujBShqztm?usp=sharing. Please advise. Thanks!

craig3141 commented 1 year ago

So, is there anything that can be done to make the usable for horizon=1?

jankrepl commented 1 year ago

@craig3141 sorry for a late response.

I actually take back what I said above. Certain losses (e.g. ShareRatio) will need more than 1 sample in order to obtain legal values (otherwise there will be division by zero). But I am actually not sure, since there is always an eps > 0 that tries to prevent this from happening. Might be something different

However, if you only use the loss/metric MeanReturn things should work.

Hope that helps:) Feel free to report further issues and I might give it a closer look.

craig3141 commented 1 year ago

Of course, thank you!