![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
Slippage: how far a fill price moves against the order (a buy pays more, a sell gets less). More...
#include <algotradelib/src/backtest/cost.hpp>
Public Member Functions | |
| std::optional< std::pair< Decimal64, Decimal64 > > | apply (const Decimal64 &price, OrderSide side, const PriceRule &rule) const |
| Moves a price against the order. | |
Static Public Member Functions | |
| static SlippageModel | none () |
| Returns a model with no slippage (the report says so). | |
| static SlippageModel | of_basis_points (Decimal64 points) |
| Returns a basis-point slippage model. | |
| static SlippageModel | of_ticks (int count) |
| Returns a tick slippage model. | |
Public Attributes | |
| Decimal64 | basis_points_ {Decimal64::parse("0")} |
| The price given up per execution, in ten-thousandths of the price. | |
| int | ticks_ {0} |
| Grid steps given up per execution, each a step to the next grid price against the order. | |
Slippage: how far a fill price moves against the order (a buy pays more, a sell gets less).
basis_points_ is a fraction of the price in ten-thousandths; ticks_ walks that many steps along the instrument's grid, one at a time, so a walk that crosses into another band takes that band's tick from there on. Both apply when both are set: the ticks are walked from the price before slippage, and the two amounts added.
|
inline |
Moves a price against the order.
| price | The price before slippage. |
| side | The order's side. |
| rule | The instrument's grid. A buy steps up by the tick at each price; a sell steps down by the tick of the band below each price. From a price on the KRX grid each step reaches the next grid price; from a price off the grid, or with a custom table whose band starts are not multiples of both ticks, it may not (as with PriceRule::round_to_tick). A step the grid has no tick for (an unknown grid, a sell at the first band's start) or that would end at or below zero is not taken. |
|
inlinestatic |
Returns a model with no slippage (the report says so).
Definition at line 522 of file cost.hpp.
Referenced by algotradelib::backtest::NextBarFillModel::NextBarFillModel(), and algotradelib::backtest::NextBarFillModel::NextBarFillModel().
|
inlinestatic |
|
inlinestatic |
| Decimal64 algotradelib::backtest::SlippageModel::basis_points_ {Decimal64::parse("0")} |
The price given up per execution, in ten-thousandths of the price.
Definition at line 427 of file cost.hpp.
Referenced by apply(), and of_basis_points().
| int algotradelib::backtest::SlippageModel::ticks_ {0} |
Grid steps given up per execution, each a step to the next grid price against the order.
Definition at line 429 of file cost.hpp.
Referenced by apply(), and of_ticks().