jankrepl / deepdow

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

how to setup deepdow for inference mode #87

Closed turmeric-blend closed 3 years ago

turmeric-blend commented 3 years ago

in this case the data prepared and passed through the dataloader/model would not have a label y

jankrepl commented 3 years ago

Not sure if I am helping you much with this answer, but you simply need to create the feature tensor X.As opposed to training, it would probably have the batch dimension equal to 1 (that is(1, n_channels, lookback, n_assets)). I would imagine you just take the most recent market information that is available today and convert them to X.

If you are asking whether there is some automated way to do this (similarly to raw_to_Xy for training), the answer is no. However, creating this 1 tensor should be easy because you can take your script that generated training data (e.g. raw_to_Xy) and adjust it (not caring about y and previous days).

Once you have the X, then network(X) will give you the portfolio weights. By the way, just to be be on the safe side, make sure you run network.eval() before your forward pass so that all the layers of the network are in inference mode.

turmeric-blend commented 3 years ago

I guess I was thinking if there is a dataloader and Run method of doing inference, but now that u mentioned it I guess I was over complicating things.

Once you have the X, then network(X) will give you the portfolio weights. By the way, just to be be on the safe side, make sure you run network.eval() before your forward pass so that all the layers of the network are in inference mode.

this works just fine. Thanks :)