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

The fees a run budget estimates for an order (RiskLimits::run_fees_). More...

#include <algotradelib/src/strategy/risk.hpp>

Collaboration diagram for algotradelib::strategy::RunFees:

Public Member Functions

std::optional< Decimal64 > estimate_commission (const Decimal64 &value) const
 Estimates the commission on one order.
std::optional< Decimal64 > estimate_tax (const Decimal64 &value, OrderSide side) const
 Estimates the tax on one order.

Public Attributes

Decimal64 commission_rate_ {Decimal64::parse("0")}
 The fraction of traded value charged on buys and sells (0.00015, not 0.015).
Decimal64 commission_minimum_ {Decimal64::parse("0")}
 The least commission on one order.
std::optional< Decimal64 > institution_rate_
 A fraction of traded value charged on top of the commission (an institution fee), if any.
std::optional< Decimal64 > sell_tax_rate_
 The fraction of a sell's value charged as tax, if any.

Detailed Description

The fees a run budget estimates for an order (RiskLimits::run_fees_).

The same shapes as the backtest's CommissionModel, institution rate and SellTax, stated here because a budget needs them before any fill. They apply per order: the minimum and the rounding apply once to the order's traded value, however many fills make it up. Each charge rounds up to a whole currency unit (an exact zero stays zero), so it is never below a charge truncated to whole units; for a currency with cents the commission and the institution fee, each rounded up, can over-reserve up to two units an order. Per-share fees have no shape here. Default-constructed, it states no fees at all.

Definition at line 320 of file risk.hpp.

Member Function Documentation

◆ estimate_commission()

std::optional< Decimal64 > algotradelib::strategy::RunFees::estimate_commission ( const Decimal64 & value) const
inline

Estimates the commission on one order.

Parameters
valueThe order's traded value.
Returns
max(ceil(value x commission_rate_), commission_minimum_) + ceil(value x institution_rate_), each ceil to a whole unit and the minimum as stated; std::nullopt if the value, a rate or the minimum is negative, or the arithmetic does not fit.

Definition at line 337 of file risk.hpp.

◆ estimate_tax()

std::optional< Decimal64 > algotradelib::strategy::RunFees::estimate_tax ( const Decimal64 & value,
OrderSide side ) const
inline

Estimates the tax on one order.

Parameters
valueThe order's traded value.
sideThe order's side.
Returns
ceil(value x sell_tax_rate_) on a sell, in whole units, and zero on a buy or without a rate; std::nullopt if the value or the rate is negative, or the arithmetic does not fit.

Definition at line 369 of file risk.hpp.

Member Data Documentation

◆ commission_minimum_

Decimal64 algotradelib::strategy::RunFees::commission_minimum_ {Decimal64::parse("0")}

The least commission on one order.

Definition at line 324 of file risk.hpp.

Referenced by estimate_commission().

◆ commission_rate_

Decimal64 algotradelib::strategy::RunFees::commission_rate_ {Decimal64::parse("0")}

The fraction of traded value charged on buys and sells (0.00015, not 0.015).

Definition at line 322 of file risk.hpp.

Referenced by estimate_commission().

◆ institution_rate_

std::optional<Decimal64> algotradelib::strategy::RunFees::institution_rate_

A fraction of traded value charged on top of the commission (an institution fee), if any.

Definition at line 326 of file risk.hpp.

Referenced by estimate_commission().

◆ sell_tax_rate_

std::optional<Decimal64> algotradelib::strategy::RunFees::sell_tax_rate_

The fraction of a sell's value charged as tax, if any.

Definition at line 328 of file risk.hpp.

Referenced by estimate_tax().


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