algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::DepthSnapshot Struct Reference

An instrument's order book: resting bids and offers. More...

#include <algotradelib/src/core/market_data.hpp>

Collaboration diagram for algotradelib::DepthSnapshot:

Public Member Functions

std::optional< DepthLevel > best_bid () const
 Returns the best bid.
std::optional< DepthLevel > best_ask () const
 Returns the best offer.
std::optional< Decimal64 > spread () const
 Returns the spread, best offer minus best bid, exactly.
std::optional< Decimal64 > mid () const
 Returns the midpoint of the best bid and offer, exactly (one more decimal place if needed).

Public Attributes

InstrumentId instrument_
 The instrument.
std::vector< DepthLevel > bids_
 The bids, descending by price.
std::vector< DepthLevel > asks_
 The offers, ascending by price.
Currency currency_
 The currency of the prices.
std::optional< std::chrono::system_clock::time_point > exchange_time_
 When the exchange says the book was true, if the broker gave a time.
std::chrono::system_clock::time_point received_at_
 When the book was received, on this machine's clock.

Detailed Description

An instrument's order book: resting bids and offers.

Index zero is the best level on each side (bids descending, asks ascending); adapters sort the levels themselves. A side may be empty.

Definition at line 206 of file market_data.hpp.

Member Function Documentation

◆ best_ask()

std::optional< DepthLevel > algotradelib::DepthSnapshot::best_ask ( ) const
inline

Returns the best offer.

Returns
The lowest offer level, or std::nullopt if no offer rests.

Definition at line 232 of file market_data.hpp.

Referenced by mid(), and spread().

◆ best_bid()

std::optional< DepthLevel > algotradelib::DepthSnapshot::best_bid ( ) const
inline

Returns the best bid.

Returns
The highest bid level, or std::nullopt if no bid rests.

Definition at line 224 of file market_data.hpp.

Referenced by mid(), and spread().

◆ mid()

std::optional< Decimal64 > algotradelib::DepthSnapshot::mid ( ) const
inline

Returns the midpoint of the best bid and offer, exactly (one more decimal place if needed).

Not rounded to the tick grid; round it yourself before using it as an order price.

Returns
The midpoint, or std::nullopt if a side is empty or the arithmetic does not fit.

Definition at line 256 of file market_data.hpp.

◆ spread()

std::optional< Decimal64 > algotradelib::DepthSnapshot::spread ( ) const
inline

Returns the spread, best offer minus best bid, exactly.

Returns
The spread, or std::nullopt if a side is empty or the arithmetic does not fit.

Definition at line 240 of file market_data.hpp.

Member Data Documentation

◆ asks_

std::vector<DepthLevel> algotradelib::DepthSnapshot::asks_

The offers, ascending by price.

Definition at line 212 of file market_data.hpp.

Referenced by best_ask(), and algotradelib::order_depth().

◆ bids_

std::vector<DepthLevel> algotradelib::DepthSnapshot::bids_

The bids, descending by price.

Definition at line 210 of file market_data.hpp.

Referenced by best_bid(), and algotradelib::order_depth().

◆ currency_

Currency algotradelib::DepthSnapshot::currency_

The currency of the prices.

Definition at line 214 of file market_data.hpp.

◆ exchange_time_

std::optional<std::chrono::system_clock::time_point> algotradelib::DepthSnapshot::exchange_time_

When the exchange says the book was true, if the broker gave a time.

Definition at line 216 of file market_data.hpp.

◆ instrument_

InstrumentId algotradelib::DepthSnapshot::instrument_

The instrument.

Definition at line 208 of file market_data.hpp.

◆ received_at_

std::chrono::system_clock::time_point algotradelib::DepthSnapshot::received_at_

When the book was received, on this machine's clock.

Definition at line 218 of file market_data.hpp.


The documentation for this struct was generated from the following file: