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

A/B tests of strategy parameters ([ab], docs/how-to/strategies/ab-test.md). More...

#include "fastmm/config/config.hpp"
#include "fastmm/core/instrument.hpp"
#include "fastmm/core/time.hpp"
#include "fastmm/strategies/param_publisher.hpp"
#include <cstddef>
#include <cstdint>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

class  fastmm::AbPlan
 
class  fastmm::AbController
 

Namespaces

namespace  fastmm
 

Enumerations

enum class  fastmm::AbAssignment : std::uint8_t { fastmm::Instrument , fastmm::Time , fastmm::Crossover , fastmm::Branch }
 

Functions

constexpr std::string_view fastmm::to_string (AbAssignment a) noexcept
 
std::optional< std::int64_t > fastmm::parse_utc_time (std::string_view s)
 "YYYY-MM-DD", "YYYY-MM-DD HH:MM" or "YYYY-MM-DD HH:MM:SS", with a T for the space and a trailing Z allowed, UTC, as ns since the epoch.
 
std::string fastmm::format_utc_time (std::int64_t ns)
 "YYYY-MM-DD HH:MM:SS UTC".
 
constexpr std::string_view fastmm::to_string (AbController::State s) noexcept
 

Variables

constexpr std::size_t fastmm::kMaxAbArms = 16
 

Detailed Description

A/B tests of strategy parameters ([ab], docs/how-to/strategies/ab-test.md).

AbPlan says which arm each instrument is in at any time. It is a function of the [ab] table, the instrument table and the time only, so fastmm-live, a backtest and fastmm-data ab (which rebuilds it from a journal's configuration) agree on it.

instrument each instrument stays in one arm. The instruments, heaviest first, are cut into strata of as many instruments as there are arms, and each stratum gives every arm one instrument, in an order drawn from the seed; or [ab.assign] names each instrument's arm, and those it does not name stay out of the test. time every instrument is in the same arm. Time is cut into blocks of block_s from the Unix epoch (plus block_offset_s), and each run of as many blocks as there are arms gives every arm one block, in an order drawn from the seed. crossover both: an instrument's arm is its stratum slot plus the block's draw, modulo the number of arms, so each block splits the instruments and each run of blocks puts every instrument in every arm once. branch a backtest runs once per arm over the same data and seed, every instrument in that run's arm (set_branch) from the test's start, the start of trading when it names none (set_default_start); fastmm-live refuses it. The runs share the market and the draws until their order flows differ, so each instrument is paired with itself.

AbController keeps a session's instruments in the plan's arms. When an instrument's arm changes it publishes the arm's parameters (the configured values with the arm's on top) as one ParamUpdate, Origin::Experiment with the arm in ParamUpdateMsg::arm. The engine applies it like any update, the journal records it, and the orders sent after it carry the arm (Order::arm). Off the engine thread: it allocates.