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

The prices, the windows and the learned yields of one engine. More...

#include <fastmm/core/capacity_price.hpp>

Public Member Functions

void configure (const CapacityConfig &cfg) noexcept
 
const CapacityConfig & config () const noexcept
 
bool on () const noexcept
 
CapacityMode mode () const noexcept
 
const CapacityThreshold & threshold () const noexcept
 
double floor () const noexcept
 
bool prices (VenueId account) const noexcept
 Whether orders on account are priced ([capacity] venues).
 
bool enforces (bool move) const noexcept
 Whether a refusal below the price is enforced for a new order or for a move.
 
void on_send (VenueId account, VenueId primary, InstrumentId id, Side side, double notional, std::int64_t now_ns) noexcept
 A new order or a replace went to account (of the pool whose primary is primary).
 
void on_request (VenueId primary, std::int64_t now_ns) noexcept
 A cancel (or any other request) of the pool: weight only.
 
void on_fill (VenueId account, InstrumentId id, Side side, double order_notional, double fill_notional, bool first, std::int64_t now_ns) noexcept
 A fill of an order placed with order_notional; first: the order's first fill.
 
CapacityQuote quote (VenueId account, VenueId primary, std::int64_t now_ns) const noexcept
 
double price (VenueId account, VenueId primary, std::int64_t now_ns) const noexcept
 
double learned_value (InstrumentId id, Side side, double notional) const noexcept
 The learned value of a quote of notional on (id, side), quote currency.
 
bool decide (VenueId account, double value, double price, bool move, bool enforced, InstrumentId id=InstrumentId{}, Side side=Side::Buy, std::int64_t now_ns=0) noexcept
 An action of value (a move: its gain) was priced at price on account; returns whether it passes.
 
const CapacityMinute & totals () const noexcept
 
bool recheck_due (std::int64_t now_ns) const noexcept
 A priced-out level is applied again once a window has rolled over or a fill gave a slot back.
 
void rechecked (std::int64_t now_ns) noexcept
 
bool tick_due (std::int64_t now_ns) const noexcept
 
template<class Emit >
void tick (std::int64_t now_ns, Emit &&emit) noexcept
 Once a minute: decay the yields, refit the floor and the day prices, and hand each account's minute to emit(VenueId, const CapacityMinute&) before clearing it.
 
double day_price (VenueId account) const noexcept
 

Static Public Attributes

static constexpr int kClasses = 6
 by notional over the minimum: <2, <6, <12, <22, <60, more
 
static constexpr double kPriorYield = 0.02
 filled per placed notional before any is learned
 
static constexpr double kShrinkOrders = 20.0
 a cell's estimate leans on its class's for this
 
static constexpr std::int64_t kTickNs = 60'000'000'000
 
static constexpr std::int64_t kWeightWindowNs = 60'000'000'000
 
static constexpr double kYieldHalfLifeS = 6.0 * 3600.0
 

Detailed Description

The prices, the windows and the learned yields of one engine.

Member Function Documentation

◆ configure()

void fastmm::CapacityPrice::configure ( const CapacityConfig &  cfg)
inlinenoexcept

◆ config()

const CapacityConfig & fastmm::CapacityPrice::config ( ) const
inlinenoexcept

◆ on()

bool fastmm::CapacityPrice::on ( ) const
inlinenoexcept

◆ mode()

CapacityMode fastmm::CapacityPrice::mode ( ) const
inlinenoexcept

◆ threshold()

const CapacityThreshold & fastmm::CapacityPrice::threshold ( ) const
inlinenoexcept

◆ floor()

double fastmm::CapacityPrice::floor ( ) const
inlinenoexcept

◆ prices()

bool fastmm::CapacityPrice::prices ( VenueId  account) const
inlinenoexcept

Whether orders on account are priced ([capacity] venues).

◆ enforces()

bool fastmm::CapacityPrice::enforces ( bool  move) const
inlinenoexcept

Whether a refusal below the price is enforced for a new order or for a move.

