alpha-rptr icon indicating copy to clipboard operation
alpha-rptr copied to clipboard

Adding Session Persistence using JSON

Open praveenbm5 opened this issue 3 years ago • 0 comments

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.

praveenbm5 avatar Aug 08 '22 10:08 praveenbm5