|
FastMM C++ API 0.6.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 state() every state_interval_s, at the end, every state_snapshot_interval_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() are journaled (StrategyStateMsg), so a replay restores them too and a backtest can start from them.