|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
run_live(): wires venues, rings, the engine and the journal into the plan 5.1 thread model and runs a session (fastmm::live, src/live/session.cpp). More...
#include "fastmm/config/config.hpp"#include "fastmm/core/strong_id.hpp"#include <cstdint>#include <functional>#include <memory>#include <string>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| struct | fastmm::live::LiveStrategy |
| A strategy the caller builds instead of the registry's [strategy] name. More... | |
| struct | fastmm::live::LiveOptions |
Namespaces | |
| namespace | fastmm |
| namespace | fastmm::live |
Functions | |
| int | fastmm::live::run_live (const Config &cfg, const LiveOptions &opts) |
| Runs one session; returns the process exit code. | |
| bool | fastmm::live::resolve_venue_env (Config &cfg, bool dry_run, const char *prog) |
| Resolves ${VAR} in every venue string. | |
| void | fastmm::live::restore_signal_handlers () noexcept |
| Restores the SIGINT/SIGTERM handlers run_live replaced; a no-op when none are replaced. | |
Variables | |
| constexpr int | fastmm::live::kExitOk = 0 |
| Process exit codes (listed in fastmm-live --help and docs/how-to/operations/). | |
| constexpr int | fastmm::live::kExitUsage = 2 |
| bad command line, missing API keys | |
| constexpr int | fastmm::live::kExitConfig = 3 |
| bad config, strategy or parameters | |
| constexpr int | fastmm::live::kExitVenue = 4 |
| venue reference data failed | |
| constexpr int | fastmm::live::kExitRuntime = 5 |
| cancel_all failed, journal, ring overflow, uncaught error | |
| constexpr int | fastmm::live::kExitKilled = 6 |
| engine-tripped kill switch with [engine] on_kill = "exit" | |
| constexpr int | fastmm::live::kExitSlowTier = 7 |
| LiveOptions::watchdog (a Python slow tier failed) | |
| constexpr int | fastmm::live::kExitLocked = 8 |
| Another process holds the instance lock, or a takeover failed; nothing was traded. | |
| constexpr std::int64_t | fastmm::live::kKilledReminderNs = 10'000'000'000 |
| How often a session that stays up after a kill ([engine] on_kill = "stay") repeats its ERROR. | |
run_live(): wires venues, rings, the engine and the journal into the plan 5.1 thread model and runs a session (fastmm::live, src/live/session.cpp).
fastmm::cli::live (cli/live.hpp) is the command line around it.
fm-net-<i> one per venue: net::Reactor loop (connections, parsing into the venue's md and order rings, draining the venue's outbound ring when the engine wakes it) fm-engine Engine<S, TscClock, LiveTransport, RingFeed>::run() (pinned / spin mode from [engine] cpu / spin_mode) fm-journal JournalFileWriter drain thread (when journaling) log sink Logger::start(): formats and writes log records from every thread's ring main thread control: posts Venue::on_timer every second, prints stats, recalibrates the TSC every [engine] tsc_recalibrate_s and publishes it (the engine and the venues pick it up), handles SIGINT/SIGTERM and --duration: kill switch -> cancel_all on every venue over an independent REST connection -> stop, all within ~5 s. It also watches the engine's kill switch: a kill the engine trips itself (risk limit, full ring, every venue killed) runs the same shutdown and exits with kExitKilled when [engine] on_kill = "exit" (the default); with "stay" the session keeps running and logs an ERROR line every 10 s. Venue kills are logged once per venue.
[engine] threading = "single" (one venue): no fm-net-0; fm-engine runs the venue's reactor iteration between engine steps (Engine::run_inline), takes each market-data event as the venue commits it (EventSink drain hook -> Engine::drain) and hands its orders to Venue::send_now.
The thread set is fixed for the whole session (the logger keeps a ring per thread). The strategy is built by the StrategyRegistry's TransportKind::Live factory for [strategy] name; register it (register_builtin_strategies, a strategy module) before calling run_live, or pass a LiveStrategy (fastmm_live._live runs Python hot strategies that way). run_live installs process-wide SIGINT/SIGTERM handlers and restores the previous ones when it returns.