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

A flat commission: a rate on traded value, with an optional per-execution minimum. More...

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

Collaboration diagram for algotradelib::backtest::CommissionModel:

Public Member Functions

std::optional< Decimal64 > on (const Decimal64 &quantity, const Decimal64 &price) const
 Computes the commission on one execution.

Static Public Member Functions

static CommissionModel none ()
 Returns a model that charges nothing (the report says so).
static CommissionModel of (Decimal64 rate, Decimal64 minimum=Decimal64::parse("0"))
 Returns a rate-based model.

Public Attributes

Decimal64 rate_ {Decimal64::parse("0")}
 The fraction of traded value charged per execution (0.00015, not 0.015).
Decimal64 minimum_ {Decimal64::parse("0")}
 The smallest commission on any execution.
bool from_broker_ {false}
 Whether the rate came from a broker's published schedule; commission_model_from sets it from the schedule's origin_.

Detailed Description

A flat commission: a rate on traded value, with an optional per-execution minimum.

Charged on buys and sells alike; it carries no tax (see NextBarFillModel::with_sell_tax).

Definition at line 28 of file cost.hpp.

Member Function Documentation

◆ none()

CommissionModel algotradelib::backtest::CommissionModel::none ( )
inlinestatic

Returns a model that charges nothing (the report says so).

Returns
The model.

Definition at line 67 of file cost.hpp.

Referenced by algotradelib::backtest::NextBarFillModel::NextBarFillModel().

◆ of()

CommissionModel algotradelib::backtest::CommissionModel::of ( Decimal64 rate,
Decimal64 minimum = Decimal64::parse("0") )
inlinestatic

Returns a rate-based model.

Parameters
rateThe fraction of traded value charged.
minimumThe smallest commission per execution.
Returns
The model.

Definition at line 75 of file cost.hpp.

Referenced by algotradelib::backtest::commission_model_from().

◆ on()

std::optional< Decimal64 > algotradelib::backtest::CommissionModel::on ( const Decimal64 & quantity,
const Decimal64 & price ) const
inline

Computes the commission on one execution.

Parameters
quantityThe quantity.
priceThe price.
Returns
quantity * price * rate_ truncated to whole currency units, or minimum_ if that is larger; std::nullopt if the arithmetic does not fit.

Definition at line 46 of file cost.hpp.

Member Data Documentation

◆ from_broker_

bool algotradelib::backtest::CommissionModel::from_broker_ {false}

Whether the rate came from a broker's published schedule; commission_model_from sets it from the schedule's origin_.

Definition at line 37 of file cost.hpp.

◆ minimum_

Decimal64 algotradelib::backtest::CommissionModel::minimum_ {Decimal64::parse("0")}

The smallest commission on any execution.

Definition at line 32 of file cost.hpp.

Referenced by on().

◆ rate_

Decimal64 algotradelib::backtest::CommissionModel::rate_ {Decimal64::parse("0")}

The fraction of traded value charged per execution (0.00015, not 0.015).

Definition at line 30 of file cost.hpp.

Referenced by on().


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