FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1#pragma once
2// Typed configuration (8.7). TOML parsing lives in src/core/config.cpp (toml++ is a
3// private dependency of fastmm_core); this header exposes only plain structs.
4//
5// Sections: [engine] [venues.<x>] [venues.<x>.fees] [[instruments]] [strategy]
6// [strategy.params] [risk] [gateway] [accounting] [accounting.fx] [logging] [sim]
7// [backtest] [storage]
8// A [venues.<x>] key the generic parser does not read is kept verbatim in VenueSection::extra:
9// the connector `kind` names owns it (include/fastmm/venues/registry.hpp).
10// Rules: ${VAR} is substituted only inside [venues.*] strings; a value that looks like an
11// inline secret (> 32 chars, no ${) is rejected unless allow_inline_secrets; redacted()
12// prints the config with secrets masked; validation errors carry line:col.
13#include "fastmm/core/account_pool.hpp"
14#include "fastmm/core/balance_book.hpp"
15#include "fastmm/core/enums.hpp"
16#include "fastmm/core/fees.hpp"
17#include "fastmm/core/fx.hpp"
19#include "fastmm/core/perp_book.hpp"
21#include "fastmm/core/risk.hpp"
22#include "fastmm/core/thread_utils.hpp"
23#include "fastmm/core/treasury.hpp"
24#include "fastmm/core/underlying.hpp"
26
27#include <cstdint>
28#include <map>
29#include <optional>
30#include <stdexcept>
31#include <string>
32#include <string_view>
33#include <vector>
34
35namespace fastmm {
36
37inline constexpr std::size_t kMaxVenuesConfig = 8; // == kMaxVenues (transport.hpp)
38// The shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol.
39inline constexpr int kMinFillAuditIntervalS = 10;
40
41class ConfigError : public std::runtime_error {
42 public:
43 ConfigError(const std::string& msg, int line = 0, int col = 0)
44 : std::runtime_error(line > 0 ? msg + " (line " + std::to_string(line) + ":" +
45 std::to_string(col) + ")"
46 : msg),
47 line_(line),
48 col_(col) {}
49 [[nodiscard]] int line() const noexcept { return line_; }
50 [[nodiscard]] int col() const noexcept { return col_; }
52 private:
53 int line_;
54 int col_;
55};
56
57struct EngineSection {
58 std::string name = "fastmm";
59 int cpu = -1;
60 std::vector<int> net_cpus;
61 std::string spin_mode = "adaptive";
62 // Carry the previous session's positions over from the store (venues that replay executions).
63 bool restore_position = true;
64 std::string net_backend = "epoll"; // net::Reactor backend: "epoll" | "io_uring"
65 // fastmm-live: "split" runs the engine and each venue's network loop on their own threads;
66 // "single" runs the one venue's network loop, the engine and order sending on the engine thread.
67 std::string threading = "split";
68 bool journal = true;
69 std::string journal_dir = "runs";
70 std::string journal_sync = "async"; // "async" | "fdatasync" (core/journal.hpp)
71 std::size_t journal_max_bytes = 0; // roll over to the next part at this size (0: never)
72 int journal_retention_days = 0; // delete .fmj files older than this at start (0: keep)
73 std::string epoch_file = "runs/session_epoch";
74 // Latched kill switch and cumulative PnL; empty = "<journal_dir>/<name>.kill".
75 std::string kill_file;
76 // fastmm-live: an exclusive flock(2) on lock_file (empty = "<journal_dir>/<name>.lock") taken
77 // before the session touches the account, so one process of this engine name trades at a time
78 // (live/instance_lock.hpp). --standby and --takeover take it whatever this says.
79 bool instance_lock = false;
80 std::string lock_file;
81 // --takeover: how long the new process waits for the running one to release the lock after it
82 // accepted `handoff`, ms.
83 int handoff_timeout_ms = 75'000;
84 std::uint64_t rng_seed = 1;
85 std::size_t md_ring_bytes = 4U << 20;
86 std::size_t order_ring_bytes = 1U << 20;
87 std::size_t journal_ring_bytes = 16U << 20;
88 std::uint32_t max_events_per_step = 64;
89 std::uint32_t feed_budget_per_ring = 64; // RingFeed: events per ring before the next one's turn
90 // Adaptive: a network thread alone on its pinned core never blocks (net_never_blocks).
91 bool net_spin_dedicated = false;
92 int crossed_grace_ms = 100;
93 int ack_timeout_ms = 0; // force-cancel an order without an ack after this long; 0 = off
94 // Operator flatten (fastmm-ctl flatten): the sweep period, how long the engine keeps working the
95 // position off (0 = until it is flat or an operator stops it) and the default slippage.
96 int flatten_interval_ms = 500;
97 int flatten_timeout_ms = 60000;
99 double queue_conservatism = 1.0; // queue position estimate (ctx.queue_ahead), 0..1
101 int tsc_recalibrate_s = 10; // fastmm-live: TSC recalibration period, 0 = never
102 std::int64_t timer_slack_ns = 0; // fastmm-live: PR_SET_TIMERSLACK of its threads, 0 = kernel's
103 bool lock_memory = false; // fastmm-live: mlockall(MCL_CURRENT | MCL_FUTURE)
104 // fastmm-live: PM QoS CPU latency request (/dev/cpu_dma_latency) held for the session, us;
105 // -1 = none.
106 int cpu_dma_latency_us = -1;
107 // fastmm-live: SCHED_FIFO priority of the engine thread and of the network threads, 0 = off.
108 int rt_priority = 0;
109 int net_rt_priority = 0;
110 // fastmm-live: log the NICs' interrupt CPUs against the pinned ones.
111 bool log_irq_affinity = false;
112 int min_requote_ticks = 1;
114 int min_qty_bps = 8000;
115 bool post_only = true;
116 bool supports_replace = true;
117 int reject_backoff_ms = 1000; // QuoteManager: pause a side after a venue reject (0 = off)
118 int reject_backoff_max_ms = 60000; // doubling cap
119 int quote_token_reserve = 0; // [risk] order tokens quotes that add risk leave to others
120 // fastmm-live after a kill switch it did not ask for (risk limit, internal failure, every venue
121 // killed): "exit" shuts down like SIGTERM and exits with code 6; "stay" keeps running with
122 // quoting off and logs an ERROR line every 10 s.
123 std::string on_kill = "exit";
124};
126struct FeesSection {
127 double maker_bps = 0.0;
128 double taker_bps = 0.0;
131// [venues.<primary>.treasury]: the pool treasury of an account pool's primary
132// (core/treasury.hpp). Decimals keep their text; Config::treasury_config() makes it typed.
133struct TreasurySection {
134 bool configured = false; // the table is present
135 bool enabled = false;
136 bool dry_run = false;
137 std::string asset;
138 std::map<std::string, double> weights; // pool account -> weight (absent: 1)
139 std::map<std::string, std::string> min_free; // pool account -> decimal (absent: 0)
140 double threshold = 0.2;
141 std::string min_amount = "0";
142 std::string max_amount = "0";
143 std::string step = "0.01";
144 std::int64_t interval_s = 10;
145 std::int64_t min_interval_s = 60;
146 std::int64_t max_per_hour = 12;
147 std::int64_t cooldown_s = 300;
148 std::int64_t timeout_s = 60;
149 std::int64_t settle_s = 30;
150 std::string state_file; // empty: <journal_dir>/<engine name>.<primary>.treasury
153struct VenueSection {
154 std::string name;
155 std::string kind;
156 std::string ws_url;
157 std::string ws_api_url;
158 std::string rest_url;
159 std::string api_key;
160 std::string api_secret;
161 std::string api_passphrase; // OKX: the passphrase chosen with the API key
162 bool testnet = true;
163 bool supports_replace = false;
164 // Market data only: no keys needed, no private sessions, no orders, not awaited at start, not
165 // cancelled at stop. For a venue that is only a price leader for a strategy on another venue.
166 bool public_only = false;
167 // Another account of the venue named: this one takes orders for that venue's instruments with
168 // its own keys, balances and order-count windows, and has no instruments or market data of its
169 // own (core/account_pool.hpp). Empty: a venue of its own.
170 std::string pool_of;
171 bool insecure_tls = false;
172 std::string ca_file;
173 int recv_window_ms = 3000;
174 // Where this venue's connections leave the host from: one of its addresses, or the address of a
175 // network interface (net/source_address.hpp). Empty: the kernel chooses.
176 std::string source_ip;
177 std::string source_interface;
178 // Fill audit (live/fill_auditor.hpp): every fill_audit_interval_s seconds fastmm-live compares
179 // the venue's trade history with the fills the store holds for this venue, up to
180 // fill_audit_lag_s ago. 0: off. "report" only reports a difference; "book" also books the
181 // executions the engine missed, through the execution replay.
182 int fill_audit_interval_s = 0;
183 int fill_audit_lag_s = 180;
184 std::string fill_audit_mode = "report";
187 // Every key the generic parser does not interpret, stringified. The venue `kind` names owns
188 // them: it declares them, validates them and reports an unknown one
189 // (fastmm::venues::validate_venues, include/fastmm/venues/registry.hpp), which is why the
190 // central schema knows none of them. `extra_lines` is the line each key came from, absent for a
191 // key set in code, so the owner can report with a position the way the schema does.
192 std::map<std::string, std::string> extra;
193 std::map<std::string, int> extra_lines;
196struct InstrumentSection {
197 std::string venue;
198 std::string symbol;
199 std::string base;
200 std::string quote;
201 std::string asset_class = "spot";
202 std::string tick;
203 std::string lot;
204 std::string min_qty;
205 std::string max_qty;
206 std::string min_notional;
207 std::string contract_multiplier = "1";
208 bool enabled = true;
210 std::string expiry;
211 std::string strike;
212 std::string option_type;
213 // Per-instrument fee schedule; unset means the instrument pays its venue's [venues.<x>.fees].
214 // Positive == a fee, negative == a rebate.
215 std::optional<double> maker_bps;
216 std::optional<double> taker_bps;
217 // A derivative's initial margin, fraction of the notional, decimal; empty: none configured.
218 std::string initial_margin;
219};
221struct StrategySection {
222 std::string name;
224 std::int64_t max_param_age_ms = 0; // 0 = off
225 std::string state_file; // the strategy's state across sessions; empty: none
226 std::int64_t state_interval_s = 300;
227 std::int64_t state_snapshot_interval_s = 0; // journal snapshots of state(); 0: none
230struct RiskSection {
231 std::string max_order_qty;
233 std::string max_position;
237 int stale_md_ms = 0;
238 std::string max_loss;
240 std::string max_net_notional;
242 int burst = 0;
243 bool stp = true;
244 int max_feed_lag_ms = 0; // 0 = off
245 bool check_balance = true; // refuse what the venue's balance cannot cover
246 // [risk.underlying.<BASE>] max_net: net position per base asset over every instrument, base
247 // units.
248 UnderlyingSpec underlying;
249};
251// fastmm-gateway's account guards: one venue's account, shared by every attached strategy.
252struct GatewaySection {
253 int orders_per_sec = 0; // new orders and replaces per venue, 0 = off
254 int burst = 0; // token-bucket capacity, 0 = orders_per_sec
255 std::string max_open_notional; // notional working at a venue, decimal; empty = off
256 // The account over every attached strategy, decimals in the settlement currency; empty = off.
257 std::string max_loss; // net PnL, carried in <journal_dir>/<name>.kill
258 std::string max_gross_notional; // sum of |position| at the marks
259 std::string max_net_notional; // |signed sum| of the positions at the marks
260 // [gateway.underlying.<BASE>] max_net: the account's net position per base asset, base units.
261 UnderlyingSpec underlying;
262 // [gateway.shared."<venue>:<symbol>"]: an instrument several strategies may trade at once, and
263 // the [engine] name of its primary strategy (empty: none), which books the events naming no
264 // order.
265 std::map<std::string, std::string> shared;
266 bool check_balance = true; // the account's balance covers every strategy's orders
268 [[nodiscard]] bool any() const noexcept {
269 return orders_per_sec != 0 || burst != 0 || !max_open_notional.empty() || !max_loss.empty() ||
270 !max_gross_notional.empty() || !max_net_notional.empty() || underlying.configured() ||
271 !shared.empty() || !check_balance;
272 }
273};
274
275struct LoggingSection {
276 std::string level = "info";
277 std::string file;
278 std::string mirror_level = "warn";
279 // Seconds between the per-venue status lines; 0: none. Unset (-1): every second into a log file,
280 // every 10 s when the log is stderr.
281 std::int64_t status_interval_s = -1;
282};
284// Free-form section used by the sim / backtest libraries: dotted keys -> stringified value.
285struct GenericSection {
286 std::map<std::string, std::string> values;
287 std::map<std::string, int> lines; // key -> line in the file; absent for keys set in code
288 [[nodiscard]] bool has(std::string_view key) const { return values.contains(std::string(key)); }
289 [[nodiscard]] std::string get_string(std::string_view key, std::string_view def = "") const;
290 [[nodiscard]] std::int64_t get_int(std::string_view key, std::int64_t def = 0) const;
291 [[nodiscard]] double get_double(std::string_view key, double def = 0.0) const;
292 [[nodiscard]] bool get_bool(std::string_view key, bool def = false) const;
295struct ConfigLoadOptions {
296 bool allow_inline_secrets = false;
297 bool substitute_env = true;
300class Config {
301 public:
303
304 static Config load(const std::string& path, const LoadOptions& opts = LoadOptions{});
305 static Config parse(std::string_view toml,
306 const LoadOptions& opts = LoadOptions{},
307 std::string_view source_name = "<string>");
308
310 std::vector<VenueSection> venues; // VenueId == index
311 std::vector<InstrumentSection> instruments;
315 // [accounting]: the reporting currency and the FX source of each other settlement currency,
316 // read by fastmm-live, fastmm-gateway, the backtester and replay (build_fx_plan, core/fx.hpp).
317 AccountingSpec accounting;
321 // [storage]: the backend name and whatever keys that backend reads. Free-form, like [sim] and
322 // [backtest]: a storage backend parses its own keys and the central schema knows none of them
323 // (docs/reference/storage.md).
325 std::vector<std::string> warnings;
326 std::string source; // path or "<string>"
327 std::uint64_t hash = 0; // FNV-1a of the raw text
329 [[nodiscard]] const VenueSection* venue(std::string_view name) const noexcept;
330 [[nodiscard]] VenueId venue_id(std::string_view name) const noexcept; // invalid if unknown
331 // The account pools ([venues.<x>] pool_of), by venue id; inactive without any.
332 [[nodiscard]] PoolPlan pool_plan() const noexcept;
333 // The treasury of the pool whose primary is `primary` ([venues.<primary>.treasury]), typed; a
334 // disabled one when the venue has none.
335 [[nodiscard]] TreasuryConfig treasury_config(std::string_view primary) const;
336
337 // Typed views used to wire the engine.
338 [[nodiscard]] RiskLimits risk_limits() const;
339 [[nodiscard]] QuoteParams quote_params() const;
340 [[nodiscard]] LogLevel log_level() const;
341 [[nodiscard]] LogLevel mirror_level() const;
342 // `to_file`: the log goes to a file (--log or [logging] file), where the default is 1 s.
343 [[nodiscard]] std::int64_t status_interval_s(bool to_file) const noexcept {
345 return to_file ? 1 : 10;
346 }
347 [[nodiscard]] SpinMode spin_mode() const;
348 [[nodiscard]] bool single_threaded() const noexcept { return engine.threading == "single"; }
350 // Dump with api_key/api_secret/api_passphrase masked; safe to log.
351 [[nodiscard]] std::string redacted() const;
352
353 // The configuration as parsed (after any changes made to this object, e.g. command-line
354 // overrides) as complete TOML without api_key / api_secret / api_passphrase. Deterministic:
355 // equal configurations give equal text, and parsing the text gives an equal configuration.
356 // Journals embed it, and its hash is the journal header's config_hash.
357 [[nodiscard]] std::string effective_toml() const;
358 [[nodiscard]] std::uint64_t effective_hash() const { return text_hash(effective_toml()); }
359 [[nodiscard]] static std::uint64_t text_hash(std::string_view text) noexcept; // FNV-1a
362// Builds the dense instrument table (src/core/instrument_loader.cpp). Throws ConfigError.
364
365// The fee rates of each instrument: its [[instruments]] maker_bps / taker_bps, else its venue's
366// [venues.<x>.fees]; the first venue's are the default for ids outside the configuration. Without
367// `table`, instrument k of the configuration is InstrumentId k (load_instruments); with it, each
368// instrument of `table` takes the entry with its venue and symbol, `venue_names` naming its venue
369// ids (a table from fastmm-gateway, whose order is not the configuration's).
370FeeTable fee_table(const Config& cfg,
371 const InstrumentTable* table = nullptr,
372 const std::vector<std::string>* venue_names = nullptr);
373
374// [risk] check_balance and each instrument's [[instruments]] initial_margin, the instruments mapped
375// as fee_table() maps them.
376BalanceConfig balance_config(const Config& cfg,
377 const InstrumentTable* table = nullptr,
378 const std::vector<std::string>* venue_names = nullptr);
379
380// [accounting] mark, stale_mark_ms and stale_funding_ms.
381PerpConfig perp_config(const Config& cfg);
382
383} // namespace fastmm
Definition config.hpp:43
int col() const noexcept
Definition config.hpp:52
int line() const noexcept
Definition config.hpp:51
Definition config.hpp:302
static Config parse(std::string_view toml, const LoadOptions &opts=LoadOptions{}, std::string_view source_name="<string>")
SpinMode spin_mode() const
StrategySection strategy
Definition config.hpp:314
LogLevel mirror_level() const
RiskLimits risk_limits() const
Typed views used to wire the engine.
bool single_threaded() const noexcept
Definition config.hpp:350
std::string redacted() const
Dump with api_key/api_secret/api_passphrase masked; safe to log.
GenericSection backtest
Definition config.hpp:322
GenericSection storage
[storage]: the backend name and whatever keys that backend reads.
Definition config.hpp:326
LoggingSection logging
Definition config.hpp:320
const VenueSection * venue(std::string_view name) const noexcept
GatewaySection gateway
Definition config.hpp:316
PoolPlan pool_plan() const noexcept
The account pools ([venues.<x>] pool_of), by venue id; inactive without any.
std::vector< std::string > warnings
Definition config.hpp:327
QuoteParams quote_params() const
EngineSection engine
Definition config.hpp:311
std::string source
path or "<string>"
Definition config.hpp:328
std::uint64_t hash
FNV-1a of the raw text.
Definition config.hpp:329
TreasuryConfig treasury_config(std::string_view primary) const
The treasury of the pool whose primary is primary ([venues.
RiskSection risk
Definition config.hpp:315
std::uint64_t effective_hash() const
Definition config.hpp:360
AccountingSpec accounting
[accounting]: the reporting currency and the FX source of each other settlement currency,...
Definition config.hpp:319
GenericSection sim
Definition config.hpp:321
std::vector< VenueSection > venues
VenueId == index.
Definition config.hpp:312
static Config load(const std::string &path, const LoadOptions &opts=LoadOptions{})
LogLevel log_level() const
static std::uint64_t text_hash(std::string_view text) noexcept
FNV-1a.
std::int64_t status_interval_s(bool to_file) const noexcept
to_file: the log goes to a file (--log or [logging] file), where the default is 1 s.
Definition config.hpp:345
std::string effective_toml() const
The configuration as parsed (after any changes made to this object, e.g.
VenueId venue_id(std::string_view name) const noexcept
invalid if unknown
std::vector< InstrumentSection > instruments
Definition config.hpp:313
Definition fees.hpp:54
Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue,...
Definition instrument.hpp:141
All engine enumerations.
Fee rates per instrument, in centi-basis-points (integer) of the fill notional.
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Definition strategy.hpp:16
constexpr int kMinFillAuditIntervalS
The shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol.
Definition config.hpp:41
LogLevel
Definition enums.hpp:604
FeeTable fee_table(const Config &cfg, const InstrumentTable *table=nullptr, const std::vector< std::string > *venue_names=nullptr)
The fee rates of each instrument: its [[instruments]] maker_bps / taker_bps, else its venue's [venues...
PerpConfig perp_config(const Config &cfg)
[accounting] mark, stale_mark_ms and stale_funding_ms.
constexpr std::size_t kMaxVenuesConfig
== kMaxVenues (transport.hpp)
Definition config.hpp:39
InstrumentTable load_instruments(const Config &cfg)
Builds the dense instrument table (src/core/instrument_loader.cpp). Throws ConfigError.
constexpr std::string_view to_string(ParamType t) noexcept
Definition params.hpp:63
BalanceConfig balance_config(const Config &cfg, const InstrumentTable *table=nullptr, const std::vector< std::string > *venue_names=nullptr)
[risk] check_balance and each instrument's [[instruments]] initial_margin, the instruments mapped as ...
std::map< std::string, std::string > ParamMap
Definition params.hpp:119
Strategy parameter schema (8.6, ADR-0012).
QuoteManager (5.6): diffs the strategy's DesiredQuotes against the orders resting at the venue and em...
Definition config.hpp:297
bool substitute_env
Definition config.hpp:299
bool allow_inline_secrets
Definition config.hpp:298
Definition config.hpp:59
std::size_t order_ring_bytes
Definition config.hpp:88
std::string epoch_file
Definition config.hpp:75
int reject_backoff_max_ms
doubling cap
Definition config.hpp:120
std::string kill_file
Latched kill switch and cumulative PnL; empty = "<journal_dir>/<name>.kill".
Definition config.hpp:77
std::uint32_t feed_budget_per_ring
RingFeed: events per ring before the next one's turn.
Definition config.hpp:91
bool instance_lock
fastmm-live: an exclusive flock(2) on lock_file (empty = "<journal_dir>/<name>....
Definition config.hpp:81
int crossed_grace_ms
Definition config.hpp:94
int tsc_recalibrate_s
fastmm-live: TSC recalibration period, 0 = never
Definition config.hpp:103
std::string journal_sync
"async" | "fdatasync" (core/journal.hpp)
Definition config.hpp:72
int flatten_timeout_ms
Definition config.hpp:99
std::size_t journal_max_bytes
roll over to the next part at this size (0: never)
Definition config.hpp:73
std::string lock_file
Definition config.hpp:82
bool log_irq_affinity
fastmm-live: log the NICs' interrupt CPUs against the pinned ones.
Definition config.hpp:113
std::vector< int > net_cpus
Definition config.hpp:62
double queue_conservatism
queue position estimate (ctx.queue_ahead), 0..1
Definition config.hpp:101
int latency_publish_ms
Definition config.hpp:102
int min_requote_ticks
Definition config.hpp:114
int quote_token_reserve
[risk] order tokens quotes that add risk leave to others
Definition config.hpp:121
bool post_only
Definition config.hpp:117
std::string threading
fastmm-live: "split" runs the engine and each venue's network loop on their own threads; "single" run...
Definition config.hpp:69
std::string on_kill
fastmm-live after a kill switch it did not ask for (risk limit, internal failure, every venue killed)...
Definition config.hpp:125
bool supports_replace
Definition config.hpp:118
int rt_priority
fastmm-live: SCHED_FIFO priority of the engine thread and of the network threads, 0 = off.
Definition config.hpp:110
int handoff_timeout_ms
--takeover: how long the new process waits for the running one to release the lock after it accepted ...
Definition config.hpp:85
int cpu_dma_latency_us
fastmm-live: PM QoS CPU latency request (/dev/cpu_dma_latency) held for the session,...
Definition config.hpp:108
int min_qty_bps
Definition config.hpp:116
bool journal
Definition config.hpp:70
std::string net_backend
net::Reactor backend: "epoll" | "io_uring"
Definition config.hpp:66
std::string spin_mode
Definition config.hpp:63
int ack_timeout_ms
force-cancel an order without an ack after this long; 0 = off
Definition config.hpp:95
std::uint32_t max_events_per_step
Definition config.hpp:90
std::string name
Definition config.hpp:60
int flatten_interval_ms
Operator flatten (fastmm-ctl flatten): the sweep period, how long the engine keeps working the positi...
Definition config.hpp:98
int reject_backoff_ms
QuoteManager: pause a side after a venue reject (0 = off)
Definition config.hpp:119
int cpu
Definition config.hpp:61
bool net_spin_dedicated
Adaptive: a network thread alone on its pinned core never blocks (net_never_blocks).
Definition config.hpp:93
std::size_t journal_ring_bytes
Definition config.hpp:89
std::uint64_t rng_seed
Definition config.hpp:86
int journal_retention_days
delete .fmj files older than this at start (0: keep)
Definition config.hpp:74
int flatten_slippage_bps
Definition config.hpp:100
std::int64_t timer_slack_ns
fastmm-live: PR_SET_TIMERSLACK of its threads, 0 = kernel's
Definition config.hpp:104
int net_rt_priority
Definition config.hpp:111
std::string journal_dir
Definition config.hpp:71
bool lock_memory
fastmm-live: mlockall(MCL_CURRENT | MCL_FUTURE)
Definition config.hpp:105
bool restore_position
Carry the previous session's positions over from the store (venues that replay executions).
Definition config.hpp:65
int min_requote_interval_ms
Definition config.hpp:115
std::size_t md_ring_bytes
Definition config.hpp:87
Definition config.hpp:128
double maker_bps
Definition config.hpp:129
double taker_bps
Definition config.hpp:130
fastmm-gateway's account guards: one venue's account, shared by every attached strategy.
Definition config.hpp:254
std::string max_loss
The account over every attached strategy, decimals in the settlement currency; empty = off.
Definition config.hpp:259
int orders_per_sec
new orders and replaces per venue, 0 = off
Definition config.hpp:255
UnderlyingSpec underlying
[gateway.underlying.<BASE>] max_net: the account's net position per base asset, base units.
Definition config.hpp:263
int burst
token-bucket capacity, 0 = orders_per_sec
Definition config.hpp:256
std::string max_gross_notional
sum of |position| at the marks
Definition config.hpp:260
std::string max_open_notional
notional working at a venue, decimal; empty = off
Definition config.hpp:257
std::map< std::string, std::string > shared
[gateway.shared.
Definition config.hpp:267
bool any() const noexcept
Definition config.hpp:270
bool check_balance
the account's balance covers every strategy's orders
Definition config.hpp:268
std::string max_net_notional
|signed sum| of the positions at the marks
Definition config.hpp:261
Free-form section used by the sim / backtest libraries: dotted keys -> stringified value.
Definition config.hpp:287
std::map< std::string, std::string > values
Definition config.hpp:288
double get_double(std::string_view key, double def=0.0) const
std::map< std::string, int > lines
key -> line in the file; absent for keys set in code
Definition config.hpp:289
std::int64_t get_int(std::string_view key, std::int64_t def=0) const
bool has(std::string_view key) const
Definition config.hpp:290
std::string get_string(std::string_view key, std::string_view def="") const
bool get_bool(std::string_view key, bool def=false) const
Definition config.hpp:198
std::optional< double > taker_bps
Definition config.hpp:218
std::string strike
Definition config.hpp:213
std::string lot
Definition config.hpp:205
std::string contract_multiplier
Definition config.hpp:209
std::optional< double > maker_bps
Per-instrument fee schedule; unset means the instrument pays its venue's [venues.
Definition config.hpp:217
std::string asset_class
Definition config.hpp:203
std::string expiry
Definition config.hpp:212
std::string max_qty
Definition config.hpp:207
std::string venue
Definition config.hpp:199
std::string base
Definition config.hpp:201
std::string min_qty
Definition config.hpp:206
std::string tick
Definition config.hpp:204
std::string option_type
Definition config.hpp:214
int price_decimals
Definition config.hpp:211
std::string min_notional
Definition config.hpp:208
std::string quote
Definition config.hpp:202
std::string initial_margin
A derivative's initial margin, fraction of the notional, decimal; empty: none configured.
Definition config.hpp:220
bool enabled
Definition config.hpp:210
std::string symbol
Definition config.hpp:200
Definition config.hpp:277
std::string file
Definition config.hpp:279
std::string mirror_level
Definition config.hpp:280
std::string level
Definition config.hpp:278
std::int64_t status_interval_s
Seconds between the per-venue status lines; 0: none.
Definition config.hpp:283
Definition quote_manager.hpp:91
Definition risk_limits.hpp:17
Definition config.hpp:232
std::string max_gross_notional
Definition config.hpp:241
int max_feed_lag_ms
0 = off
Definition config.hpp:246
int fat_finger_bps
Definition config.hpp:238
int max_open_orders
Definition config.hpp:236
std::string max_position
Definition config.hpp:235
UnderlyingSpec underlying
[risk.underlying.
Definition config.hpp:250
std::string max_order_qty
Definition config.hpp:233
std::string max_order_notional
Definition config.hpp:234
int price_collar_bps
Definition config.hpp:237
std::string max_net_notional
Definition config.hpp:242
std::string max_loss
Definition config.hpp:240
int orders_per_sec
Definition config.hpp:243
int stale_md_ms
Definition config.hpp:239
int burst
Definition config.hpp:244
bool check_balance
refuse what the venue's balance cannot cover
Definition config.hpp:247
bool stp
Definition config.hpp:245
Definition config.hpp:223
ParamMap params
Definition config.hpp:225
std::int64_t max_param_age_ms
0 = off
Definition config.hpp:226
std::int64_t state_snapshot_interval_s
journal snapshots of state(); 0: none
Definition config.hpp:229
std::int64_t state_interval_s
Definition config.hpp:228
std::string name
Definition config.hpp:224
std::string state_file
the strategy's state across sessions; empty: none
Definition config.hpp:227
[venues.
Definition config.hpp:135
std::string min_amount
Definition config.hpp:143
std::string step
Definition config.hpp:145
std::int64_t max_per_hour
Definition config.hpp:148
double threshold
Definition config.hpp:142
std::int64_t interval_s
Definition config.hpp:146
std::int64_t min_interval_s
Definition config.hpp:147
std::int64_t settle_s
Definition config.hpp:151
std::string asset
Definition config.hpp:139
std::int64_t cooldown_s
Definition config.hpp:149
bool dry_run
Definition config.hpp:138
bool enabled
Definition config.hpp:137
std::map< std::string, double > weights
pool account -> weight (absent: 1)
Definition config.hpp:140
bool configured
the table is present
Definition config.hpp:136
std::string max_amount
Definition config.hpp:144
std::string state_file
empty: <journal_dir>/<engine name>.<primary>.treasury
Definition config.hpp:152
std::int64_t timeout_s
Definition config.hpp:150
std::map< std::string, std::string > min_free
pool account -> decimal (absent: 0)
Definition config.hpp:141
Definition config.hpp:155
bool supports_replace
Definition config.hpp:165
bool testnet
Definition config.hpp:164
bool insecure_tls
Definition config.hpp:173
std::string fill_audit_mode
Definition config.hpp:186
bool public_only
Market data only: no keys needed, no private sessions, no orders, not awaited at start,...
Definition config.hpp:168
std::string api_key
Definition config.hpp:161
std::string ca_file
Definition config.hpp:174
std::string ws_api_url
Definition config.hpp:159
int recv_window_ms
Definition config.hpp:175
std::map< std::string, int > extra_lines
Definition config.hpp:195
std::string name
Definition config.hpp:156
std::string api_passphrase
OKX: the passphrase chosen with the API key.
Definition config.hpp:163
std::map< std::string, std::string > extra
Every key the generic parser does not interpret, stringified.
Definition config.hpp:194
FeesSection fees
Definition config.hpp:187
TreasurySection treasury
Definition config.hpp:188
std::string source_ip
Where this venue's connections leave the host from: one of its addresses, or the address of a network...
Definition config.hpp:178
std::string api_secret
Definition config.hpp:162
std::string pool_of
Another account of the venue named: this one takes orders for that venue's instruments with its own k...
Definition config.hpp:172
std::string kind
Definition config.hpp:157
std::string source_interface
Definition config.hpp:179
int fill_audit_interval_s
Fill audit (live/fill_auditor.hpp): every fill_audit_interval_s seconds fastmm-live compares the venu...
Definition config.hpp:184
std::string rest_url
Definition config.hpp:160
int fill_audit_lag_s
Definition config.hpp:185
std::string ws_url
Definition config.hpp:158