I have tried to use SP500 data to reproduce this code, and change some sql sequence. But, when i run the code,the loss and portfoilio_value is nan. My data and running result are shown below.


I wonder to know if the data needed to be preprocessed before run the code like normalization or anything else.
Looking forward to your reply!