13#include "fastmm/core/account_pool.hpp"
14#include "fastmm/core/balance_book.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"
49 [[nodiscard]]
int line() const noexcept {
return line_; }
50 [[nodiscard]]
int col() const noexcept {
return col_; }
58 std::string
name =
"fastmm";
192 std::map<std::string, std::string>
extra;
265 std::map<std::string, std::string>
shared;
268 [[nodiscard]]
bool any() const noexcept {
275struct LoggingSection {
276 std::string
level =
"info";
286 std::map<std::string, std::string>
values;
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;
307 std::string_view source_name =
"<string>");
310 std::vector<VenueSection>
venues;
335 [[nodiscard]] TreasuryConfig
treasury_config(std::string_view primary) const;
345 return to_file ? 1 : 10;
347 [[nodiscard]] SpinMode
spin_mode()
const;
351 [[nodiscard]] std::string
redacted()
const;
359 [[nodiscard]]
static std::uint64_t
text_hash(std::string_view text)
noexcept;
372 const std::vector<std::string>* venue_names =
nullptr);
378 const std::vector<std::string>* venue_names =
nullptr);
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
Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue,...
Definition instrument.hpp:141
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
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