Kismuz / btgym

Scalable, event-driven, deep-learning-friendly backtesting library
https://kismuz.github.io/btgym/
GNU Lesser General Public License v3.0
985 stars 260 forks source link

Kernel died with basic example #5

Closed AdrianP- closed 7 years ago

AdrianP- commented 7 years ago

Hi, nice work with btgym, I was working in a similar project (https://github.com/AdrianP-/gym_trading) and I wanted to integrate RL with a zipline/pyalgotrader/etc, but you already did it! Please send me a email :)

However I tried your examples and my kernel always die in MyEnvironment = gym.make('backtrader-v46'). Commenting this line everything works well :D. Why is necessary?

Kismuz commented 7 years ago

@AdrianP- ,

Well, that's exactly the case described in More control section comments:

# Other parameters:

# Network port to use; note that using multiply environments at once reqires expliciltly
# setting different ports to avoid meesing up. If your jupyter kernel suddenly dies
# when running new environment - that's may be because of port conflict,
# or 'previous' environment instance (client-side) is still running.
# Don't panic, just clear up and restart kernel,
# or use env.close() to shut down all the services.
port=5555,

But I think it's not proper way to show environment configuration, so I'll change code a bit, adding env.close() calls after each example. That's a proper way of handling environments and will solve the problem. Please update your repository.