![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
How much an OrderIntent trades: a quantity, a notional amount, or a target weight. More...
#include <algotradelib/src/strategy/intent.hpp>
Public Member Functions | |
| SizeSpec ()=default | |
| Constructs a quantity of zero (reconciling it reports QUANTITY_ROUNDS_TO_ZERO). | |
| SizeKind | kind () const noexcept |
| Returns how the size is expressed. | |
| const Decimal64 & | as_quantity () const |
| Returns the quantity. | |
| const Money & | as_notional () const |
| Returns the notional amount. | |
| const Decimal64 & | as_target_weight () const |
| Returns the target weight. | |
Static Public Member Functions | |
| static SizeSpec | quantity (Decimal64 amount) |
| Makes a size in shares or contracts. | |
| static SizeSpec | notional (Money amount) |
| Makes a size as an amount of money. | |
| static SizeSpec | target_weight (Decimal64 fraction) |
| Makes a size as a fraction of portfolio value to hold. | |
How much an OrderIntent trades: a quantity, a notional amount, or a target weight.
The runner converts a notional or a weight into a quantity, using a price and the portfolio. Read the value with the accessor that matches kind(); the others throw.
Definition at line 137 of file intent.hpp.
|
default |
Constructs a quantity of zero (reconciling it reports QUANTITY_ROUNDS_TO_ZERO).
Referenced by notional(), quantity(), and target_weight().
|
inline |
Returns the notional amount.
| std::logic_error | unless kind() is NOTIONAL. |
Definition at line 215 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile().
|
inline |
Returns the quantity.
| std::logic_error | unless kind() is QUANTITY. |
Definition at line 205 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile().
|
inline |
Returns the target weight.
| std::logic_error | unless kind() is TARGET_WEIGHT. |
Definition at line 225 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns how the size is expressed.
Definition at line 198 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile().
Makes a size as an amount of money.
| amount | The amount; the runner divides it by a price to get a quantity. |
Definition at line 159 of file intent.hpp.
Makes a size in shares or contracts.
| amount | The quantity. |
Definition at line 147 of file intent.hpp.
Makes a size as a fraction of portfolio value to hold.
A weight states a holding, not a trade: the runner compares it with what is held and working and trades only the difference, so restating the same weight places nothing. Like a target position, it may withdraw working orders on the instrument (see strategy::weight_target). The target is rounded down to whole lots, so a weight worth less than one share sells the holding to zero; set a TradeTolerance to avoid trading one share each time the price ticks.
Only a buy intent with DAY validity, no trigger and no idempotency key can carry a weight; anything else is refused with RejectReason::UNSUPPORTED_WEIGHT. A weight needs the portfolio value: a backtest supplies it, but a live runner refuses the intent (no_portfolio_value) unless you call Runner::set_portfolio_value.
It is still an order intent, not a TargetPosition: one withheld for the account is dropped, not retained for later; one refused for the market phase is kept, as any intent is.
| fraction | The fraction of portfolio value, as an exact decimal (for example 0.25); for a computed weight, convert with analytics::to_decimal. |
Definition at line 187 of file intent.hpp.
Referenced by algotradelib::strategy::vanilla::EqualWeightRebalance::on_phase().