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

How a backtest charges commission: one stated model, or a schedule resolved per execution. More...

#include <algotradelib/src/backtest/cost.hpp>

Public Member Functions

 CommissionPolicy ()=default
 Constructs a policy that charges nothing (the report says so).
bool is_scheduled () const noexcept
 Tests whether the policy resolves a schedule.
const VenueKey & asserted_venue () const noexcept
 Returns the asserted venue.
std::string_view tariff () const noexcept
 Returns the schedule's tariff name.
Result< CommissionCharge > charge (const Decimal64 &quantity, const Decimal64 &price, const Date &date, Country country) const
 Computes the commission on one execution.

Static Public Member Functions

static CommissionPolicy stated (CommissionModel model)
 Makes a policy that charges one model on every execution.
static Result< CommissionPolicy > scheduled (CommissionSchedule schedule, VenueKey asserted, Country dating_market)
 Makes a policy that picks a rate from a schedule for each execution.

Detailed Description

How a backtest charges commission: one stated model, or a schedule resolved per execution.

stated charges one CommissionModel throughout. scheduled picks the rate for each execution by its market, its local trading date and the venue the caller asserts (a replay cannot know where an order executed, so the report lists the venue as an assumption). A rate that cannot be resolved is an error, and the replay halts rather than skipping or zero-costing the fill.

Definition at line 184 of file cost.hpp.

Constructor & Destructor Documentation

◆ CommissionPolicy()

algotradelib::backtest::CommissionPolicy::CommissionPolicy ( )
default

Constructs a policy that charges nothing (the report says so).

Referenced by scheduled(), and stated().

Member Function Documentation

◆ asserted_venue()

const VenueKey & algotradelib::backtest::CommissionPolicy::asserted_venue ( ) const
inlinenoexcept

Returns the asserted venue.

Returns
The venue a scheduled policy charges at; VenueKey::any() for a stated one.

Definition at line 247 of file cost.hpp.

◆ charge()

Result< CommissionCharge > algotradelib::backtest::CommissionPolicy::charge ( const Decimal64 & quantity,
const Decimal64 & price,
const Date & date,
Country country ) const
inline

Computes the commission on one execution.

A scheduled policy charges no minimum (a schedule states none).

Parameters
quantityThe quantity.
priceThe price.
dateThe market-local trading date of the execution (see SessionWindow::local_date).
countryThe instrument's market.
Returns
The charge, or an INVALID_ARGUMENT error: commission_not_representable, commission_date_not_market_local (a dated rate for a market other than dating_market), rate_bounds_unreadable or no_rate_for_date.

Definition at line 270 of file cost.hpp.

◆ is_scheduled()

bool algotradelib::backtest::CommissionPolicy::is_scheduled ( ) const
inlinenoexcept

Tests whether the policy resolves a schedule.

Returns
true for a scheduled policy.

Definition at line 241 of file cost.hpp.

◆ scheduled()

Result< CommissionPolicy > algotradelib::backtest::CommissionPolicy::scheduled ( CommissionSchedule schedule,
VenueKey asserted,
Country dating_market )
inlinestatic

Makes a policy that picks a rate from a schedule for each execution.

Parameters
scheduleThe rates. A caller-stated schedule must name its tariff_.
assertedThe venue fills are assumed to happen at; not Venue::COMBINED, which is routing rather than a venue.
dating_marketThe market whose local trading day the replay's dates are; a dated rate for another market is refused when charged.
Returns
The policy, or an INVALID_ARGUMENT error: commission_tariff_unnamed or commission_venue_not_an_execution.

Definition at line 211 of file cost.hpp.

◆ stated()

CommissionPolicy algotradelib::backtest::CommissionPolicy::stated ( CommissionModel model)
inlinestatic

Makes a policy that charges one model on every execution.

Parameters
modelThe model; its from_broker_ is kept.
Returns
The policy.

Definition at line 194 of file cost.hpp.

◆ tariff()

std::string_view algotradelib::backtest::CommissionPolicy::tariff ( ) const
inlinenoexcept

Returns the schedule's tariff name.

Returns
The name; empty for a stated policy.

Definition at line 253 of file cost.hpp.


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