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

The capacity price ([capacity]): every action that uses an order slot is a purchase. More...

#include "fastmm/core/enums.hpp"
#include "fastmm/core/instrument.hpp"
#include "fastmm/core/order.hpp"
#include "fastmm/core/strong_id.hpp"
#include "fastmm/core/transport.hpp"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string_view>

Go to the source code of this file.

Classes

struct  fastmm::CapacityConfig
 
struct  fastmm::CapacityQuote
 What an action costs on one account now (ctx.capacity). More...
 
struct  fastmm::CapacityMinute
 A minute of one account (CapacityRecord): what was priced and refused. More...
 
class  fastmm::CapacityThreshold
 h(z): the knapsack threshold as a multiple of L, precomputed. More...
 
class  fastmm::CapacityDayPrice
 The day price of one budget: the value at which the rest of the day's demand fits what is left. More...
 
class  fastmm::CapacityPrice
 The prices, the windows and the learned yields of one engine. More...
 

Namespaces

namespace  fastmm
 

Enumerations

enum class  fastmm::CapacityMode : std::uint8_t { fastmm::Off = 0 , fastmm::Observe = 1 , fastmm::New = 2 , fastmm::Enforce = 3 }
 
enum class  fastmm::CapacityValue : std::uint8_t { fastmm::Off = 0 , fastmm::Learned = 1 }
 The value of a quote level whose strategy states none. More...
 

Functions

constexpr std::string_view fastmm::to_string (CapacityMode m) noexcept
 

Detailed Description

The capacity price ([capacity]): every action that uses an order slot is a purchase.

A new order, and a move of a resting one, takes a slot of its account's order window and of the day's orders. It is sent when what it is worth is at least what the slots cost at that moment:

send iff value >= price(account) = L * h(z_window) + L * (h(z_weight) - 1) + day prices

value what the strategy says the order brings in (the level's or NewOrderRequest's value), in the quote currency; else the [capacity] value default: "off" (worth any price) or "learned" (notional * yield * margin_bps, the yield being the filled notional per placed notional of the instrument, side and size class) a move buys the gain: the value at the new price less the resting order's (keep). A move away from the touch cancels for free; its new order is bought as a new one L what an order of the venue's minimum notional is worth at the session's yield h(z) the online-knapsack threshold on the share z of the window used (Zhou, Chakrabarty and Lukose 2008): 1 below z0 = 1 / (1 + ln R), (R e)^z / e above, R at a full window; R = [risk] max_order_notional / the minimum notional z_window the account's orders in the current window less the first fills in it (a venue that credits fills), over orders_10s z_weight the pool's requests in the current minute over weight_1m (0: not priced) day prices the account's (orders_1d) and the strategy's (orders_per_day): the value at which the demand of the rest of the UTC day fits what is left of the budget, shared out by the demand of each hour of the day

Cancels are never priced. A level whose order is not worth its price is priced out: its target stays in its slot, and the engine applies it again when the window rolls over or a fill gives a slot back. Every input is the engine's own: its sends, its fills, the configuration and the clock, so a replay prices every order as the session did.

Hot path: z is a counter, h a table of 101 entries, the price a few multiply-adds. The yield estimates decay and the day prices are fitted once a minute (tick()). No allocation.