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

One commission rate, the market and venue it applies to, and the dates it applies on. More...

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

Collaboration diagram for algotradelib::CommissionRate:

Public Member Functions

bool normalized () const noexcept
 Tests whether the rate's market is a normalized Country.
RateApplicability applies_on (const Date &date) const
 Tests whether the rate applies on a date.
bool excluded_on (const Date &date) const
 Tests whether a readable bound puts a date outside the rate's window.

Public Attributes

Country country_ {Country::KR}
 The market the rate applies to; meaningless when other_ is set.
Code< 16 > other_
 The broker's market code, when the library does not normalize that market.
VenueKey venue_
 The venue the rate applies to.
Decimal64 rate_
 The broker's commission, as a fraction of traded value (0.00015, not 0.015).
std::optional< Decimal64 > institution_rate_
 The institution fee (유관기관제비용), as a fraction of traded value, if stated separately.
std::optional< Date > from_
 The first date the rate applies on; empty is open-ended unless from_unreadable_ is set.
std::optional< Date > until_
 The last date the rate applies on; empty is open-ended unless until_unreadable_ is set.
bool from_unreadable_ {false}
 Whether the source stated a start date that could not be read (so from_ is empty).
bool until_unreadable_ {false}
 Whether the source stated an end date that could not be read (so until_ is empty).

Detailed Description

One commission rate, the market and venue it applies to, and the dates it applies on.

Rates are fractions of traded value (0.00015, not 0.015). An absent date bound is open-ended in that direction; a bound that was present but unreadable sets from_unreadable_ or until_unreadable_, and then applies_on answers UNREADABLE rather than treating the row as open-ended. No per-order minimum or transaction tax is modelled here; a backtest states a sale tax with backtest::NextBarFillModel::with_sell_tax.

Definition at line 1449 of file types.hpp.

Member Function Documentation

◆ applies_on()

RateApplicability algotradelib::CommissionRate::applies_on ( const Date & date) const
inline

Tests whether the rate applies on a date.

Parameters
dateThe date.
Returns
NO if a readable bound excludes the date (even when the other bound is unreadable), UNREADABLE if not excluded but a bound could not be read, and YES otherwise.

Definition at line 1510 of file types.hpp.

◆ excluded_on()

bool algotradelib::CommissionRate::excluded_on ( const Date & date) const
inline

Tests whether a readable bound puts a date outside the rate's window.

Parameters
dateThe date.
Returns
true if date is before from_ or after until_.

Definition at line 1525 of file types.hpp.

Referenced by applies_on().

◆ normalized()

bool algotradelib::CommissionRate::normalized ( ) const
inlinenoexcept

Tests whether the rate's market is a normalized Country.

Returns
true if other_ is empty, so country_ names the market.

Definition at line 1501 of file types.hpp.

Member Data Documentation

◆ country_

Country algotradelib::CommissionRate::country_ {Country::KR}

The market the rate applies to; meaningless when other_ is set.

Definition at line 1451 of file types.hpp.

◆ from_

std::optional<Date> algotradelib::CommissionRate::from_

The first date the rate applies on; empty is open-ended unless from_unreadable_ is set.

Definition at line 1479 of file types.hpp.

Referenced by excluded_on().

◆ from_unreadable_

bool algotradelib::CommissionRate::from_unreadable_ {false}

Whether the source stated a start date that could not be read (so from_ is empty).

The row is kept, but applies_on answers UNREADABLE for any date the readable bounds do not exclude.

Definition at line 1488 of file types.hpp.

Referenced by applies_on().

◆ institution_rate_

std::optional<Decimal64> algotradelib::CommissionRate::institution_rate_

The institution fee (유관기관제비용), as a fraction of traded value, if stated separately.

Empty means the source gave one combined rate and said nothing about its parts (every Toss row); a report then treats rate_ as inclusive. A present zero is a stated zero; a positive value is charged in addition to rate_.

Definition at line 1475 of file types.hpp.

◆ other_

Code<16> algotradelib::CommissionRate::other_

The broker's market code, when the library does not normalize that market.

Empty for a normalized market. A broker row whose market code cannot be stored here is skipped and counted in CommissionSchedule::dropped_.

Definition at line 1458 of file types.hpp.

Referenced by normalized().

◆ rate_

Decimal64 algotradelib::CommissionRate::rate_

The broker's commission, as a fraction of traded value (0.00015, not 0.015).

Definition at line 1467 of file types.hpp.

◆ until_

std::optional<Date> algotradelib::CommissionRate::until_

The last date the rate applies on; empty is open-ended unless until_unreadable_ is set.

Definition at line 1481 of file types.hpp.

Referenced by excluded_on().

◆ until_unreadable_

bool algotradelib::CommissionRate::until_unreadable_ {false}

Whether the source stated an end date that could not be read (so until_ is empty).

The row is kept, but applies_on answers UNREADABLE for any date the readable bounds do not exclude.

Definition at line 1495 of file types.hpp.

Referenced by applies_on().

◆ venue_

VenueKey algotradelib::CommissionRate::venue_

The venue the rate applies to.

VenueKey::any() on every rate a broker publishes; no broker publishes per-venue rates, so a caller states KRX and NXT rates from the fee page.

Definition at line 1465 of file types.hpp.


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