How to exit the bot on a 'completed' live run


#1

I have a bot that I want to terminate after achieving a certain goal - determined by the code.

If I exit via sys.exit() then the the .pickle file isn’t created.

How do we shut down a bot nicely?

Also: what’s a recommended way to distinguish between Backtesting mode and live/paper mode? I want the bot to keep running when being backtested.


#2

Hi,
Currently, the only way to have a graceful finish on live/paper is to specify an end_date when starting the algo. We hope to implement an immediate graceful termination as well in the near future.

In order to distinguish between the different modes you can use context.mode_name.