FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
session_state.hpp File Reference

State that survives a process restart: the session epoch (client order ids) and the latched risk state (kill switch and cumulative PnL). More...

#include "fastmm/core/enums.hpp"
#include "fastmm/core/fixed_point.hpp"
#include "fastmm/core/result.hpp"
#include <cstdint>
#include <string>
#include <string_view>

Go to the source code of this file.

Classes

class  fastmm::SessionEpochStore
 The 16-bit session epoch is the high half of every ClientOrderId, so two sessions that share one would let a venue's late message from the earlier session match an order of the later one. More...
 
struct  fastmm::KillState
 Cumulative risk state across sessions. More...
 
class  fastmm::KillStateStore
 

Namespaces

namespace  fastmm
 

Functions

Result< void, std::string > fastmm::write_file_atomic (const std::string &path, std::string_view contents)
 Writes contents to path atomically: <path>.tmp, fsync, rename, fsync of the directory.
 
Result< bool, std::string > fastmm::load_strategy_state (const std::string &path, std::string &out)
 The strategy state file ([strategy] state_file, written by write_file_atomic): its bytes, true when it exists, false when there is no such file (a first start); an error when it cannot be read.
 

Detailed Description

State that survives a process restart: the session epoch (client order ids) and the latched risk state (kill switch and cumulative PnL).

Both are text files next to the journal, written through a temporary file + fsync + rename, so a crash leaves the old file or the new one, never a truncated one. Both stores fail closed: a session that cannot read or bump them must not trade.