stefan-jansen / machine-learning-for-trading

Code for Machine Learning for Algorithmic Trading, 2nd edition.
https://ml4trading.io
12.85k stars 4.11k forks source link

Chapter 12 - Backtesting #91

Closed jmg17 closed 3 years ago

jmg17 commented 3 years ago

In : => Chapter 12_gradient_boosting_machines => Long-Short Strategy, Part 6: Backtesting with Zipline => Run algorithm Crash kernel with this return :

Traceback (most recent call last): File "zipline/gens/sim_engine.pyx", line 102, in iter GeneratorExit

Zipline “demo” is OK All steps of long_short strategy are OK lgb/train/01 and lgb/test/01 are OK Memory is not full What I’am doing wrong? Thank for your replay JMG

PS : I get exactly same kernel crash in : Chapter 08 => ML4T Workflow with zipline

stefan-jansen commented 3 years ago

I just ran the backtesting notebook in Chapter 12 (I have cleaned up the boosting notebooks ~4 weeks ago and it is now 09_backtesting_with_zipline.ipynb using the ml4t-zipline environment without any issues.

It is hard to say what the issue is because Zipline tends to fail silently except for the GeneratorExit message when things go wrong while executing the algorithm. I have also seen this error when trying to recreate the environment using conda with slightly different versions of any of the packages. Are you using Docker and the original notebook or did you make any changes to either?

jmg17 commented 3 years ago

I use conda (Anaconda3) on ubuntu 20.04 and create ml4t-zipline environment without any change. Same "Generator exit" message appears in Chapter 08 => ML4T Workflow with zipline. Would docker solve the problem ? I do not see why.

stefan-jansen commented 3 years ago

I've successfully tested the code using Docker. I would give it a try. The main reason I've provided the image is that it's unfortunately not straightforward to replicate the environment given the (fairly old) Zipline dependencies on the Python and OS side. Would be great to update the software but I haven't been able to find the time yet.

jmg17 commented 3 years ago

OK I will try to use docker Thank you

stefan-jansen commented 3 years ago

Feel free to reopen if you run into any issues with installation or running the Zipline notebooks.