FastMM documentation
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::QuoteManager Class Reference

#include <fastmm/core/quote_manager.hpp>

Public Member Functions

 QuoteManager (const QuoteParams &p={}) noexcept
 
const QuoteParams & params () const noexcept
 
void set_params (const QuoteParams &p) noexcept
 
const QuoteStats & stats () const noexcept
 
void set_replace (InstrumentId id, bool on) noexcept
 Whether the instrument's venue amends in place (default true; supports_replace still applies).
 
bool replaces (InstrumentId id) const noexcept
 
template<class Placer >
std::uint32_t reconcile (const Instrument &inst, const DesiredQuotes &desired, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Reconciles desired vs resting for one instrument. Returns the number of actions placed.
 
template<class Placer >
std::uint32_t pull_quotes (const Instrument &inst, const Oms &oms, Placer &&place, bool keep_desired=false) noexcept
 Cancels every working quote on the instrument and suppresses re-quoting until the next reconcile().
 
void pause_quotes (InstrumentId id) noexcept
 Holds the instrument's orders as they are until resume(): no New, Cancel or Replace, and a target recorded for a slot is dropped (resume() re-applies the whole ladder).
 
bool paused (InstrumentId id) const noexcept
 
template<class Placer >
std::uint32_t resume (const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Ends a pause and re-applies the desired quotes kept by pause_quotes() or pull_quotes(keep_desired) to the orders resting now.
 
bool resumable (InstrumentId id) const noexcept
 
void hold_side (Side side, bool on) noexcept
 Holds side on every instrument (on) or ends the hold (off).
 
bool side_held (Side side) const noexcept
 
void hold_side (InstrumentId id, Side side, bool on) noexcept
 The same for one instrument (the engine's hazard groups, core/hazard.hpp): the side is held while either hold is on.
 
bool side_held (InstrumentId id, Side side) const noexcept
 
template<class Placer >
std::uint32_t pull_side (const Instrument &inst, Side side, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Cancels the instrument's working quotes on side, now; one still pending is cancelled when its ack arrives.
 
template<class Placer >
std::uint32_t reapply (const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Re-applies the instrument's last desired quotes (a hold ended); one pulled or paused stays as it is.
 
bool starved () const noexcept
 Instruments whose quotes were held back for want of an order token, oldest first.
 
std::size_t starved_count () const noexcept
 
InstrumentId pop_starved () noexcept
 Takes the oldest starved instrument off the queue (the caller checks starved() first).
 
template<class Placer >
std::uint32_t retry (const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Re-applies the last desired quotes of an instrument popped from the starved queue; one that was pulled meanwhile stays pulled.
 
bool backed_off () const noexcept
 Instruments with a New held back by a side's reject backoff: once the backoff ends, the engine re-applies their last desired quotes (retry_backed_off), so a side comes back by itself rather than at the strategy's next requote, which a quiet market may not bring.
 
bool backoff_due (Timestamp now) const noexcept
 
template<class F >
void take_backoff_due (Timestamp now, F &&f) noexcept
 Takes each instrument whose held-back side may quote at now off the queue and calls f(InstrumentId); the others stay queued.
 
template<class Placer >
std::uint32_t retry_backed_off (const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Re-applies the last desired quotes of an instrument take_backoff_due() handed out; one pulled meanwhile stays pulled.
 
bool priced_out () const noexcept
 Instruments with a level priced out ([capacity]): the engine re-applies their last desired quotes (retry_priced) when the price may have fallen, a window rolling over or a fill giving a slot back.
 
template<class F >
void take_priced (F &&f) noexcept
 Takes every instrument queued now off the queue and calls f(InstrumentId); one priced out again during f queues itself for the next time.
 
template<class Placer >
std::uint32_t retry_priced (const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 
template<class Placer >
void on_order_update (const OmsUpdate &u, const Instrument &inst, const Oms &oms, Timestamp now, Placer &&place) noexcept
 Feed every OmsUpdate here.
 
Handle< Order > slot_handle (InstrumentId id, Side s, std::uint32_t level) const noexcept
 
bool pulled (InstrumentId id) const noexcept
 
const DesiredQuotes & desired (InstrumentId id) const noexcept
 The last ladder reconcile() applied to the instrument (empty after a pull).
 
bool starved (InstrumentId id) const noexcept
 The instrument waits for an order token (a New or Replace was rate-limited).
 
bool backing_off (InstrumentId id, Side s, Timestamp now) const noexcept
 The side is in its venue-reject backoff at now.
 

Static Public Member Functions

static constexpr std::uint32_t make_tag (Side s, std::uint32_t level) noexcept
 user_tag encoding so a terminal OmsUpdate can be mapped back to its slot.
 
static constexpr bool is_quote_tag (std::uint32_t tag) noexcept
 

Constructor & Destructor Documentation

◆ QuoteManager()

fastmm::QuoteManager::QuoteManager ( const QuoteParams &  p = {})
inlineexplicitnoexcept

Member Function Documentation

◆ params()

const QuoteParams & fastmm::QuoteManager::params ( ) const
inlinenoexcept

◆ set_params()

void fastmm::QuoteManager::set_params ( const QuoteParams &  p)
inlinenoexcept

◆ stats()

const QuoteStats & fastmm::QuoteManager::stats ( ) const
inlinenoexcept

◆ set_replace()

void fastmm::QuoteManager::set_replace ( InstrumentId  id,
bool  on 
)
inlinenoexcept

Whether the instrument's venue amends in place (default true; supports_replace still applies).

◆ replaces()

bool fastmm::QuoteManager::replaces ( InstrumentId  id) const
inlinenoexcept

◆ make_tag()

static constexpr std::uint32_t fastmm::QuoteManager::make_tag ( Side  s,
std::uint32_t  level 
)
inlinestaticconstexprnoexcept

user_tag encoding so a terminal OmsUpdate can be mapped back to its slot.

◆ is_quote_tag()

static constexpr bool fastmm::QuoteManager::is_quote_tag ( std::uint32_t  tag)
inlinestaticconstexprnoexcept

◆ reconcile()

template<class Placer >
std::uint32_t fastmm::QuoteManager::reconcile ( const Instrument &  inst,
const DesiredQuotes &  desired,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Reconciles desired vs resting for one instrument. Returns the number of actions placed.

A level the ladder does not ask for and whose slot is empty has nothing to reconcile.

◆ pull_quotes()

template<class Placer >
std::uint32_t fastmm::QuoteManager::pull_quotes ( const Instrument &  inst,
const Oms &  oms,
Placer &&  place,
bool  keep_desired = false 
)
inlinenoexcept

Cancels every working quote on the instrument and suppresses re-quoting until the next reconcile().

With keep_desired (a pause, not a decision to stop quoting) the last desired quotes are kept for resume(), unless the instrument was already pulled.

< pending: cannot touch; a later pull will catch it

◆ pause_quotes()

void fastmm::QuoteManager::pause_quotes ( InstrumentId  id)
inlinenoexcept

Holds the instrument's orders as they are until resume(): no New, Cancel or Replace, and a target recorded for a slot is dropped (resume() re-applies the whole ladder).

The last desired quotes are kept for resume() unless the instrument was already pulled. Sends nothing.

◆ paused()

bool fastmm::QuoteManager::paused ( InstrumentId  id) const
inlinenoexcept

◆ resume()

template<class Placer >
std::uint32_t fastmm::QuoteManager::resume ( const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Ends a pause and re-applies the desired quotes kept by pause_quotes() or pull_quotes(keep_desired) to the orders resting now.

Returns the actions placed.

◆ resumable()

bool fastmm::QuoteManager::resumable ( InstrumentId  id) const
inlinenoexcept

◆ hold_side() [1/2]

void fastmm::QuoteManager::hold_side ( Side  side,
bool  on 
)
inlinenoexcept

Holds side on every instrument (on) or ends the hold (off).

While it holds, the side's levels count as empty wherever quotes are reconciled; the desired quotes keep them for reapply().

◆ side_held() [1/2]

bool fastmm::QuoteManager::side_held ( Side  side) const
inlinenoexcept

◆ hold_side() [2/2]

void fastmm::QuoteManager::hold_side ( InstrumentId  id,
Side  side,
bool  on 
)
inlinenoexcept

The same for one instrument (the engine's hazard groups, core/hazard.hpp): the side is held while either hold is on.

◆ side_held() [2/2]

bool fastmm::QuoteManager::side_held ( InstrumentId  id,
Side  side 
) const
inlinenoexcept

◆ pull_side()

template<class Placer >
std::uint32_t fastmm::QuoteManager::pull_side ( const Instrument &  inst,
Side  side,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Cancels the instrument's working quotes on side, now; one still pending is cancelled when its ack arrives.

The other side and the desired quotes stay as they are. Returns the actions placed.

◆ reapply()

template<class Placer >
std::uint32_t fastmm::QuoteManager::reapply ( const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Re-applies the instrument's last desired quotes (a hold ended); one pulled or paused stays as it is.

◆ starved() [1/2]

bool fastmm::QuoteManager::starved ( ) const
inlinenoexcept

Instruments whose quotes were held back for want of an order token, oldest first.

◆ starved_count()

std::size_t fastmm::QuoteManager::starved_count ( ) const
inlinenoexcept

◆ pop_starved()

InstrumentId fastmm::QuoteManager::pop_starved ( )
inlinenoexcept

Takes the oldest starved instrument off the queue (the caller checks starved() first).

◆ retry()

template<class Placer >
std::uint32_t fastmm::QuoteManager::retry ( const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Re-applies the last desired quotes of an instrument popped from the starved queue; one that was pulled meanwhile stays pulled.

An action held back again queues it at the back.

◆ backed_off()

bool fastmm::QuoteManager::backed_off ( ) const
inlinenoexcept

Instruments with a New held back by a side's reject backoff: once the backoff ends, the engine re-applies their last desired quotes (retry_backed_off), so a side comes back by itself rather than at the strategy's next requote, which a quiet market may not bring.

◆ backoff_due()

bool fastmm::QuoteManager::backoff_due ( Timestamp  now) const
inlinenoexcept

◆ take_backoff_due()

template<class F >
void fastmm::QuoteManager::take_backoff_due ( Timestamp  now,
F &&  f 
)
inlinenoexcept

Takes each instrument whose held-back side may quote at now off the queue and calls f(InstrumentId); the others stay queued.

◆ retry_backed_off()

template<class Placer >
std::uint32_t fastmm::QuoteManager::retry_backed_off ( const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Re-applies the last desired quotes of an instrument take_backoff_due() handed out; one pulled meanwhile stays pulled.

A side still backing off queues it again.

◆ priced_out()

bool fastmm::QuoteManager::priced_out ( ) const
inlinenoexcept

Instruments with a level priced out ([capacity]): the engine re-applies their last desired quotes (retry_priced) when the price may have fallen, a window rolling over or a fill giving a slot back.

◆ take_priced()

template<class F >
void fastmm::QuoteManager::take_priced ( F &&  f)
inlinenoexcept

Takes every instrument queued now off the queue and calls f(InstrumentId); one priced out again during f queues itself for the next time.

◆ retry_priced()

template<class Placer >
std::uint32_t fastmm::QuoteManager::retry_priced ( const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

◆ on_order_update()

template<class Placer >
void fastmm::QuoteManager::on_order_update ( const OmsUpdate &  u,
const Instrument &  inst,
const Oms &  oms,
Timestamp  now,
Placer &&  place 
)
inlinenoexcept

Feed every OmsUpdate here.

A terminal update frees the slot it belonged to and, if a target was recorded for it (cancel-then-new, or a requote that met the order pending), places the New now. The ack of an order that was pending at a requote applies the recorded target. While the instrument is pulled, an order that has just become working is cancelled instead.

< the venue takes this side

The terminal order was this slot's unless the slot already holds a newer live order. Ids are not compared: a replace changes the order's id, and a stale id used to drop the update and leave the slot waiting for a terminal state forever.

◆ slot_handle()

Handle< Order > fastmm::QuoteManager::slot_handle ( InstrumentId  id,
Side  s,
std::uint32_t  level 
) const
inlinenoexcept

◆ pulled()

bool fastmm::QuoteManager::pulled ( InstrumentId  id) const
inlinenoexcept

◆ desired()

const DesiredQuotes & fastmm::QuoteManager::desired ( InstrumentId  id) const
inlinenoexcept

The last ladder reconcile() applied to the instrument (empty after a pull).

◆ starved() [2/2]

bool fastmm::QuoteManager::starved ( InstrumentId  id) const
inlinenoexcept

The instrument waits for an order token (a New or Replace was rate-limited).

◆ backing_off()

bool fastmm::QuoteManager::backing_off ( InstrumentId  id,
Side  s,
Timestamp  now 
) const
inlinenoexcept

The side is in its venue-reject backoff at now.