FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::Instrument Struct Reference

#include <fastmm/core/instrument.hpp>

Public Types

enum  Flags : std::uint8_t { kEnabled = 1U << 0 , kInverse = 1U << 1 , kReduceOnlySupported = 1U << 2 , kCoinQuoted = 1U << 3 }
 

Public Member Functions

constexpr bool enabled () const noexcept
 
constexpr bool inverse () const noexcept
 
constexpr bool coin_quoted () const noexcept
 
constexpr Price round_price (Price p, Side side) const noexcept
 Passive rounding: bids down, asks up.
 
constexpr Qty round_qty (Qty q) const noexcept
 
constexpr Price ticks (std::int64_t n) const noexcept
 n ticks as a price distance (tick * n).
 
constexpr bool valid_price (Price p) const noexcept
 
constexpr bool valid_qty (Qty q) const noexcept
 
constexpr Notional notional (Price p, Qty q) const noexcept
 Notional in the settlement currency: price * qty * multiplier for a linear contract, and qty * multiplier / price (base coin) for an inverse one, whose contract size is quoted in the quote currency.
 
constexpr Notional pnl_per_tick () const noexcept
 PnL change (settlement ccy) for one tick move on one contract.
 
constexpr Notional inverse_pnl (Price from, Price to, Qty qty) const noexcept
 PnL in the base coin of moving qty contracts from from to to: qty * multiplier * (1/from - 1/to).
 
constexpr std::string_view settlement_ccy () const noexcept
 The currency PnL, fees and notional are denominated in: the base coin for an inverse contract, the quote currency otherwise.
 
constexpr bool is_derivative () const noexcept
 

Public Attributes

InstrumentId id {}
 4
 
VenueId venue {}
 1
 
AssetClass asset_class {}
 1
 
std::uint8_t flags = 0
 1
 
std::uint8_t price_decimals = 8
 1 venue formatting hint
 
Price tick {}
 8
 
Qty lot {}
 8
 
Qty min_qty {}
 8
 
Qty max_qty {}
 8
 
Notional min_notional {}
 8
 
Qty contract_multiplier = Qty::from_int(1)
 8 units of underlying per contract
 
Notional max_notional {}
 8 -> 64
 
std::int64_t expiry_ns = 0
 8 (0 = perpetual / spot)
 
Price strike {}
 8 -> 16
 
Symbol symbol {}
 21
 
FixedString< 8 > base {}
 9
 
FixedString< 8 > quote {}
 9 -> 55
 
OptionType option_type = OptionType::None
 1 -> 56
 
std::uint8_t cold_pad_ [8] = {}
 -> 64
 

Member Enumeration Documentation

◆ Flags

enum fastmm::Instrument::Flags : std::uint8_t
Enumerator
kEnabled 
kInverse 

Priced in one currency and settled in another (Deribit's BTC perpetual: USD against BTC): notional is qty * multiplier / price and PnL moves with 1 / price, in the base coin.

kReduceOnlySupported 
kCoinQuoted 

An option whose premium is in its underlying coin (Deribit's BTC options, 0.0065 BTC): its model value is the USD price divided by the forward.

Valued linearly in that premium; not kInverse.

Member Function Documentation

◆ enabled()

constexpr bool fastmm::Instrument::enabled ( ) const
inlineconstexprnoexcept

◆ inverse()

constexpr bool fastmm::Instrument::inverse ( ) const
inlineconstexprnoexcept

◆ coin_quoted()

constexpr bool fastmm::Instrument::coin_quoted ( ) const
inlineconstexprnoexcept

◆ round_price()

constexpr Price fastmm::Instrument::round_price ( Price  p,
Side  side 
) const
inlineconstexprnoexcept

Passive rounding: bids down, asks up.

◆ round_qty()

constexpr Qty fastmm::Instrument::round_qty ( Qty  q) const
inlineconstexprnoexcept

◆ ticks()

constexpr Price fastmm::Instrument::ticks ( std::int64_t  n) const
inlineconstexprnoexcept

n ticks as a price distance (tick * n).

◆ valid_price()

constexpr bool fastmm::Instrument::valid_price ( Price  p) const
inlineconstexprnoexcept

◆ valid_qty()

constexpr bool fastmm::Instrument::valid_qty ( Qty  q) const
inlineconstexprnoexcept

◆ notional()

constexpr Notional fastmm::Instrument::notional ( Price  p,
Qty  q 
) const
inlineconstexprnoexcept

Notional in the settlement currency: price * qty * multiplier for a linear contract, and qty * multiplier / price (base coin) for an inverse one, whose contract size is quoted in the quote currency.

Zero for an inverse contract at a non-positive price.

◆ pnl_per_tick()

constexpr Notional fastmm::Instrument::pnl_per_tick ( ) const
inlineconstexprnoexcept

PnL change (settlement ccy) for one tick move on one contract.

An inverse contract's tick value depends on the price (multiplier * tick / price^2), so this is zero for one: use inverse_pnl() instead.

◆ inverse_pnl()

constexpr Notional fastmm::Instrument::inverse_pnl ( Price  from,
Price  to,
Qty  qty 
) const
inlineconstexprnoexcept

PnL in the base coin of moving qty contracts from from to to: qty * multiplier * (1/from - 1/to).

Zero unless both prices are positive.

◆ settlement_ccy()

constexpr std::string_view fastmm::Instrument::settlement_ccy ( ) const
inlineconstexprnoexcept

The currency PnL, fees and notional are denominated in: the base coin for an inverse contract, the quote currency otherwise.

Empty when the instrument does not name it.

◆ is_derivative()

constexpr bool fastmm::Instrument::is_derivative ( ) const
inlineconstexprnoexcept

Member Data Documentation

◆ id

InstrumentId fastmm::Instrument::id {}

4

◆ venue

VenueId fastmm::Instrument::venue {}

1

◆ asset_class

AssetClass fastmm::Instrument::asset_class {}

1

◆ flags

std::uint8_t fastmm::Instrument::flags = 0

1

◆ price_decimals

std::uint8_t fastmm::Instrument::price_decimals = 8

1 venue formatting hint

◆ tick

Price fastmm::Instrument::tick {}

8

◆ lot

Qty fastmm::Instrument::lot {}

8

◆ min_qty

Qty fastmm::Instrument::min_qty {}

8

◆ max_qty

Qty fastmm::Instrument::max_qty {}

8

◆ min_notional

Notional fastmm::Instrument::min_notional {}

8

◆ contract_multiplier

Qty fastmm::Instrument::contract_multiplier = Qty::from_int(1)

8 units of underlying per contract

◆ max_notional

Notional fastmm::Instrument::max_notional {}

8 -> 64

◆ expiry_ns

std::int64_t fastmm::Instrument::expiry_ns = 0

8 (0 = perpetual / spot)

◆ strike

Price fastmm::Instrument::strike {}

8 -> 16

◆ symbol

Symbol fastmm::Instrument::symbol {}

21

◆ base

FixedString<8> fastmm::Instrument::base {}

9

◆ quote

FixedString<8> fastmm::Instrument::quote {}

9 -> 55

◆ option_type

OptionType fastmm::Instrument::option_type = OptionType::None

1 -> 56

◆ cold_pad_

std::uint8_t fastmm::Instrument::cold_pad_[8] = {}

-> 64