algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
cost.hpp File Reference

Trading costs for a backtest: commission (CommissionModel, CommissionPolicy), slippage (SlippageModel) and how a limit order's fill price is chosen (LimitFillPrice). More...

#include <algotradelib/core>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
Include dependency graph for cost.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  algotradelib::backtest::CommissionModel
 A flat commission: a rate on traded value, with an optional per-execution minimum. More...
struct  algotradelib::backtest::AppliedRate
 The commission rate that charged an execution, as the backtest report lists it. More...
struct  algotradelib::backtest::CommissionCharge
 What one execution was charged: the broker's commission and the institution fee. More...
class  algotradelib::backtest::CommissionPolicy
 How a backtest charges commission: one stated model, or a schedule resolved per execution. More...
struct  algotradelib::backtest::SlippageModel
 Slippage: how far a fill price moves against the order (a buy pays more, a sell gets less). More...

Namespaces

namespace  algotradelib
 The library: broker-neutral types (core), and the modules below.
namespace  algotradelib::backtest
 Replays a strategy over stored bars: fill and cost models, the replay ledger, and the report.

Enumerations

enum class  algotradelib::backtest::LimitFillPrice { algotradelib::backtest::AT_LIMIT , algotradelib::backtest::AT_OPEN_IF_BETTER }
 Which price a backtest credits a limit order that fills. More...

Functions

Result< CommissionModel > algotradelib::backtest::commission_model_from (const CommissionSchedule &schedule, Country country, const Date &date)
 Builds a flat commission model from a schedule's rate for a market on a date.
constexpr std::string_view algotradelib::backtest::limit_fill_price_name (LimitFillPrice choice) noexcept
 Returns a lowercase name for a choice, such as "at_limit", for reports.

Detailed Description

Trading costs for a backtest: commission (CommissionModel, CommissionPolicy), slippage (SlippageModel) and how a limit order's fill price is chosen (LimitFillPrice).

Every model charges nothing by default, and the backtest report states what was applied, so a zero-cost run is visible. Sale tax is set on the fill model, NextBarFillModel::with_sell_tax.

Definition in file cost.hpp.