18 std::string_view contents);
35 bool* wrapped =
nullptr);
57 [[nodiscard]]
static std::string
default_path(std::string_view journal_dir,
58 std::string_view engine_name);
Definition session_state.hpp:56
static std::string default_path(std::string_view journal_dir, std::string_view engine_name)
"<journal_dir>/<engine name>.kill".
static Result< KillState, std::string > load(const std::string &path)
A missing file is a cleared state; a file that cannot be read or parsed is an error.
static Result< void, std::string > clear(const std::string &path)
Removes the file (an operator clearing a latched trip and the loss budget with it).
static Result< void, std::string > store(const std::string &path, const KillState &s)
The 16-bit session epoch is the high half of every ClientOrderId, so two sessions that share one woul...
Definition session_state.hpp:30
static Result< std::uint16_t, std::string > next_epoch(const std::string &path, bool *wrapped=nullptr)
Reads the durable counter, increments it, writes it back and returns the epoch to use (1....
Minimal expected<T, E>: the hot path never throws, it returns Result.
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Definition strategy.hpp:16
Result< bool, std::string > load_strategy_state(const std::string &path, std::string &out)
The strategy state file ([strategy] state_file, written by write_file_atomic): its bytes,...
KillReason
Why a kill switch (global or one venue's) was tripped.
Definition enums.hpp:523
Result< void, std::string > write_file_atomic(const std::string &path, std::string_view contents)
Writes contents to path atomically: <path>.tmp, fsync, rename, fsync of the directory.
Cumulative risk state across sessions.
Definition session_state.hpp:44
Notional carry() const noexcept
The carry [risk] max_loss is measured against, on top of the running session's PnL.
Definition session_state.hpp:53
Notional realized
Definition session_state.hpp:47
std::int64_t updated_ns
wall clock of the last write
Definition session_state.hpp:50
KillReason reason
Definition session_state.hpp:46
bool latched
a max-loss trip is latched: refuse to start until an operator clears it
Definition session_state.hpp:45
std::uint64_t sessions
Definition session_state.hpp:49
Notional fees
Definition session_state.hpp:48