FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
live_analysis.hpp
Go to the documentation of this file.
1#pragma once
2// What a live session's fills were worth, from its journal alone (fastmm-data analyze): per
3// instrument and overall, the fills, maker share and traded notional, the spread they captured
4// against the venue mid and their markouts and adverse selection at each horizon (markout.hpp),
5// next to the order traffic. The mid is the recorded BookTicker stream's (mid_series.hpp); a
6// session that recorded none has no markouts, only the counts.
8
9#include <cstdint>
10#include <span>
11#include <string>
12#include <vector>
13
14namespace fastmm::bt {
15
16struct LiveAnalysisInstrument {
17 std::string symbol;
18 std::uint64_t fills = 0;
19 std::uint64_t maker_fills = 0;
20 double bought = 0.0; // base units
21 double sold = 0.0; // base units
22 double notional = 0.0; // quote currency
23};
25struct LiveAnalysis {
26 std::string strategy;
27 std::int64_t first_ns = 0; // venue time of the first and last event
28 std::int64_t last_ns = 0;
29 std::uint64_t orders = 0; // new orders sent
30 std::uint64_t cancels = 0;
31 std::uint64_t replaces = 0;
32 std::uint64_t rejects = 0; // venue refusals
33 std::uint64_t fills = 0; // executions, each once
34 std::uint64_t maker_fills = 0;
35 std::uint64_t repeated_fills = 0; // the same execution reported again (a replay): counted once
36 bool mids = false; // the journal has a BookTicker stream to mark against
37 std::vector<LiveAnalysisInstrument> instruments; // by instrument id
38 std::vector<MarkoutHorizon> horizons;
39};
41// Throws std::runtime_error when the journal cannot be read.
42[[nodiscard]] LiveAnalysis analyze_live(const std::string& path,
43 std::span<const std::int64_t> horizons_ns);
44[[nodiscard]] std::string format_live_analysis(const LiveAnalysis& a);
45[[nodiscard]] std::string live_analysis_json(const LiveAnalysis& a);
47} // namespace fastmm::bt
Post-fill markouts: the metric that separates spread captured from adverse selection.
Definition backtest_config.hpp:39
std::string format_live_analysis(const LiveAnalysis &a)
std::string live_analysis_json(const LiveAnalysis &a)
LiveAnalysis analyze_live(const std::string &path, std::span< const std::int64_t > horizons_ns)
Throws std::runtime_error when the journal cannot be read.
double notional
quote currency
Definition live_analysis.hpp:24
std::uint64_t fills
Definition live_analysis.hpp:20
std::string symbol
Definition live_analysis.hpp:19
std::uint64_t maker_fills
Definition live_analysis.hpp:21
double bought
base units
Definition live_analysis.hpp:22
double sold
base units
Definition live_analysis.hpp:23
Definition live_analysis.hpp:27
std::uint64_t rejects
venue refusals
Definition live_analysis.hpp:34
std::uint64_t orders
new orders sent
Definition live_analysis.hpp:31
std::uint64_t repeated_fills
the same execution reported again (a replay): counted once
Definition live_analysis.hpp:37
std::uint64_t replaces
Definition live_analysis.hpp:33
std::uint64_t cancels
Definition live_analysis.hpp:32
bool mids
the journal has a BookTicker stream to mark against
Definition live_analysis.hpp:38
std::vector< LiveAnalysisInstrument > instruments
by instrument id
Definition live_analysis.hpp:39
std::int64_t first_ns
venue time of the first and last event
Definition live_analysis.hpp:29
std::uint64_t fills
executions, each once
Definition live_analysis.hpp:35
std::string strategy
Definition live_analysis.hpp:28
std::uint64_t maker_fills
Definition live_analysis.hpp:36
std::int64_t last_ns
Definition live_analysis.hpp:30
std::vector< MarkoutHorizon > horizons
Definition live_analysis.hpp:40