◆ on_send()

void fastmm::CapacityPrice::on_send ( VenueId  account,
VenueId  primary,
InstrumentId  id,
Side  side,
double  notional,
std::int64_t  now_ns 
)
inlinenoexcept

A new order or a replace went to account (of the pool whose primary is primary).

◆ on_request()

void fastmm::CapacityPrice::on_request ( VenueId  primary,
std::int64_t  now_ns 
)
inlinenoexcept

A cancel (or any other request) of the pool: weight only.

◆ on_fill()

void fastmm::CapacityPrice::on_fill ( VenueId  account,
InstrumentId  id,
Side  side,
double  order_notional,
double  fill_notional,
bool  first,
std::int64_t  now_ns 
)
inlinenoexcept

A fill of an order placed with order_notional; first: the order's first fill.

◆ quote()

CapacityQuote fastmm::CapacityPrice::quote ( VenueId  account,
VenueId  primary,
std::int64_t  now_ns 
) const
inlinenoexcept

◆ price()

double fastmm::CapacityPrice::price ( VenueId  account,
VenueId  primary,
std::int64_t  now_ns 
) const
inlinenoexcept

◆ learned_value()

double fastmm::CapacityPrice::learned_value ( InstrumentId  id,
Side  side,
double  notional 
) const
inlinenoexcept

The learned value of a quote of notional on (id, side), quote currency.

◆ decide()

bool fastmm::CapacityPrice::decide ( VenueId  account,
double  value,
double  price,
bool  move,
bool  enforced,
InstrumentId  id = InstrumentId{},
Side  side = Side::Buy,
std::int64_t  now_ns = 0 
)
inlinenoexcept

An action of value (a move: its gain) was priced at price on account; returns whether it passes.

Records it in the account's minute and in the day's demand. A refusal of instrument id's side that was already refused in the same window is the same demand asked again (a strategy requoting a priced-out level): refused, and recorded once.

< unpriced

◆ totals()

const CapacityMinute & fastmm::CapacityPrice::totals ( ) const
inlinenoexcept

◆ recheck_due()

bool fastmm::CapacityPrice::recheck_due ( std::int64_t  now_ns) const
inlinenoexcept

A priced-out level is applied again once a window has rolled over or a fill gave a slot back.

◆ rechecked()

void fastmm::CapacityPrice::rechecked ( std::int64_t  now_ns)
inlinenoexcept

◆ tick_due()

bool fastmm::CapacityPrice::tick_due ( std::int64_t  now_ns) const
inlinenoexcept

◆ tick()

template<class Emit >
void fastmm::CapacityPrice::tick ( std::int64_t  now_ns,
Emit &&  emit 
)
inlinenoexcept

Once a minute: decay the yields, refit the floor and the day prices, and hand each account's minute to emit(VenueId, const CapacityMinute&) before clearing it.

◆ day_price()

double fastmm::CapacityPrice::day_price ( VenueId  account) const
inlinenoexcept

Member Data Documentation

◆ kClasses

constexpr int fastmm::CapacityPrice::kClasses = 6
staticconstexpr

by notional over the minimum: <2, <6, <12, <22, <60, more

◆ kPriorYield

constexpr double fastmm::CapacityPrice::kPriorYield = 0.02
staticconstexpr

filled per placed notional before any is learned

◆ kShrinkOrders

constexpr double fastmm::CapacityPrice::kShrinkOrders = 20.0
staticconstexpr

a cell's estimate leans on its class's for this

◆ kTickNs

constexpr std::int64_t fastmm::CapacityPrice::kTickNs = 60'000'000'000
staticconstexpr

◆ kWeightWindowNs

constexpr std::int64_t fastmm::CapacityPrice::kWeightWindowNs = 60'000'000'000
staticconstexpr

◆ kYieldHalfLifeS

constexpr double fastmm::CapacityPrice::kYieldHalfLifeS = 6.0 * 3600.0
staticconstexpr