62[[nodiscard]] std::optional<std::int64_t>
parse_utc_time(std::string_view s);
76 std::span<const std::string> venue_names);
80 [[nodiscard]] std::size_t
arms() const noexcept {
return s_.
arms.size(); }
81 [[nodiscard]] std::size_t
instruments() const noexcept {
return slot_.size(); }
82 [[nodiscard]]
const std::string&
arm_name(
int arm)
const {
83 return s_.
arms.at(
static_cast<std::size_t
>(arm)).name;
86 [[nodiscard]]
const std::string&
instrument_name(std::size_t inst)
const {
87 return names_.at(inst);
89 [[nodiscard]] std::int64_t
start_ns() const noexcept {
return start_ns_; }
90 [[nodiscard]] std::int64_t
end_ns() const noexcept {
return end_ns_; }
91 [[nodiscard]] std::int64_t
block_ns() const noexcept {
return block_ns_; }
93 [[nodiscard]] std::int64_t
block_end(std::int64_t k)
const noexcept {
94 return (k + 1) * block_ns_ + offset_ns_;
97 [[nodiscard]]
bool in_test(std::size_t inst)
const noexcept {
98 return inst < slot_.size() && slot_[inst] != kOut;
101 void set_branch(
int arm)
noexcept { branch_ = arm; }
102 [[nodiscard]]
int branch() const noexcept {
return branch_; }
104 if (s_.
start.empty()) start_ns_ = ns;
108 [[nodiscard]]
int arm_at(std::size_t inst, std::int64_t t)
const noexcept;
110 [[nodiscard]] std::int64_t
next_change(std::int64_t t)
const noexcept;
112 [[nodiscard]] std::int64_t
block_of(std::int64_t t)
const noexcept;
115 [[nodiscard]] std::int64_t
round_of(std::int64_t t)
const noexcept;
117 [[nodiscard]] std::size_t
stratum(std::size_t inst)
const noexcept {
return stratum_[inst]; }
118 [[nodiscard]] std::size_t
slot(std::size_t inst)
const noexcept {
return slot_[inst]; }
123 [[nodiscard]] std::
size_t block_draw(std::int64_t block) const noexcept;
127 std::int64_t start_ns_;
128 std::int64_t end_ns_;
129 static constexpr std::uint8_t kOut = 0xFF;
130 std::int64_t block_ns_ = 0;
131 std::int64_t offset_ns_ = 0;
133 std::vector<std::uint8_t> slot_;
134 std::vector<std::
size_t> stratum_;
135 std::vector<std::
string> names_;
141 enum class State : std::uint8_t { Waiting, Running, Ended };
149 [[nodiscard]]
const AbPlan& plan() const noexcept {
return plan_; }
160 [[nodiscard]]
int promoted() const noexcept {
return promote_; }
162 [[nodiscard]]
int arm(std::string_view name)
const noexcept;
164 [[nodiscard]]
bool owns(std::string_view param)
const noexcept;
166 [[nodiscard]]
const std::vector<ParamValue>& values(
int arm)
const;
168 [[nodiscard]]
int current(std::size_t inst)
const noexcept {
return current_[inst]; }
171 [[nodiscard]] std::uint64_t refused() const noexcept {
return refused_; }
172 [[nodiscard]]
const std::string& last_error() const noexcept {
return last_error_; }
175 [[nodiscard]] std::string status(
Timestamp now)
const;
178 bool publish(
InstrumentId inst,
int values, std::uint8_t arm);
182 std::vector<ParamValue> base_;
183 std::vector<std::vector<ParamValue>> arm_values_;
184 std::vector<int> current_;
186 bool stopping_ =
false;
189 std::uint64_t refused_ = 0;
190 std::string last_error_;
Definition ab_test.hpp:140
ParamPublisher::ParamValue ParamValue
Definition ab_test.hpp:142
State
Definition ab_test.hpp:143
Definition ab_test.hpp:68
void set_default_start(std::int64_t ns) noexcept
Definition ab_test.hpp:105
const std::string & instrument_name(std::size_t inst) const
The instrument's name in the configuration's terms: "venue:symbol".
Definition ab_test.hpp:88
std::size_t slot(std::size_t inst) const noexcept
Definition ab_test.hpp:120
void set_branch(int arm) noexcept
branch: the arm of this run, and the start when [ab] start names none.
Definition ab_test.hpp:103
bool identical_arms() const noexcept
Every arm names the same parameters with the same values: an A/A test.
std::size_t stratum(std::size_t inst) const noexcept
The instrument's stratum (instrument, crossover; 0 with time) and its slot in it.
Definition ab_test.hpp:119
const std::string & arm_name(int arm) const
Definition ab_test.hpp:84
std::size_t instruments() const noexcept
Definition ab_test.hpp:83
bool in_test(std::size_t inst) const noexcept
The instrument is in the test: [ab.assign] names it, or there is none.
Definition ab_test.hpp:99
static constexpr int kNoArm
Definition ab_test.hpp:70
std::int64_t end_ns() const noexcept
INT64_MAX: none.
Definition ab_test.hpp:92
int branch() const noexcept
Definition ab_test.hpp:104
std::int64_t block_end(std::int64_t k) const noexcept
When block k ends (time, crossover).
Definition ab_test.hpp:95
std::size_t arms() const noexcept
Definition ab_test.hpp:82
int arm_at(std::size_t inst, std::int64_t t) const noexcept
The arm instrument inst is in at t (ns since the epoch): kNoArm before start and from end.
std::int64_t block_of(std::int64_t t) const noexcept
The block t falls in (time, crossover), 0 with instrument.
const AbSection & section() const noexcept
Definition ab_test.hpp:80
AbAssignment assignment() const noexcept
Definition ab_test.hpp:81
std::int64_t start_ns() const noexcept
INT64_MIN: none.
Definition ab_test.hpp:91
std::int64_t block_ns() const noexcept
0: no blocks
Definition ab_test.hpp:93
std::int64_t round_of(std::int64_t t) const noexcept
The run of arms() blocks t falls in, each arm once in it (time, crossover); 0 with instrument.
std::int64_t next_change(std::int64_t t) const noexcept
The first time after t at which arm_at() may change, INT64_MAX when it never does.
Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue,...
Definition instrument.hpp:147
Definition param_publisher.hpp:61
std::pair< std::string, std::string > ParamValue
name, value as ParamDesc::parse takes
Definition param_publisher.hpp:63
Typed configuration (8.7).
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Definition strategy.hpp:23
std::optional< std::int64_t > 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 al...
AbAssignment
Definition ab_test.hpp:47
constexpr std::size_t kMaxAbArms
Definition ab_test.hpp:45
std::string format_utc_time(std::int64_t ns)
"YYYY-MM-DD HH:MM:SS UTC".
constexpr std::string_view to_string(ParamType t) noexcept
Definition params.hpp:63
ParamPublisher: builds ParamUpdate messages for a running engine, off the engine thread (ADR-0013).
Definition config.hpp:329
std::string start
UTC; empty: from the start of the session.
Definition config.hpp:334
std::vector< AbArmSection > arms
Definition config.hpp:344
Definition instrument.hpp:29