89 std::string_view
name =
"hedge";
90 std::uint32_t
tag = 0;
117 enum class State : std::uint8_t {
146 void reset() noexcept {
155 sources_[n_sources_++] = Leg{id,
Ratio{}, 0};
160 hedges_[n_hedges_++] = Leg{id, tolerance, 0};
166 bool start(Ctx& ctx,
const Config& cfg)
noexcept {
170 if (n_sources_ == 0 || n_hedges_ == 0) {
174 const auto n = ctx.instruments().size();
175 for (std::size_t i = 0; i < n_sources_ + n_hedges_; ++i) {
178 FASTMM_LOG_ERROR(
"{}: instrument {} is not among the {} configured; not hedging",
184 const Instrument& inst = ctx.instrument(
id);
185 if (inst.inverse() || !inst.contract_multiplier.is_positive()) {
187 "{}: {} is not a linear contract; not hedging", cfg_.
name, inst.symbol.view());
190 for (std::size_t j = 0; j < i; ++j) {
191 if (leg(j).
id ==
id) {
197 for (std::size_t i = 0; i < n_sources_ + n_hedges_; ++i)
198 venue_of_[i] = ctx.instrument(leg(i).
id).venue;
203 void set_config(
const Config& cfg)
noexcept { cfg_ = cfg; }
205 if (hedge < n_hedges_) hedges_[hedge].tolerance = tolerance;
213 for (std::size_t i = 0; i <
kMaxHedges; ++i) {
224 if (!ready_ || !
is_leg(fill.instrument))
return false;
233 if (!ready_ || !u.terminal)
return false;
234 const Order& o = u.order;
235 const std::int64_t now = ctx.now().ns;
236 if (derisk_open_ && o.
cl_ord_id == derisk_id_) {
237 derisk_open_ =
false;
238 if (
uncertain(u)) hold_uncertain(o, now);
243 if (k < 0)
return false;
244 if (o.
cum_qty.
is_zero()) failed(ctx,
static_cast<std::size_t
>(k), now);
245 if (
uncertain(u)) hold_uncertain(o, now);
253 if (ready_ && hedge_index(
id) >= 0)
update(ctx);
266 if (!ready_ || m.channel == 0)
return;
267 const std::uint32_t bit = 1U << (m.channel & 31U);
268 for (std::size_t i = 0; i < n_sources_ + n_hedges_; ++i) {
270 if (venue_of_[i] != m.hdr.venue)
continue;
282 if (!ready_ || !
involves(m.hdr.venue))
return false;
291 const std::int64_t now = ctx.now().ns;
292 if (in_flight(ctx)) {
296 if (ctx.reconciling()) {
300 if (now < next_ns_) {
316 std::size_t first = n_hedges_;
317 for (std::size_t i = 0; i < n_hedges_; ++i) {
323 if (first == n_hedges_) {
329 ctx.instrument(hedges_[0].id).symbol.view(),
339 const std::optional<NewOrderRequest> sized = order_on(ctx, first,
residual, &cut);
342 unblock(
"the residual is under the hedge minimum");
346 std::size_t k = first;
347 if (!covered(ctx, req)) {
349 for (std::size_t j = first + 1; j < n_hedges_; ++j) {
352 const std::optional<NewOrderRequest> r = order_on(ctx, j,
residual, &cut_j);
353 if (r && covered(ctx, *r)) {
361 if (k == n_hedges_) {
366 "{}: hedge {} {} @ {} held: no usable hedge venue's balance covers it ({} on {}); {} "
367 "unhedged until a balance report or a fill changes that",
384 if (k != active_) switch_to(ctx, k, now);
385 unblock(
"a hedge instrument takes the residual again");
386 const auto sent = ctx.send(req);
399 if (cut && !split_) {
402 "{}: [risk] admits {} {} @ {} of the {} to hedge on {}: it goes out in pieces",
408 ctx.instrument(req.
instrument).symbol.view());
414 [[nodiscard]]
bool ready() const noexcept {
return ready_; }
415 [[nodiscard]]
bool halted() const noexcept {
return halted_; }
417 [[nodiscard]]
bool held() const noexcept {
return held_; }
418 [[nodiscard]]
bool derisking() const noexcept {
return derisking_; }
419 [[nodiscard]]
State state() const noexcept {
return state_; }
420 [[nodiscard]]
const Stats&
stats() const noexcept {
return stats_; }
421 [[nodiscard]] std::size_t
hedge_count() const noexcept {
return n_hedges_; }
423 [[nodiscard]] std::size_t
active() const noexcept {
return active_; }
424 [[nodiscard]]
Qty target() const noexcept {
return target_; }
427 for (std::size_t i = 0; i < n_sources_; ++i) {
428 if (sources_[i].
id ==
id)
return true;
437 for (std::size_t i = 0; i < n_sources_ + n_hedges_; ++i) {
438 if (venue_of_[i] == v)
return true;
445 [[nodiscard]]
Qty residual(
const Ctx& ctx)
const noexcept {
447 for (std::size_t i = 0; i < n_sources_ + n_hedges_; ++i) {
449 r +=
to_base(ctx.instrument(
id), ctx.position(
id).qty);
456 [[nodiscard]]
Reason why(
const Ctx& ctx, std::size_t i, std::int64_t now)
const noexcept {
457 const Leg& h = hedges_[i];
458 const VenueId v = venue_of_[n_sources_ + i];
462 const auto& b = ctx.book(h.id);
475 [[nodiscard]]
bool can_hedge(
const Ctx& ctx)
const noexcept {
476 if (!ready_ || halted_)
return false;
477 const std::int64_t now = ctx.now().
ns;
478 for (std::size_t i = 0; i < n_hedges_; ++i) {
485 [[nodiscard]]
Status status(
const Ctx& ctx)
const noexcept {
489 s.
active =
static_cast<std::uint8_t
>(active_);
505 if (!inst.contract_multiplier.is_positive())
return Qty{};
519 std::uint32_t tag)
noexcept {
523 if (inst.max_qty.is_positive() && qty > inst.max_qty) qty = inst.round_qty(inst.max_qty);
524 if (!qty.
is_positive() || qty < inst.min_qty)
return std::nullopt;
527 if (!best_ask.is_positive())
return std::nullopt;
528 px = inst.round_price(best_ask + best_ask * tolerance,
Side::Buy);
530 if (!best_bid.is_positive())
return std::nullopt;
531 px = inst.round_price(best_bid - best_bid * tolerance,
Side::Sell);
534 if (inst.min_notional.is_positive() && inst.notional(px, qty) < inst.min_notional)
548 while (q.
is_positive() && inst.notional(price, q) > cap) q = q - inst.lot;
559 Price price)
noexcept {
560 Qty room = h.max_order_qty;
561 room = std::min(room, side ==
Side::Buy ? h.buy_qty : h.sell_qty);
562 room = std::min(room, side ==
Side::Buy ? h.underlying_buy_qty : h.underlying_sell_qty);
563 Notional notional = h.max_order_notional;
565 std::min(notional, side ==
Side::Buy ? h.exposure_buy_notional : h.exposure_sell_notional);
577 if (room >= r.qty)
return false;
578 const Qty q = inst.round_qty(room);
579 if (!q.
is_positive() || q < inst.min_qty)
return false;
580 if (inst.min_notional.is_positive() && inst.notional(r.price, q) < inst.min_notional)
590 const Order& o = u.order;
591 return u.unresolved_qty.is_positive() ||
596 [[nodiscard]]
static constexpr std::string_view
to_string(
Reason r)
noexcept {
605 return "without a book";
609 return "held by the feed-lag gate";
615 [[nodiscard]]
static constexpr std::string_view
to_string(
State s)
noexcept {
626 return "reconciling";
632 return "unavailable";
643 std::uint32_t down = 0;
646 [[nodiscard]] Leg& leg(std::size_t i)
noexcept {
647 return i < n_sources_ ? sources_[i] : hedges_[i - n_sources_];
649 [[nodiscard]]
const Leg& leg(std::size_t i)
const noexcept {
650 return i < n_sources_ ? sources_[i] : hedges_[i - n_sources_];
652 [[nodiscard]]
int hedge_index(
InstrumentId id)
const noexcept {
653 for (std::size_t i = 0; i < n_hedges_; ++i) {
654 if (hedges_[i].
id ==
id)
return static_cast<int>(i);
659 void clear_state() noexcept {
661 for (Leg& l : sources_) l.down = 0;
662 for (Leg& l : hedges_) l.down = 0;
664 for (std::size_t i = 0; i <
kMaxHedges; ++i) {
671 unavailable_ =
false;
676 derisk_open_ =
false;
679 derisk_stuck_ =
false;
686 [[nodiscard]]
static RiskHeadroom headroom(
const Ctx& ctx,
InstrumentId id)
noexcept {
687 if constexpr (
requires { ctx.risk_headroom(
id); }) {
688 return ctx.risk_headroom(
id);
690 return RiskHeadroom{};
697 [[nodiscard]] std::optional<NewOrderRequest> order_on(
const Ctx& ctx,
700 bool* cut)
const noexcept {
701 const Leg& h = hedges_[i];
702 const auto& b = ctx.book(h.id);
703 const Instrument& inst = ctx.instrument(h.id);
704 std::optional<NewOrderRequest> r =
706 if (r) *cut =
fit_risk(headroom(ctx, h.id), inst, *r);
711 [[nodiscard]]
static bool covered(
const Ctx& ctx,
const NewOrderRequest& r)
noexcept {
712 return ctx.balance_room(r.instrument, r.side, r.price) >= r.qty;
716 [[nodiscard]]
bool in_flight(
const Ctx& ctx)
const noexcept {
717 if (derisk_open_)
return true;
718 for (std::size_t i = 0; i < n_hedges_; ++i) {
720 if (ctx.open_qty(
id,
Side::Buy).is_positive() || ctx.open_qty(
id,
Side::Sell).is_positive())
726 void hold_uncertain(
const Order& o, std::int64_t now)
noexcept {
729 if (until > next_ns_) next_ns_ = until;
731 "{}: order {} ended without the venue saying how; next order in {} ms at the earliest",
738 void switch_to(
const Ctx& ctx, std::size_t k, std::int64_t now)
noexcept {
739 const std::size_t from = active_;
747 "{}: hedging moves from {} (instrument {}) to {} (instrument {}): the first is {}",
749 ctx.instrument(a).symbol.view(),
751 ctx.instrument(b).symbol.view(),
755 FASTMM_LOG_WARN(
"{}: hedging back on {} (instrument {}) from {} (instrument {})",
757 ctx.instrument(b).symbol.view(),
759 ctx.instrument(a).symbol.view(),
765 void failed(Ctx& ctx, std::size_t k, std::int64_t now)
noexcept {
767 next_ns_ = now + cfg_.
retry.
ns;
768 const auto n =
static_cast<std::size_t
>(cfg_.
max_failures);
769 std::size_t& count = failures_[k];
772 if (halted_ || count < n)
return;
773 const std::int64_t oldest = fail_ns_[k][(count - n) %
kMaxFailures];
776 for (std::size_t i = 0; i < n_hedges_; ++i) {
777 if (i != k && now >= bench_until_[i]) other =
true;
779 const std::string_view sym = ctx.instrument(hedges_[k].
id).symbol.view();
781 bench_until_[k] = now + cfg_.
bench.
ns;
785 "{}: {} hedges on {} (instrument {}) filled nothing within {} ms: it sits "
798 "{}: {} hedges on {} filled nothing within {} ms: hedging stopped with {} unhedged; "
811 void blocked(Ctx& ctx,
Qty residual, std::int64_t now)
noexcept {
820 derisk_stuck_ =
false;
823 "{}: no hedge instrument has taken {} for {} ms: de-risking the sources in steps of at "
830 if (now < next_derisk_ns_)
return;
835 void unblock(std::string_view
why)
noexcept {
836 unavailable_ =
false;
838 if (!derisking_)
return;
844 void derisk_step(Ctx& ctx,
Qty residual, std::int64_t now)
noexcept {
846 for (std::size_t i = 0; i < n_sources_; ++i) {
847 const Leg& s = sources_[i];
848 const Instrument& inst = ctx.instrument(s.id);
849 const Qty pos =
to_base(inst, ctx.position(s.id).qty);
852 if (s.down != 0 || ctx.venue_killed(inst.venue))
continue;
853 const auto& b = ctx.book(s.id);
854 if (!b.is_valid())
continue;
856 if (pos.abs() < base) base = pos.
abs();
858 std::optional<NewOrderRequest> r =
hedge_order(inst,
862 cfg_.derisk_tolerance,
866 if (!inst.is_derivative() && ctx.balance_room(s.id, r->side, r->price) < r->qty)
continue;
867 NewOrderRequest req = *r;
868 req.reduce_only =
true;
869 static_cast<void>(
fit_risk(headroom(ctx, s.id), inst, req));
871 const auto sent = ctx.send(req);
884 derisk_stuck_ =
false;
888 if (!derisk_stuck_) {
889 derisk_stuck_ =
true;
895 std::array<Leg, kMaxSources> sources_{};
896 std::array<Leg, kMaxHedges> hedges_{};
897 std::array<VenueId, kMaxSources + kMaxHedges> venue_of_{};
898 std::size_t n_sources_ = 0;
899 std::size_t n_hedges_ = 0;
901 std::int64_t next_ns_ = 0;
902 std::array<std::size_t, kMaxHedges> failures_{};
903 std::array<std::array<std::int64_t, kMaxFailures>,
kMaxHedges> fail_ns_{};
904 std::array<std::int64_t, kMaxHedges> bench_until_{};
905 std::size_t active_ = 0;
909 bool halted_ =
false;
911 bool unavailable_ =
false;
914 bool blocked_ =
false;
915 bool derisking_ =
false;
916 bool derisk_open_ =
false;
917 bool derisk_stuck_ =
false;
918 std::int64_t blocked_ns_ = 0;
919 std::int64_t next_derisk_ns_ = 0;
bool add_hedge(InstrumentId id, Ratio tolerance) noexcept
Definition hedge_executor.hpp:159
std::size_t active() const noexcept
Definition hedge_executor.hpp:422
bool involves(VenueId v) const noexcept
A venue of any leg.
Definition hedge_executor.hpp:435
static constexpr bool fit_risk(const RiskHeadroom &h, const Instrument &inst, NewOrderRequest &r) noexcept
Cuts r to risk_room() when that is less and still an order the instrument takes (the lot,...
Definition hedge_executor.hpp:571
State state() const noexcept
Definition hedge_executor.hpp:418
void update(Ctx &ctx) noexcept
Looks at the positions and sends what they call for; the hooks above end here.
Definition hedge_executor.hpp:289
Qty residual(const Ctx &ctx) const noexcept
Sources plus hedges minus the target, base units.
Definition hedge_executor.hpp:444
bool is_leg(InstrumentId id) const noexcept
Definition hedge_executor.hpp:431
bool on_fill(Ctx &ctx, const Fill &fill) noexcept
A fill of any leg: the residual moved. False for another instrument.
Definition hedge_executor.hpp:223
static constexpr std::size_t kMaxSources
Definition hedge_executor.hpp:86
void on_timer(Ctx &ctx) noexcept
Definition hedge_executor.hpp:257
void restart() noexcept
Clears a halt, the benches and the failure counts; hedging resumes from the positions.
Definition hedge_executor.hpp:211
InstrumentId hedge_id(std::size_t i) const noexcept
Definition hedge_executor.hpp:421
bool ready() const noexcept
Definition hedge_executor.hpp:413
void set_config(const Config &cfg) noexcept
Parameters may change while running (on_params); the legs may not.
Definition hedge_executor.hpp:204
Status status(const Ctx &ctx) const noexcept
Definition hedge_executor.hpp:484
bool on_order_update(Ctx &ctx, const OmsUpdate &u) noexcept
The end of a hedge or de-risk order: counts a failure or holds, then looks again.
Definition hedge_executor.hpp:232
bool can_hedge(const Ctx &ctx) const noexcept
Some hedge instrument can take a hedge now, and hedging is not halted.
Definition hedge_executor.hpp:474
bool start(Ctx &ctx, const Config &cfg) noexcept
Checks the legs against the instrument table: each is configured, linear, used once,...
Definition hedge_executor.hpp:167
static constexpr Qty to_base(const Instrument &inst, Qty contracts) noexcept
Contracts to base units and back (linear: qty * multiplier).
Definition hedge_executor.hpp:499
Qty target() const noexcept
Definition hedge_executor.hpp:423
static constexpr Qty risk_room(const RiskHeadroom &h, const Instrument &inst, Side side, Price price) noexcept
The largest order of side on inst at price that [risk] admits now: max_order_qty, max_order_notional ...
Definition hedge_executor.hpp:554
static constexpr std::string_view to_string(Reason r) noexcept
Definition hedge_executor.hpp:594
const Stats & stats() const noexcept
Definition hedge_executor.hpp:419
bool is_source(InstrumentId id) const noexcept
Definition hedge_executor.hpp:425
bool held() const noexcept
The last hedge the positions asked for fits no usable instrument's balance.
Definition hedge_executor.hpp:416
static constexpr std::size_t kMaxHedges
Definition hedge_executor.hpp:87
static bool uncertain(const OmsUpdate &u) noexcept
A terminal update whose outcome the venue did not report: the ack timeout cancelled an order the venu...
Definition hedge_executor.hpp:587
void reset() noexcept
Forgets the legs and every state but the stats. Call before adding legs in on_start.
Definition hedge_executor.hpp:147
std::size_t hedge_count() const noexcept
Definition hedge_executor.hpp:420
void set_target(Qty base) noexcept
The net base position the strategy wants to hold; the residual is measured from it.
Definition hedge_executor.hpp:209
bool on_balance(Ctx &ctx, const BalanceMsg &m) noexcept
A balance report of a leg's venue: a held hedge may fit now. False for another venue.
Definition hedge_executor.hpp:281
bool halted() const noexcept
Definition hedge_executor.hpp:414
Reason why(const Ctx &ctx, std::size_t i, std::int64_t now) const noexcept
Why hedge instrument i cannot take a hedge now (Reason::Usable: it can).
Definition hedge_executor.hpp:455
void on_connection(Ctx &, const ConnectionStateMsg &m) noexcept
Order channels (channel != 0) of the legs' venues.
Definition hedge_executor.hpp:265
bool derisking() const noexcept
Definition hedge_executor.hpp:417
State
What the last evaluation found.
Definition hedge_executor.hpp:119
@ Holding
retry backoff or uncertain hold
@ Reconciling
a venue reconciles
@ Unavailable
no hedge instrument is usable
@ Waiting
the residual rounds under the hedge instrument's minimum
@ Halted
every hedge instrument failed max_failures times; restart() clears it
@ Flat
the residual is zero
@ InFlight
a hedge or de-risk order is open
@ Idle
not started, or nothing evaluated yet
@ Held
no usable instrument's balance or margin covers the hedge
static constexpr std::size_t kMaxFailures
Definition hedge_executor.hpp:88
bool is_hedge(InstrumentId id) const noexcept
Definition hedge_executor.hpp:424
bool add_source(InstrumentId id) noexcept
Definition hedge_executor.hpp:154
static std::optional< NewOrderRequest > hedge_order(const Instrument &inst, Qty residual, Price best_bid, Price best_ask, Ratio tolerance, std::uint32_t tag) noexcept
The order on inst that brings residual (base units) back towards zero: an IOC of -residual in contrac...
Definition hedge_executor.hpp:512
Reason
Why a hedge instrument is not usable now.
Definition hedge_executor.hpp:132
void on_book(Ctx &ctx, InstrumentId id) noexcept
A hedge instrument's book: a new touch to price against.
Definition hedge_executor.hpp:252
static constexpr Qty to_contracts(const Instrument &inst, Qty base) noexcept
Definition hedge_executor.hpp:502
static constexpr Qty qty_within(const Instrument &inst, Price price, Notional cap) noexcept
The largest quantity of inst whose notional at price is at most cap, rounded down to the lot (zero wh...
Definition hedge_executor.hpp:539
void set_tolerance(std::size_t hedge, Ratio tolerance) noexcept
Definition hedge_executor.hpp:205
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Strategy hooks (ADR-0012): the hook table, the compile-time checker and the Fill view.
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Asynchronous logging (5.10).
#define FASTMM_LOG_WARN(fmt_str,...)
Definition log.hpp:336
#define FASTMM_LOG_INFO(fmt_str,...)
Definition log.hpp:334
#define FASTMM_LOG_ERROR(fmt_str,...)
Definition log.hpp:338
Event bus message structs (5.5).
Definition strategy.hpp:16
StrongId< struct ClientOrderTag, std::uint64_t, 0 > ClientOrderId
48-bit: session_epoch(16) << 32 | seq(32). 0 is never issued.
Definition strong_id.hpp:41
constexpr Duration milliseconds(std::int64_t v) noexcept
Definition time.hpp:38
constexpr std::int64_t kFixedScale
1e-8
Definition fixed_point.hpp:23
@ VenueReject
Venue-originated.
Side
Definition enums.hpp:12
Fixed< struct QtyTag > Qty
Definition fixed_point.hpp:333
StrongId< struct InstrumentTag, std::uint32_t > InstrumentId
Dense index into the engine's instrument table.
Definition strong_id.hpp:38
FixedString< 16 > encode_cl_ord_id(ClientOrderId id) noexcept
Definition strong_id.hpp:77
constexpr std::int64_t mul_raw(Fixed< A > a, Fixed< B > b) noexcept
Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier).
Definition fixed_point.hpp:367
Fixed< RatioTag > Ratio
A dimensionless factor: 1.0 == 1e8 raw, 1 bp == 10'000 raw, so 0.0001 bp is the smallest step.
Definition fixed_point.hpp:336
StrongId< struct VenueTag, std::uint8_t > VenueId
Definition strong_id.hpp:39
Order management (5.8): a Pool<Order> + OpenHashMap<ClientOrderId, Handle> + a ring of recently termi...
Order: the OMS's 128-byte record for one order across its lifetime.
RiskLimits: the pre-trade limits a session runs with ([risk] in the configuration),...
The account's holding of one asset on one venue (EventType::Balance), as the venue reports it at its ...
Definition messages.hpp:315
Definition messages.hpp:452
std::int64_t ns
Definition time.hpp:23
constexpr std::int64_t millis() const noexcept
Definition time.hpp:29
One execution as a strategy sees it (on_fill).
Definition hooks.hpp:56
constexpr bool is_negative() const noexcept
Definition fixed_point.hpp:303
static constexpr Fixed max() noexcept
Definition fixed_point.hpp:165
constexpr Fixed abs() const noexcept
Definition fixed_point.hpp:304
static constexpr Fixed from_raw(std::int64_t r) noexcept
Definition fixed_point.hpp:155
constexpr bool is_zero() const noexcept
Definition fixed_point.hpp:301
std::int64_t raw
Definition fixed_point.hpp:152
constexpr bool is_positive() const noexcept
Definition fixed_point.hpp:302
static constexpr Fixed from_int(std::int64_t units) noexcept
Whole units, e.g. from_int(100) == 100.00000000.
Definition fixed_point.hpp:161
Definition hedge_executor.hpp:90
Duration stale
a hedge book older than this is unusable; 0: never
Definition hedge_executor.hpp:98
Duration failure_window
Definition hedge_executor.hpp:96
Duration uncertain_hold
Definition hedge_executor.hpp:97
Qty derisk_step
base units per de-risk order; 0: the whole residual
Definition hedge_executor.hpp:101
int max_failures
within failure_window: bench, or halt on the last one
Definition hedge_executor.hpp:95
std::uint32_t tag
user_tag of hedge orders
Definition hedge_executor.hpp:92
Duration bench
how long a failing instrument sits out
Definition hedge_executor.hpp:99
std::uint32_t derisk_tag
user_tag of de-risk orders
Definition hedge_executor.hpp:93
Duration derisk_interval
Definition hedge_executor.hpp:102
Duration derisk_after
0: never de-risk
Definition hedge_executor.hpp:100
Ratio derisk_tolerance
Definition hedge_executor.hpp:103
Duration retry
after a hedge that filled nothing
Definition hedge_executor.hpp:94
std::string_view name
log prefix
Definition hedge_executor.hpp:91
Definition hedge_executor.hpp:106
std::uint64_t failovers
hedging moved to a later instrument in the list
Definition hedge_executor.hpp:112
std::uint64_t hedges_sent
Definition hedge_executor.hpp:107
std::uint64_t benches
instruments benched after max_failures
Definition hedge_executor.hpp:113
std::uint64_t derisk_orders
Definition hedge_executor.hpp:115
std::uint64_t halts
Definition hedge_executor.hpp:110
std::uint64_t hedges_held
episodes of a hedge no balance or margin could cover
Definition hedge_executor.hpp:111
std::uint64_t uncertain_ends
ended without the venue saying how
Definition hedge_executor.hpp:109
std::uint64_t derisk_episodes
Definition hedge_executor.hpp:114
std::uint64_t hedge_failures
ended with nothing filled, or refused by the engine
Definition hedge_executor.hpp:108
Definition hedge_executor.hpp:134
Timestamp hold_until
end of the last retry or uncertain hold
Definition hedge_executor.hpp:142
bool held
Definition hedge_executor.hpp:139
std::uint8_t active
index of the hedge instrument hedges go to
Definition hedge_executor.hpp:137
bool halted
Definition hedge_executor.hpp:140
bool in_flight
Definition hedge_executor.hpp:138
bool derisking
Definition hedge_executor.hpp:141
Qty residual
Definition hedge_executor.hpp:136
State state
Definition hedge_executor.hpp:135
Definition instrument.hpp:29
constexpr LimitOrder tag(std::uint32_t user_tag) const noexcept
user_tag: echoed in the order record.
Definition order.hpp:112
constexpr LimitOrder ioc() const noexcept
Definition order.hpp:105
Side side
Definition order.hpp:73
Price price
Definition order.hpp:78
static constexpr LimitOrder limit(InstrumentId instrument, Side side, Price price, Qty qty) noexcept
A GTC limit order, refined with the builder's methods: ctx.send(NewOrderRequest::limit(id,...
Definition order.hpp:126
InstrumentId instrument
Definition order.hpp:67
Qty qty
Definition order.hpp:79
OrderState state
1
Definition order.hpp:34
VenueOrderId venue_order_id
41 -> 49
Definition order.hpp:27
ClientOrderId cl_ord_id
8
Definition order.hpp:26
InstrumentId instrument
4 -> 60
Definition order.hpp:29
RejectReason reject_reason
1
Definition order.hpp:35
Qty cum_qty
8 -> 96
Definition order.hpp:41
How much more each limit admits for one instrument now: the largest order (or number of orders) that ...
Definition risk_limits.hpp:50
std::int64_t ns
Definition time.hpp:46
constexpr bool valid() const noexcept
Definition time.hpp:55
VenueHealth: per venue, how late its market data arrives and how long our orders take to be acknowled...