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

Which venue a commission rate applies to: any venue, a normalized Venue, or a raw code. More...

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

Public Member Functions

 VenueKey ()=default
 Constructs the key for any venue.
VenueKeyKind kind () const noexcept
 Returns the key's kind.
bool is_any () const noexcept
 Tests whether the key is for any venue.
Venue venue () const noexcept
 Returns the normalized venue.
const Code< 8 > & raw_code () const noexcept
 Returns the raw venue code.
bool matches (const VenueKey &asserted) const noexcept
 Tests whether two keys name the same venue, exactly in kind and value.

Static Public Member Functions

static VenueKey any () noexcept
 Returns the key for any venue.
static std::optional< VenueKey > normalized (Venue venue)
 Makes a key for a normalized venue.
static std::optional< VenueKey > raw (std::string_view code)
 Makes a key for a venue code the library does not normalize.

Friends

bool operator== (const VenueKey &lhs, const VenueKey &rhs) noexcept
 Compares kind and value; same as matches.
bool operator!= (const VenueKey &lhs, const VenueKey &rhs) noexcept
 Compares two keys for inequality.

Detailed Description

Which venue a commission rate applies to: any venue, a normalized Venue, or a raw code.

The three kinds never match each other: a RAW key never equals a NORMALIZED one even if the text looks the same. A backtest refuses Venue::COMBINED as the venue a fill happened at, since it names consolidated routing (KIS SOR), not where an order matched.

Definition at line 1244 of file types.hpp.

Constructor & Destructor Documentation

◆ VenueKey()

algotradelib::VenueKey::VenueKey ( )
default

Constructs the key for any venue.

Referenced by any(), matches(), normalized(), operator!=, operator==, and raw().

Member Function Documentation

◆ any()

VenueKey algotradelib::VenueKey::any ( )
inlinestaticnoexcept

Returns the key for any venue.

Returns
A key of kind ANY.

Definition at line 1253 of file types.hpp.

Referenced by algotradelib::CommissionSchedule::rate_for().

◆ is_any()

bool algotradelib::VenueKey::is_any ( ) const
inlinenoexcept

Tests whether the key is for any venue.

Returns
true for kind ANY.

Definition at line 1296 of file types.hpp.

◆ kind()

VenueKeyKind algotradelib::VenueKey::kind ( ) const
inlinenoexcept

Returns the key's kind.

Returns
ANY, NORMALIZED or RAW.

Definition at line 1290 of file types.hpp.

Referenced by algotradelib::backtest::CommissionPolicy::scheduled().

◆ matches()

bool algotradelib::VenueKey::matches ( const VenueKey & asserted) const
inlinenoexcept

Tests whether two keys name the same venue, exactly in kind and value.

No fallback: an ANY key matches only ANY. Falling back to a neutral rate is done by CommissionSchedule::rate_for.

Parameters
assertedThe key to compare with.
Returns
true if the kinds and values are equal.

Definition at line 1319 of file types.hpp.

◆ normalized()

std::optional< VenueKey > algotradelib::VenueKey::normalized ( Venue venue)
inlinestatic

Makes a key for a normalized venue.

Parameters
venueThe venue; UNSPECIFIED is not a venue (use any()).
Returns
The key, or std::nullopt for Venue::UNSPECIFIED.

Definition at line 1260 of file types.hpp.

◆ raw()

std::optional< VenueKey > algotradelib::VenueKey::raw ( std::string_view code)
inlinestatic

Makes a key for a venue code the library does not normalize.

Parameters
codeThe broker's code: 1 to 8 characters, each A-Z, 0-9 or _.
Returns
The key, or std::nullopt if code is empty or cannot be stored.

Definition at line 1275 of file types.hpp.

◆ raw_code()

const Code< 8 > & algotradelib::VenueKey::raw_code ( ) const
inlinenoexcept

Returns the raw venue code.

Returns
The code for kind RAW; empty otherwise.

Definition at line 1308 of file types.hpp.

◆ venue()

Venue algotradelib::VenueKey::venue ( ) const
inlinenoexcept

Returns the normalized venue.

Returns
The venue for kind NORMALIZED; UNSPECIFIED otherwise.

Definition at line 1302 of file types.hpp.

Referenced by normalized(), and algotradelib::backtest::CommissionPolicy::scheduled().

◆ operator!=

bool operator!= ( const VenueKey & lhs,
const VenueKey & rhs )
friend

Compares two keys for inequality.

Parameters
lhsThe first key.
rhsThe second key.
Returns
true if they do not match.

Definition at line 1348 of file types.hpp.

◆ operator==

bool operator== ( const VenueKey & lhs,
const VenueKey & rhs )
friend

Compares kind and value; same as matches.

Parameters
lhsThe first key.
rhsThe second key.
Returns
true if they match.

Definition at line 1340 of file types.hpp.


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