|
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
|
Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() returns the bytes to save (valid until the strategy's next hook; the engine copies them at once) and bool restore(std::string_view) takes the bytes saved before, false when they are not this strategy's (it then starts fresh).
More...
#include <fastmm/strategies/hooks.hpp>
Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() returns the bytes to save (valid until the strategy's next hook; the engine copies them at once) and bool restore(std::string_view) takes the bytes saved before, false when they are not this strategy's (it then starts fresh).
The engine calls restore once, after on_start and before the first event (and again at a warm standby's take-over, or a backtest's start_at), and state() every state_interval_s, at the end, at every [engine] checkpoint_s for the journal, and never from inside another hook. The bytes are the strategy's own format. With a journal, the bytes handed to restore() and the checkpoints are journaled (StrategyStateMsg), so a replay restores them too and a backtest can start from any checkpoint.