![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
One run's cash and its own shares, for strategy::RiskLimits::run_budget_. More...
#include <algotradelib/src/runner/run_ledger.hpp>
Public Member Functions | |
| RunLedger (Money opening) | |
| Opens a new run. | |
| const std::string & | id () const noexcept |
| Returns the run's id. | |
| const Money & | cash () const noexcept |
| Returns the run's cash. | |
| const Currency & | currency () const noexcept |
| Returns the run's currency. | |
| Decimal64 | holding (const InstrumentId &instrument) const |
| Returns the run's own shares of an instrument. | |
| bool | book (const InstrumentId &instrument, OrderSide side, const Decimal64 &filled, const Money &amount, const Decimal64 &fee) |
| Books one fill. | |
Friends | |
| template<typename, typename, typename, typename> | |
| class | Runner |
One run's cash and its own shares, for strategy::RiskLimits::run_budget_.
A new run opens with the budget as its cash and no shares. Each fill moves both: a buy spends its amount and its fee and adds its quantity, a sell returns its amount less its fee and takes its quantity away. The cash may go below zero only by a fee booked above what was reserved; the shares never do.
runner::Runner keeps one when a budget is set; read it through Runner::run_cash and Runner::run_holding.
Definition at line 128 of file run_ledger.hpp.
|
inlineexplicit |
Opens a new run.
| opening | The run's starting cash, which names its currency. |
Definition at line 134 of file run_ledger.hpp.
|
inline |
Books one fill.
| instrument | The instrument. |
| side | The fill's side. |
| filled | The quantity filled. |
| amount | What the fill traded for, quantity times price. |
| fee | Its commission and taxes together. |
Definition at line 181 of file run_ledger.hpp.
|
inlinenoexcept |
Returns the run's cash.
Definition at line 148 of file run_ledger.hpp.
|
inlinenoexcept |
Returns the run's currency.
Definition at line 156 of file run_ledger.hpp.
|
inline |
Returns the run's own shares of an instrument.
| instrument | The instrument. |
Definition at line 165 of file run_ledger.hpp.
|
inlinenoexcept |
Returns the run's id.
Definition at line 140 of file run_ledger.hpp.
|
friend |
Definition at line 201 of file run_ledger.hpp.