Skip to main content

Persistent storage

Gunbot executes custom strategy code every time it processes a pair. Therefore, any variables assigned inside the strategy are reset each time the code runs.

To store variables persistently, use the object By default, customStratStore is undefined and must be created before data can be stored in it.

// initialize customStratStore within pairLedger object = || {};

Data saved in this object usually remains accessible and persists even when the bot restarts. However, there is no guarantee that the data will remain intact. For example, if the process is terminated, the pair ledger may be reset on the next run. Gunbot's built-in strategies rely as little as possible on persistently stored data and instead work with exchange-provided data. When creating custom strategies, it is recommended to follow the same practice.