alpha-rptr
alpha-rptr copied to clipboard
Adding Session Persistence using JSON
You can specify to save the state of a strategy to a json file using --session switch followed by a filename.
--session strategy.json
Inside your strategy, you need to declare your persisted state variables as self.session.xxxx inside the __init__ menthod of the strategy class. Only inbuilt types are supported. Refer to types supported by JSON module for more info.
You can then read the session state from a session file while restarting bot. You will be prompted to accept the found session before proceeding.
Extreme caution is advised when using session persistence.