algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor > Class Template Reference

Runs one strategy: feeds it events, reconciles what it asks for, checks the risk limits, and sends through an executor. More...

#include <algotradelib/src/runner/runner.hpp>

Inheritance diagram for algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >:

Public Types

using Tag = BrokerTag
 The broker tag (DryTag for a dry run).
using Context = runner::Context<BrokerTag, CapsType>
 The context type handed to the strategy's handlers.
using Report = DryRunReport<BrokerTag>
 What one feed returns.

Public Member Functions

 Runner (Strategy strategy={}, strategy::RiskLimits limits={}, std::size_t series_capacity=512, Executor executor={})
 Constructs a runner.
const Executor & executor () const noexcept
 Returns the executor.
Executor & executor () noexcept
 Returns the executor.
const IndeterminacyLedger & ledger () const noexcept
 Returns the ledger of instruments withheld pending reconciliation or an operator: an order of unknown outcome, which a sweep of the broker's lists can resolve, or one that timed out unconfirmed or is held for an operator, which no listing clears (account for it with release_obligations, and clear the ledger entry yourself once the broker's state is read).
IndeterminacyLedger & ledger () noexcept
 Returns the ledger, so an operator who has read the broker's order list can clear an entry.
std::optional< std::string > local_failure () const
 Returns why local machinery stopped sending, if it did.
void resume_after_local_failure ()
 Clears the local-failure hold, after an operator has fixed the cause.
void set_maximum_portfolio_age (std::optional< std::chrono::nanoseconds > age)
 Sets how old the holdings may be before a reconciliation plan computed from them is held back (WithheldPlanReason::PORTFOLIO_STALE).
void set_observed_at (std::chrono::system_clock::time_point at)
 Sets the current wall-clock instant, used to measure the age of holdings and price bands.
std::chrono::system_clock::time_point observed_at () const noexcept
 Returns the instant last set by set_observed_at.
void allow_absent_portfolio ()
 Lets this runner place orders before holdings have ever been read.
void require_known_portfolio (bool required)
 Sets whether placing requires holdings to have been read and fresh.
void halt_locally (std::string detail)
 Stops this runner sending, with the LOCAL_FAILURE hold, until resume_after_local_failure.
std::size_t placements_at_broker () const noexcept
 Returns how many placements may have left an order at the broker (accepted or of unknown outcome).
std::size_t sends_outside_permitted_phase () const noexcept
 Returns how many orders were sent in a market phase RiskLimits::permitted_phases_ does not permit, because they close toward flat.
void probe_sellable_convention (bool enabled=true)
 Turns on the strategy::SellableConventionProbe, which infers whether the broker's sellable figure already excludes resting sells.
void observe_sellable_convention ()
 Shows the current portfolio to the sellable-convention probe, if it is on.
const strategy::SellableConventionProbe< Tag > & sellable_convention () const noexcept
 Returns the sellable-convention probe.
const Strategy & strategy () const noexcept
 Returns the strategy, to read the state it kept.
Strategy & strategy () noexcept
 Returns the strategy.
const Context & context () const noexcept
 Returns the context.
Context & context () noexcept
 Returns the context, to arrange its state (instruments, portfolio) before feeding events.
const strategy::RiskGuard & guard () const noexcept
 Returns the risk guard.
strategy::RiskGuard & guard () noexcept
 Returns the risk guard, to halt or resume trading.
void set_price_limits (const InstrumentId &id, PriceLimits limits)
 Records an instrument's price band for today, used to clamp order prices.
void set_maximum_price_limits_age (std::optional< std::chrono::nanoseconds > age)
 Sets how old a price band may be and still be applied to an order's price.
void allow_unbounded_price_limits_age ()
 Applies price bands of any age (replacing a stated maximum).
std::size_t price_bands_withheld () const noexcept
 Returns how many plans were built while a band was known for the instrument but not applied (counted per plan, not per order).
bool price_limits_age_policy_stated () const noexcept
 Tests whether a price-band age policy has been stated (a maximum, or any age).
std::size_t unclamped_orders_rejected () const noexcept
 Returns how many sent orders the broker refused while carrying a price a withheld band would have clamped.
std::size_t unclamped_orders_refused () const noexcept
 Returns how many orders carrying a price a withheld band would have clamped were refused before sending (by the risk guard or the binding; not counting UNAVAILABLE).
std::size_t orders_unbuildable () const noexcept
 Returns how many orders reconciliation could not build (any strategy::RejectReason before sending, including a quantity that rounded to zero).
std::size_t orders_reconcile_withheld () const noexcept
 Returns how many orders were held back because the instrument was in the ledger (an order of unknown outcome, timed out unconfirmed, or held for an operator); see orders_unbuildable.
std::size_t orders_guard_refused () const noexcept
 Returns how many orders the risk guard refused, for a limit or a hold; see orders_unbuildable.
std::size_t orders_binding_refused () const noexcept
 Returns how many orders the binding refused to send (no request made); see orders_unbuildable.
std::size_t orders_broker_refused () const noexcept
 Returns how many orders the broker refused (SendOutcome::REJECTED; a request was spent); see last_broker_refusal. At KIS, Toss and Kiwoom most refusals count as unknown outcomes instead.
std::size_t orders_indeterminate () const noexcept
 Returns how many orders had an unknown outcome (SendOutcome::INDETERMINATE, which at KIS, Toss and Kiwoom includes most of the broker's own refusals).
std::size_t plans_withheld () const noexcept
 Returns how many whole reconciliation plans were held back (any WithheldPlanReason: holdings absent, stale or superseded, or a placement hold); the reasons are in each Report::withheld_plans_.
std::vector< strategy::TargetPosition > deferred_targets () const
 Returns the targets waiting for a stop on their instrument to be cancelled (at most one per instrument).
std::size_t targets_deferred () const noexcept
 Returns how many targets have waited for a stop's cancellation; see deferred_targets.
std::size_t deferred_dropped_after_fill () const noexcept
 Returns how many waiting targets were dropped because a stop they waited on had filled.
std::optional< std::chrono::system_clock::time_point > deferred_awaiting_evidence () const
 Returns from when the broker's order history must be read to decide waiting targets.
Report retry_deferred (const std::vector< OrderSnapshot > &evidence)
 Decides each waiting target against the broker's order history, and settles what it released.
std::size_t unconfirmed_orders () const noexcept
 Returns how many sent orders are still counted as reserved until the broker accounts for them.
void refresh_unconfirmed ()
 Rebuilds the reserved working rows against the portfolio as it is now.
void resolve_indeterminate_placement (const InstrumentId &instrument, OrderSide side, const std::optional< std::string > &order_id, const std::string &journal_id={})
 Tells the runner what a reconciliation sweep found for an order of unknown outcome.
bool serialized () const noexcept
 Tests whether this runner is serialized: at most one order per instrument that holdings have not yet accounted for.
void allow_overlapping_orders ()
 Lets several orders on one instrument be outstanding at once, as an unjournaled runner does, with that runner's known limitations.
ObligationState obligation_state (const InstrumentId &instrument) const
 Returns what a serialized runner still owes on an instrument.
std::vector< Obligation > obligations (const InstrumentId &instrument) const
 Lists the orders a serialized runner still owes on an instrument, for an operator.
std::vector< Obligation > obligations () const
 Lists every order a serialized runner still owes, on any instrument.
bool release_obligations (const InstrumentId &instrument, const std::string &reason)
 Accounts for every order a serialized runner still owes on an instrument, on an operator's word.
void restore_obligations (const JournalReplay &replay)
 Restores the orders a previous process left unaccounted for; runner::recover_runner calls it, and a serialized runner places nothing until it has run.
std::size_t orders_awaiting_confirmation () const noexcept
 Returns how many orders a serialized runner withheld because another order on the instrument was not yet accounted for, or the runner could not yet measure one; see serialized. Whole plans withheld for it are in plans_withheld.
std::size_t obligations_unexplained () const noexcept
 Returns how many orders a serialized runner owes that nothing yet explains: no listing shows them resting and holdings do not show them, or only an operator may account for them.
void set_confirmation_timeout (std::chrono::nanoseconds timeout)
 Sets how long a sent order's quantity may stay unexplained before it is counted as timed out (ten minutes by default).
std::size_t orders_unconfirmed_timed_out () const noexcept
 Returns how many sent orders timed out unconfirmed; see set_confirmation_timeout.
std::optional< std::chrono::system_clock::time_point > unconfirmed_awaiting_evidence ()
 Returns from when the broker's order history must be read to settle sent orders.
void confirm_from_history (const std::vector< OrderSnapshot > &evidence)
 Settles reserved orders against the broker's order history; sends nothing.
Report retry_retained_targets ()
 Re-submits retained targets and kept intents once they can be acted on, and settles them.
std::size_t intents_kept_for_phase () const noexcept
 Returns how many order intents are kept for the market phase, an unreachable broker or a rate limit; see retry_retained_targets.
std::size_t kept_intents_dropped () const noexcept
 Returns how many kept intents were dropped at release, because the holding they were decided against had changed or a stop now rests.
std::size_t targets_retained () const noexcept
 Returns how many targets are retained, for any reason; see retry_retained_targets.
std::size_t targets_retained_for_phase () const noexcept
 Returns how many retained targets wait for the market phase, an unreachable broker or a rate limit.
void clear_retained_targets () noexcept
 Discards every retained target and kept intent (PollingLoop does this when stopping).
void clear_deferred_targets () noexcept
 Discards every target waiting on a resting stop (deferred_targets). The orders this runner owes are not touched. PollingLoop does this when stopping: nothing a strategy stated before a stop is to be released after it.
std::size_t obligations_awaiting_account () const noexcept
 Returns how many orders a serialized runner owes that a later read could account for without anything more being sent: not held for an operator, and either no longer listed (filled or gone, awaiting holdings or history) or withdrawn with the withdrawal accepted.
bool withdrawal_accepted_for (const WorkingOrder< Tag > &working) const
 Tests whether working is a row of an order this runner sent whose withdrawal the broker has already accepted. Such an order is not withdrawn again: a second withdrawal is refused.
Report retry_deferred_on_one_snapshot ()
 Releases and settles every waiting target whose stops are no longer listed, without reading history.
std::size_t instructions_unavailable () const noexcept
 Returns how many instructions (placements and cancellations) were not sent because local machinery was unavailable; each leaves the LOCAL_FAILURE hold.
std::size_t cancels_rejected () const noexcept
 Returns how many cancellations were refused, by the broker or the binding (RejectedCancel::by_broker_ tells which).
std::size_t cancels_refused () const noexcept
 Returns how many cancellations a hold refused before sending.
std::size_t cancels_unresolved () const noexcept
 Returns how many cancellations named an order the portfolio does not list.
std::size_t cancels_indeterminate () const noexcept
 Returns how many cancellations had an unknown outcome (the order may or may not have been cancelled).
const std::optional< BrokerRefusal > & last_broker_refusal () const noexcept
 Returns the broker's code and message for the most recent order it refused (SendOutcome::REJECTED; at KIS, Toss and Kiwoom most refusals are INDETERMINATE and not recorded here).
const std::optional< strategy::Rejection > & last_unbuildable () const noexcept
 Returns why reconciliation could not build the most recent instruction it refused.
void set_trade_tolerance (strategy::TradeTolerance tolerance)
 Sets how small a drift from a target is not worth an order; see strategy::TradeTolerance.
void set_minimum_trade (Decimal64 quantity)
 Sets only the share-count floor of the trade tolerance.
void set_portfolio_value (Decimal64 value)
 Sets the portfolio's total value, which a weight-sized intent needs live.
void set_portfolio_value (Money value)
 Sets the portfolio's total value and its currency.
void clear_portfolio_value () noexcept
 Forgets the portfolio value, so weighted intents are refused again.
Report start ()
 Calls on_start and settles what it asked for.
Report stop ()
 Calls on_stop and settles what it asked for.
Report notify_stop ()
 Calls on_stop and settles what it asked for while PollingLoop's STOPPING hold stands, so the strategy's parting orders are refused rather than sent beside the operator's closing orders.
Report settle_closing ()
 Settles instructions already queued on the context, without calling a handler.
Report feed (const strategy::BarEvent &event)
 Feeds one bar: caches it, sets the last price and the clock to the bar's period end, calls on_bar, and settles what the strategy asked for.
void feed_warmup (const strategy::BarEvent &event)
 Feeds one bar as history: like feed, but whatever the strategy asks for is discarded (counted in warmup_instructions_discarded).
void record (const strategy::BarEvent &event)
 Prepares one bar for a slice: caches it (with a linear algebra backend) and sets the last price and the clock to the bar's period end, without calling a handler or settling.
void record_history_only (const strategy::BarEvent &event)
 Caches one bar without moving the last price or the clock, and without calling a handler.
Report feed (const strategy::BarSlice &slice)
 Delivers one period's bars to on_bars and settles what the strategy asked for.
void feed_warmup (const strategy::BarSlice &slice)
 Delivers one period's bars as history: like feed(const strategy::BarSlice&), but whatever the strategy asks for is discarded (counted in warmup_instructions_discarded).
std::size_t warmup_instructions_discarded () const noexcept
 Returns how many instructions feed_warmup discarded.
Report feed (const strategy::QuoteEvent &event)
 Feeds one quote: sets the last price and the clock, calls on_quote, and settles.
Report feed (const strategy::Fill &event)
 Feeds one execution: calls on_fill and settles.
Report feed (const OrderSnapshot &event)
 Feeds one order update: calls on_order_update and settles.
Report feed (strategy::MarketPhase phase)
 Feeds a market phase change: sets it on the context, calls on_phase, and settles.

Static Public Attributes

static constexpr bool on_fill_never_fires
 true when this runner sends to a broker and the strategy defines on_fill, which then never fires (no shipped live source produces fills).
static constexpr bool takes_bar_slices = strategy::strategy_detail::declares_on_bars<Strategy>
 true when the strategy declares on_bars: bars are then fed with record and delivered with feed(const strategy::BarSlice&) (or feed_warmup of one), and the single-bar feed and feed_warmup do not compile.
static constexpr bool keeps_sent_orders_until_listed
 true when this runner keeps each order it sends in Portfolio::working_ until a broker listing accounts for it: a live runner whose broker lists working orders (every shipped binding).
static constexpr bool journals_to_a_broker
 true when this runner journals what it sends to a broker (a JournalingExecutor), which makes it serialized unless allow_overlapping_orders is called; see serialized.

Detailed Description

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
class algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >

Runs one strategy: feeds it events, reconciles what it asks for, checks the risk limits, and sends through an executor.

The same class serves a dry run (the default RecordingExecutor, which sends nothing), a live session (live::SessionExecutor) and a backtest (backtest::QueueingExecutor). Feed events with feed; each call runs the matching handler and returns a DryRunReport of what it decided. A live program usually drives it through runner::PollingLoop.

A dry-run program contains no broker or network code: this header includes none.

Template Parameters
StrategyThe strategy type, held by value (read its state with strategy()).
CapsTypeThe broker capabilities the strategy sees.
BrokerTagThe broker tag of order references.
ExecutorWhere instructions are sent.

Definition at line 297 of file runner.hpp.

Member Typedef Documentation

◆ Context

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
using algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::Context = runner::Context<BrokerTag, CapsType>

The context type handed to the strategy's handlers.

Definition at line 302 of file runner.hpp.

◆ Report

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
using algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::Report = DryRunReport<BrokerTag>

What one feed returns.

Definition at line 304 of file runner.hpp.

◆ Tag

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
using algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::Tag = BrokerTag

The broker tag (DryTag for a dry run).

Definition at line 300 of file runner.hpp.

Constructor & Destructor Documentation

◆ Runner()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::Runner ( Strategy strategy = {},
strategy::RiskLimits limits = {},
std::size_t series_capacity = 512,
Executor executor = {} )
inlineexplicit

Constructs a runner.

Parameters
strategyThe strategy.
limitsThe risk limits.
series_capacityHow many trailing bars each cached series keeps; must be positive with a linear algebra backend, or the first bar fed throws std::invalid_argument.
executorWhere instructions are sent.

Definition at line 351 of file runner.hpp.

Member Function Documentation

◆ allow_absent_portfolio()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::allow_absent_portfolio ( )
inline

Lets this runner place orders before holdings have ever been read.

PollingLoop::allow_absent_portfolio calls it. A plan that would cancel something is still held back until holdings are read.

Definition at line 450 of file runner.hpp.

◆ allow_overlapping_orders()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::allow_overlapping_orders ( )
inline

Lets several orders on one instrument be outstanding at once, as an unjournaled runner does, with that runner's known limitations.

After a restart, orders a previous process sent and holdings had not yet shown are forgotten, and a target can place them again. A buy and a sell on one instrument whose fills have not reached holdings can both be taken as accounted for, and a later order confirmed by another's fill. Choose it only for a strategy that needs overlapping orders (an entry beside its protective stop) and accepts those.

Exceptions
std::logic_erroronce anything was placed, or after runner::recover_runner.

Definition at line 898 of file runner.hpp.

◆ allow_unbounded_price_limits_age()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::allow_unbounded_price_limits_age ( )
inline

Applies price bands of any age (replacing a stated maximum).

Definition at line 604 of file runner.hpp.

◆ cancels_indeterminate()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::cancels_indeterminate ( ) const
inlinenoexcept

Returns how many cancellations had an unknown outcome (the order may or may not have been cancelled).

Returns
The count over the runner's life.

Definition at line 1394 of file runner.hpp.

◆ cancels_refused()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::cancels_refused ( ) const
inlinenoexcept

Returns how many cancellations a hold refused before sending.

Returns
The count over the runner's life.

Definition at line 1384 of file runner.hpp.

◆ cancels_rejected()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::cancels_rejected ( ) const
inlinenoexcept

Returns how many cancellations were refused, by the broker or the binding (RejectedCancel::by_broker_ tells which).

Returns
The count over the runner's life.

Definition at line 1379 of file runner.hpp.

◆ cancels_unresolved()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::cancels_unresolved ( ) const
inlinenoexcept

Returns how many cancellations named an order the portfolio does not list.

Returns
The count over the runner's life.

Definition at line 1389 of file runner.hpp.

◆ clear_deferred_targets()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::clear_deferred_targets ( )
inlinenoexcept

Discards every target waiting on a resting stop (deferred_targets). The orders this runner owes are not touched. PollingLoop does this when stopping: nothing a strategy stated before a stop is to be released after it.

Definition at line 1314 of file runner.hpp.

◆ clear_portfolio_value()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::clear_portfolio_value ( )
inlinenoexcept

Forgets the portfolio value, so weighted intents are refused again.

Definition at line 1466 of file runner.hpp.

◆ clear_retained_targets()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::clear_retained_targets ( )
inlinenoexcept

Discards every retained target and kept intent (PollingLoop does this when stopping).

Definition at line 1304 of file runner.hpp.

◆ confirm_from_history()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::confirm_from_history ( const std::vector< OrderSnapshot > & evidence)
inline

Settles reserved orders against the broker's order history; sends nothing.

A terminal row for an order caps the quantity holdings must still show at its filled quantity; an order that ended with nothing filled is forgotten at once. After the runner has seen the phase CLOSED or POST_CLOSE since the order was sent, an open row of a DAY order counts as terminal (its filled quantity is final); not for a serialized runner, whose rules are under serialized. An order the history settled, or had no answer for after the timeout, withholds its instrument (orders_unconfirmed_timed_out) if a holdings read a timeout later still does not show it; see set_confirmation_timeout.

Parameters
evidenceHistory rows covering the instants unconfirmed_awaiting_evidence asked for.

Definition at line 1118 of file runner.hpp.

◆ context() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const Context & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::context ( ) const
inlinenoexcept

Returns the context.

Returns
The context.

Definition at line 543 of file runner.hpp.

Referenced by algotradelib::runner::ManualSource< Runner >::poll().

◆ context() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Context & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::context ( )
inlinenoexcept

Returns the context, to arrange its state (instruments, portfolio) before feeding events.

Returns
The context.

Definition at line 548 of file runner.hpp.

◆ deferred_awaiting_evidence()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::optional< std::chrono::system_clock::time_point > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::deferred_awaiting_evidence ( ) const
inline

Returns from when the broker's order history must be read to decide waiting targets.

Returns
The earliest instant a target whose stops are all unlisted began waiting, or std::nullopt if none can be decided from history yet.

Definition at line 737 of file runner.hpp.

◆ deferred_dropped_after_fill()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::deferred_dropped_after_fill ( ) const
inlinenoexcept

Returns how many waiting targets were dropped because a stop they waited on had filled.

Returns
The count over the runner's life.

Definition at line 730 of file runner.hpp.

◆ deferred_targets()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::vector< strategy::TargetPosition > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::deferred_targets ( ) const
inline

Returns the targets waiting for a stop on their instrument to be cancelled (at most one per instrument).

A target that needs a trade while a stop rests cancels the stop and waits (strategy::RejectReason::STOP_ORDER_RESTING); the runner keeps it so it is not lost when no strategy callback follows. It is:

  • replaced by any later target or order intent the strategy states for the instrument;
  • released (and settled) by retry_deferred once each stop it waits on is no longer listed and its history row is terminal with nothing filled;
  • dropped without sending if a stop shows any fill (counted in deferred_dropped_after_fill; a partial fill's remainder is left for the strategy to restate);
  • kept while a stop is still listed or its history is missing or not terminal.

Not journalled: a restart loses it.

Returns
The waiting targets.

Definition at line 711 of file runner.hpp.

◆ executor() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const Executor & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::executor ( ) const
inlinenoexcept

Returns the executor.

Returns
The executor.

Definition at line 366 of file runner.hpp.

◆ executor() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Executor & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::executor ( )
inlinenoexcept

Returns the executor.

Returns
The executor.

Definition at line 371 of file runner.hpp.

◆ feed() [1/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( const OrderSnapshot & event)
inline

Feeds one order update: calls on_order_update and settles.

Parameters
eventThe order's new state.
Returns
The pass's report.

Definition at line 1666 of file runner.hpp.

◆ feed() [2/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( const strategy::BarEvent & event)
inline

Feeds one bar: caches it, sets the last price and the clock to the bar's period end, calls on_bar, and settles what the strategy asked for.

Does not compile for a strategy declaring on_bars (takes_bar_slices): use record and feed(const strategy::BarSlice&).

Parameters
eventThe bar.
Returns
The pass's report.
Exceptions
std::invalid_argument(with a linear algebra backend) if the bar is not later than the cached series' newest bar.

Definition at line 1524 of file runner.hpp.

◆ feed() [3/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( const strategy::BarSlice & slice)
inline

Delivers one period's bars to on_bars and settles what the strategy asked for.

Every bar in the slice must have been passed to record first; nothing here caches, prices or clocks. on_bars then sees ctx.bars(id, slice.interval_) end at the slice's period for every instrument in it.

Parameters
sliceThe period's bars.
Returns
The pass's report.

Definition at line 1611 of file runner.hpp.

◆ feed() [4/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( const strategy::Fill & event)
inline

Feeds one execution: calls on_fill and settles.

Parameters
eventThe fill.
Returns
The pass's report.

Definition at line 1655 of file runner.hpp.

◆ feed() [5/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( const strategy::QuoteEvent & event)
inline

Feeds one quote: sets the last price and the clock, calls on_quote, and settles.

Parameters
eventThe quote.
Returns
The pass's report.

Definition at line 1642 of file runner.hpp.

◆ feed() [6/6]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed ( strategy::MarketPhase phase)
inline

Feeds a market phase change: sets it on the context, calls on_phase, and settles.

Parameters
phaseThe new phase.
Returns
The pass's report.

Definition at line 1677 of file runner.hpp.

◆ feed_warmup() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed_warmup ( const strategy::BarEvent & event)
inline

Feeds one bar as history: like feed, but whatever the strategy asks for is discarded (counted in warmup_instructions_discarded).

Use it for every bar older than the newest one, so a restart or a backlog does not act on an old signal at today's price. A source of your own should feed a read's new bars in period-end order across instruments, and feed live (with feed) only each instrument's newest closed bar, and only if its period ended strictly after every bar fed as history from the same read, across instruments. A newest bar that ties or trails one (a suspended name, or one a bar behind) is history too, or an order could be decided on a stale cross-section at today's price.

Does not compile for a strategy declaring on_bars: use record and feed_warmup(const strategy::BarSlice&).

Parameters
eventThe bar.
Exceptions
std::invalid_argument(with a linear algebra backend) if the bar is not later than the cached series' newest bar.

Definition at line 1553 of file runner.hpp.

◆ feed_warmup() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::feed_warmup ( const strategy::BarSlice & slice)
inline

Delivers one period's bars as history: like feed(const strategy::BarSlice&), but whatever the strategy asks for is discarded (counted in warmup_instructions_discarded).

Every bar in the slice must have been passed to record first. See feed_warmup(const strategy::BarEvent&) for which bars are history.

Parameters
sliceThe period's bars.

Definition at line 1626 of file runner.hpp.

◆ guard() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const strategy::RiskGuard & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::guard ( ) const
inlinenoexcept

Returns the risk guard.

Returns
The guard.

Definition at line 554 of file runner.hpp.

◆ guard() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
strategy::RiskGuard & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::guard ( )
inlinenoexcept

Returns the risk guard, to halt or resume trading.

Returns
The guard.

Definition at line 559 of file runner.hpp.

◆ halt_locally()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::halt_locally ( std::string detail)
inline

Stops this runner sending, with the LOCAL_FAILURE hold, until resume_after_local_failure.

Used, for example, by recovery when a damaged journal shows something was in flight but not what.

Parameters
detailWhy, for the operator.

Definition at line 472 of file runner.hpp.

Referenced by algotradelib::runner::recover_runner().

◆ instructions_unavailable()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::instructions_unavailable ( ) const
inlinenoexcept

Returns how many instructions (placements and cancellations) were not sent because local machinery was unavailable; each leaves the LOCAL_FAILURE hold.

Returns
The count over the runner's life.

Definition at line 1373 of file runner.hpp.

◆ intents_kept_for_phase()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::intents_kept_for_phase ( ) const
inlinenoexcept

Returns how many order intents are kept for the market phase, an unreachable broker or a rate limit; see retry_retained_targets.

Returns
The number kept now.

Definition at line 1276 of file runner.hpp.

◆ kept_intents_dropped()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::kept_intents_dropped ( ) const
inlinenoexcept

Returns how many kept intents were dropped at release, because the holding they were decided against had changed or a stop now rests.

Returns
The count over the runner's life.

Definition at line 1283 of file runner.hpp.

◆ last_broker_refusal()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const std::optional< BrokerRefusal > & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::last_broker_refusal ( ) const
inlinenoexcept

Returns the broker's code and message for the most recent order it refused (SendOutcome::REJECTED; at KIS, Toss and Kiwoom most refusals are INDETERMINATE and not recorded here).

Returns
The refusal, or std::nullopt if none (or the executor cannot report errors, as in a dry run or replay). A refusal with no detail clears it, so a nonzero orders_broker_refused can sit beside an empty value.

Definition at line 1404 of file runner.hpp.

◆ last_unbuildable()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const std::optional< strategy::Rejection > & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::last_unbuildable ( ) const
inlinenoexcept

Returns why reconciliation could not build the most recent instruction it refused.

For example, a live weight-sized intent is refused NO_PORTFOLIO_VALUE on every pass unless set_portfolio_value was called.

Returns
The rejection, or std::nullopt if none.

Definition at line 1416 of file runner.hpp.

◆ ledger() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const IndeterminacyLedger & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::ledger ( ) const
inlinenoexcept

Returns the ledger of instruments withheld pending reconciliation or an operator: an order of unknown outcome, which a sweep of the broker's lists can resolve, or one that timed out unconfirmed or is held for an operator, which no listing clears (account for it with release_obligations, and clear the ledger entry yourself once the broker's state is read).

Returns
The ledger.

Definition at line 380 of file runner.hpp.

Referenced by algotradelib::runner::recover_runner().

◆ ledger() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
IndeterminacyLedger & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::ledger ( )
inlinenoexcept

Returns the ledger, so an operator who has read the broker's order list can clear an entry.

Returns
The ledger.

Definition at line 385 of file runner.hpp.

◆ local_failure()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::optional< std::string > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::local_failure ( ) const
inline

Returns why local machinery stopped sending, if it did.

The hold (strategy::HaltReason::LOCAL_FAILURE) stays until resume_after_local_failure (or a direct guard().resume), even if the failure was transient. The detail is the first failure recorded through this runner.

Returns
The detail, or std::nullopt while sending works.

Definition at line 395 of file runner.hpp.

◆ notify_stop()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::notify_stop ( )
inline

Calls on_stop and settles what it asked for while PollingLoop's STOPPING hold stands, so the strategy's parting orders are refused rather than sent beside the operator's closing orders.

Returns
The pass's report.

Definition at line 1498 of file runner.hpp.

◆ obligation_state()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
ObligationState algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::obligation_state ( const InstrumentId & instrument) const
inline

Returns what a serialized runner still owes on an instrument.

Parameters
instrumentThe instrument.
Returns
The most restrictive state of its orders not yet accounted for: OPERATOR over UNNAMED over NAMED; NONE if there are none or the runner is not serialized.

Definition at line 911 of file runner.hpp.

◆ obligations() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::vector< Obligation > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::obligations ( ) const
inline

Lists every order a serialized runner still owes, on any instrument.

Returns
One entry per order, in the order sent; empty if none or the runner is not serialized.

Definition at line 946 of file runner.hpp.

◆ obligations() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::vector< Obligation > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::obligations ( const InstrumentId & instrument) const
inline

Lists the orders a serialized runner still owes on an instrument, for an operator.

Parameters
instrumentThe instrument.
Returns
One entry per order, in the order sent; empty if none or the runner is not serialized.

Definition at line 933 of file runner.hpp.

◆ obligations_awaiting_account()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::obligations_awaiting_account ( ) const
inlinenoexcept

Returns how many orders a serialized runner owes that a later read could account for without anything more being sent: not held for an operator, and either no longer listed (filled or gone, awaiting holdings or history) or withdrawn with the withdrawal accepted.

An order that is simply resting is not counted: only a withdrawal changes that. PollingLoop reads this to decide whether a stop that closes should read again before its pass.

Returns
The count; zero for a runner that is not serialized.

Definition at line 1326 of file runner.hpp.

◆ obligations_unexplained()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::obligations_unexplained ( ) const
inlinenoexcept

Returns how many orders a serialized runner owes that nothing yet explains: no listing shows them resting and holdings do not show them, or only an operator may account for them.

PollingLoop counts these as a closing pass begins and reports them, since the pass cannot see them.

Returns
The count; zero for a runner that is not serialized.

Definition at line 1043 of file runner.hpp.

◆ observe_sellable_convention()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::observe_sellable_convention ( )
inline

Shows the current portfolio to the sellable-convention probe, if it is on.

Called on every pass and by PollingLoop after it polls. Skipped while the working-order listing is newer than the holdings.

Definition at line 511 of file runner.hpp.

◆ observed_at()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::chrono::system_clock::time_point algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::observed_at ( ) const
inlinenoexcept

Returns the instant last set by set_observed_at.

Returns
The instant, or the epoch if never set.

Definition at line 442 of file runner.hpp.

◆ orders_awaiting_confirmation()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_awaiting_confirmation ( ) const
inlinenoexcept

Returns how many orders a serialized runner withheld because another order on the instrument was not yet accounted for, or the runner could not yet measure one; see serialized. Whole plans withheld for it are in plans_withheld.

Returns
The count over the runner's life.

Definition at line 1033 of file runner.hpp.

◆ orders_binding_refused()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_binding_refused ( ) const
inlinenoexcept

Returns how many orders the binding refused to send (no request made); see orders_unbuildable.

Returns
The count.

Definition at line 670 of file runner.hpp.

◆ orders_broker_refused()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_broker_refused ( ) const
inlinenoexcept

Returns how many orders the broker refused (SendOutcome::REJECTED; a request was spent); see last_broker_refusal. At KIS, Toss and Kiwoom most refusals count as unknown outcomes instead.

Returns
The count.

Definition at line 677 of file runner.hpp.

◆ orders_guard_refused()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_guard_refused ( ) const
inlinenoexcept

Returns how many orders the risk guard refused, for a limit or a hold; see orders_unbuildable.

Returns
The count.

Definition at line 665 of file runner.hpp.

◆ orders_indeterminate()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_indeterminate ( ) const
inlinenoexcept

Returns how many orders had an unknown outcome (SendOutcome::INDETERMINATE, which at KIS, Toss and Kiwoom includes most of the broker's own refusals).

Returns
The count.

Definition at line 683 of file runner.hpp.

◆ orders_reconcile_withheld()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_reconcile_withheld ( ) const
inlinenoexcept

Returns how many orders were held back because the instrument was in the ledger (an order of unknown outcome, timed out unconfirmed, or held for an operator); see orders_unbuildable.

Returns
The count.

Definition at line 660 of file runner.hpp.

◆ orders_unbuildable()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_unbuildable ( ) const
inlinenoexcept

Returns how many orders reconciliation could not build (any strategy::RejectReason before sending, including a quantity that rounded to zero).

One of eight counters of what became of placements: orders_unbuildable, orders_reconcile_withheld, orders_awaiting_confirmation, orders_guard_refused, orders_binding_refused, orders_broker_refused, orders_indeterminate and instructions_unavailable (which counts cancellations too). All count over the runner's life, so a loop differences them; the per-instruction reasons are in each pass's Report. See also last_unbuildable.

Returns
The count.

Definition at line 654 of file runner.hpp.

◆ orders_unconfirmed_timed_out()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::orders_unconfirmed_timed_out ( ) const
inlinenoexcept

Returns how many sent orders timed out unconfirmed; see set_confirmation_timeout.

Returns
The count over the runner's life.

Definition at line 1073 of file runner.hpp.

◆ placements_at_broker()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::placements_at_broker ( ) const
inlinenoexcept

Returns how many placements may have left an order at the broker (accepted or of unknown outcome).

Returns
The count over the runner's life; compare it before and after to tell whether a listing is out of date.

Definition at line 478 of file runner.hpp.

◆ plans_withheld()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::plans_withheld ( ) const
inlinenoexcept

Returns how many whole reconciliation plans were held back (any WithheldPlanReason: holdings absent, stale or superseded, or a placement hold); the reasons are in each Report::withheld_plans_.

Returns
The count over the runner's life.

Definition at line 691 of file runner.hpp.

◆ price_bands_withheld()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::price_bands_withheld ( ) const
inlinenoexcept

Returns how many plans were built while a band was known for the instrument but not applied (counted per plan, not per order).

Returns
The count over the runner's life.

Definition at line 613 of file runner.hpp.

◆ price_limits_age_policy_stated()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::price_limits_age_policy_stated ( ) const
inlinenoexcept

Tests whether a price-band age policy has been stated (a maximum, or any age).

Returns
true if one has.

Definition at line 619 of file runner.hpp.

◆ probe_sellable_convention()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::probe_sellable_convention ( bool enabled = true)
inline

Turns on the strategy::SellableConventionProbe, which infers whether the broker's sellable figure already excludes resting sells.

Off by default. It only observes; it sends and requests nothing extra. Read the answer from sellable_convention().

Parameters
enabledWhether to probe.

Definition at line 503 of file runner.hpp.

◆ record()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::record ( const strategy::BarEvent & event)
inline

Prepares one bar for a slice: caches it (with a linear algebra backend) and sets the last price and the clock to the bar's period end, without calling a handler or settling.

For a strategy declaring on_bars, a source records every bar of a period, then delivers the period with feed(const strategy::BarSlice&).

Parameters
eventThe bar.
Exceptions
std::invalid_argument(with a linear algebra backend) if the bar is not later than the cached series' newest bar.

Definition at line 1574 of file runner.hpp.

◆ record_history_only()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::record_history_only ( const strategy::BarEvent & event)
inline

Caches one bar without moving the last price or the clock, and without calling a handler.

For a bar that arrives after its period was already delivered: its own series stays complete, while a newer price or a later clock is not overwritten by an older bar. Does nothing without a linear algebra backend.

Parameters
eventThe bar.
Exceptions
std::invalid_argument(with a linear algebra backend) if the bar is not later than the cached series' newest bar.

Definition at line 1593 of file runner.hpp.

◆ refresh_unconfirmed()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::refresh_unconfirmed ( )
inline

Rebuilds the reserved working rows against the portfolio as it is now.

Every pass does this first; call it before reading working_ outside a pass.

Definition at line 791 of file runner.hpp.

◆ release_obligations()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::release_obligations ( const InstrumentId & instrument,
const std::string & reason )
inline

Accounts for every order a serialized runner still owes on an instrument, on an operator's word.

For an order held for an operator, one whose reply was lost and no sweep named, one from an older journal, or one whose holdings never arrived: read the broker's order list and holdings first. Each order gets a JournalOutcome::CONFIRMED line naming reason and is then forgotten; the next order on the instrument needs a holdings read received after this call. The indeterminacy ledger is left as it is. If a line cannot be written, that order is kept and the runner stops sending (HaltReason::LOCAL_FAILURE).

Parameters
instrumentThe instrument.
reasonWhy, for the journal.
Returns
false if any line could not be written.

Definition at line 980 of file runner.hpp.

◆ require_known_portfolio()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::require_known_portfolio ( bool required)
inline

Sets whether placing requires holdings to have been read and fresh.

On by default for an executor that can reach a broker, off for a dry run or a replay. Off, a placement-only plan skips both the read and the age check. PollingLoop sets it each iteration. A plan that would cancel something is held back unless holdings have been read and are fresh, whatever this setting.

Parameters
requiredWhether placing requires read holdings.

Definition at line 462 of file runner.hpp.

◆ resolve_indeterminate_placement()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::resolve_indeterminate_placement ( const InstrumentId & instrument,
OrderSide side,
const std::optional< std::string > & order_id,
const std::string & journal_id = {} )
inline

Tells the runner what a reconciliation sweep found for an order of unknown outcome.

With an order id (found in the broker's listing), the order is tracked like an accepted one; without (it was never placed), it is forgotten with its reserved row. live::SessionSource calls this for each recorded MATCHED or NOT_PLACED placement; a source of your own, or an operator clearing the ledger by hand, should too, or the order's instrument is withheld again after the confirmation timeout.

A serialized runner names only the order whose journal line is journal_id, and forgets nothing (serialized).

Parameters
instrumentThe instrument.
sideThe order's side.
order_idThe broker's order id, or std::nullopt if the order was not placed.
journal_idThe id of the order's journal line; without it a serialized runner does nothing, and any other runner names its newest unnamed order on the instrument and side.

Definition at line 811 of file runner.hpp.

◆ restore_obligations()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::restore_obligations ( const JournalReplay & replay)
inline

Restores the orders a previous process left unaccounted for; runner::recover_runner calls it, and a serialized runner places nothing until it has run.

Every placement with no CONFIRMED or REJECTED line comes back, named by an ACCEPTED or RESOLVED line's order id or else unnamed, measured from the holding its lines recorded. One with no recorded holding (an overlapping or older journal), lines that disagree or were damaged, a HELD line, or another such order on its instrument, is held for an operator and marks the ledger. Each instrument's latest CONFIRMED line means only a holdings read received after it sizes the next order. Does nothing else for a runner that is not serialized.

Parameters
replayThe journal's contents.

Definition at line 1017 of file runner.hpp.

Referenced by algotradelib::runner::recover_runner().

◆ resume_after_local_failure()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::resume_after_local_failure ( )
inline

Clears the local-failure hold, after an operator has fixed the cause.

It also acknowledges the journal failures seen so far, so the same failure does not halt again. Other holds, such as an operator's halt, stay.

Definition at line 408 of file runner.hpp.

◆ retry_deferred()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::retry_deferred ( const std::vector< OrderSnapshot > & evidence)
inline

Decides each waiting target against the broker's order history, and settles what it released.

live::SessionSource calls it after a working-order poll. It calls no handler.

Parameters
evidenceHistory rows covering the instants deferred_awaiting_evidence asked for.
Returns
The report of the settlement.

Definition at line 759 of file runner.hpp.

◆ retry_deferred_on_one_snapshot()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::retry_deferred_on_one_snapshot ( )
inline

Releases and settles every waiting target whose stops are no longer listed, without reading history.

Only for a replay, whose ledger is the broker: a stop it withdrew cannot have filled. A live caller uses retry_deferred.

Returns
The report of the settlement.

Definition at line 1367 of file runner.hpp.

◆ retry_retained_targets()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::retry_retained_targets ( )
inline

Re-submits retained targets and kept intents once they can be acted on, and settles them.

The runner keeps (rather than drops):

  • a target withheld as PORTFOLIO_ABSENT, PORTFOLIO_STALE or PORTFOLIO_SUPERSEDED, until holdings are usable (any runner, a dry run included);
  • a target or order intent refused for the market phase (a daily strategy deciding while the market is shut), until RiskLimits::permitted_phases_ admits the phase;
  • a target or order intent the broker could not be reached for, or refused for its rate limit, until a holdings read newer than the failure arrives;
  • in a serialized runner, a target whose plan could only withdraw an order the runner still owes, until every order on its instrument is accounted for (the withdrawal is attempted once, and not again while the target waits);
  • in a serialized runner, a target whose order was withheld as RECONCILE_REQUIRED, planned again at each later holdings read and withheld again while the instrument is unresolved.

All but the first only in a runner that sends to a broker. A released target is planned under the limits then in force, and one the guard refuses for anything but the phase is not kept again. Not kept: anything decided under the STOPPING, OPERATOR or LOCAL_FAILURE hold; an intent with a client order id the broker answered; an intent whose instrument's net holding is unknown. So a protective stop with a client order id, refused out of hours, is not installed at the open by itself (one without an id is).

At release, a kept intent is dropped (kept_intents_dropped) if the instrument's holding changed since (except a TARGET_WEIGHT intent, which is planned again against the new holding), or if it carries a trigger and a stop now rests on the instrument.

Nothing is released while holdings were never read or predate the listing, or while any hold is in force. If this method runs while OPERATOR or LOCAL_FAILURE holds, it discards every kept intent and every target kept for the phase or the broker (targets kept for the account stay). Halting and resuming without calling it in between discards nothing, so the kept work can still go out after the resume; call clear_retained_targets to drop it. A later target or intent for the instrument replaces a retained one, one still queued on the context when this is called included. PollingLoop calls this once per iteration; a program driving a Runner itself must call it (or clear_retained_targets).

Returns
The report of the settlement, empty if nothing was released.

Definition at line 1197 of file runner.hpp.

◆ sellable_convention()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const strategy::SellableConventionProbe< Tag > & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::sellable_convention ( ) const
inlinenoexcept

Returns the sellable-convention probe.

Returns
What it has inferred, with its counts.

Definition at line 524 of file runner.hpp.

◆ sends_outside_permitted_phase()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::sends_outside_permitted_phase ( ) const
inlinenoexcept

Returns how many orders were sent in a market phase RiskLimits::permitted_phases_ does not permit, because they close toward flat.

Counts sends, including ones the broker then rejected (likely outside a session). Not by itself a fault: it shows a flatten after the close, or a strategy restating a close every pass (limit that with RiskLimits::max_orders_per_window_).

Returns
The count over the runner's life.

Definition at line 490 of file runner.hpp.

◆ serialized()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::serialized ( ) const
inlinenoexcept

Tests whether this runner is serialized: at most one order per instrument that holdings have not yet accounted for.

On by default for a runner that journals what it sends to a broker (journals_to_a_broker: live::bind_journaled, or a JournalingExecutor of your own). In this mode:

  • a plan that would place on an instrument is withheld whole, its derived cancellations included (WithheldPlanReason::AWAITING_CONFIRMATION), while an order this runner placed there is not yet accounted for. So a protective stop cannot be placed beside an unconfirmed entry, a resting order holds its instrument until it has filled or been withdrawn and is accounted for, and a target cannot reprice its own order: cancel it with a CancelIntent and state the target again. A withheld target is kept and planned again after a newer holdings read; an order intent is reported, not kept. A target that would withdraw a resting stop and wait for it (deferred_targets) is withheld the same way while the stop is this runner's unaccounted order: withdraw the stop with a CancelIntent first;
  • an order is accounted for when a holdings read shows exactly the holding it was decided against plus what it filled (all of it, or what its own dated, ended history row says), or that row shows it ended with nothing filled. The journal records it (JournalOutcome::CONFIRMED) before the instrument is free again. The read that accounted for it may size the next order, an older one may not; after a restart or an operator's release, only a read received later may;
  • an order whose reply was lost is accounted for only once a sweep names it and a dated history row of its send confirms the name. A sweep that finds no order leaves it owed and unnamed, and live::SessionSource looks for its row again at every order-list read; only release_obligations ends one that is never found. Holdings that move past what an order can explain, or a history row of its own reporting more filled than it was for, hold it for an operator (JournalOutcome::HELD); see release_obligations. A holdings read older than the one an order was decided against says nothing about it. A timeout is counted (orders_unconfirmed_timed_out) but releases nothing, and the order still withholds its instrument until it is accounted for; only one never named marks the ledger;
  • runner::recover_runner restores every order a previous process left unaccounted for, so a restart cannot send it again, and nothing is placed before it has run. Orders from an overlapping or older journal, or two on one instrument, are restored for an operator to release.

It assumes this runner is the only one trading the account, that a holdings read received later shows no older content, and that the journal's clock and the holdings' as_of_ are one clock (as they are live; a simulated market must journal on its own clock). Orders placed any other way are outside it, as is an executor that drives this runner from inside its own place. A runner that journals to a broker but lacks what this needs (a broker that lists working orders, and an executor with last_entry, record and place(order, baseline), as JournalingExecutor has) places nothing until allow_overlapping_orders is called.

Returns
Whether serialized.

Definition at line 885 of file runner.hpp.

◆ set_confirmation_timeout()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_confirmation_timeout ( std::chrono::nanoseconds timeout)
inline

Sets how long a sent order's quantity may stay unexplained before it is counted as timed out (ten minutes by default).

When it passes, the broker's history is read once more; if that does not settle it, or holdings still do not show the filled quantity one more timeout later, the order is counted (orders_unconfirmed_timed_out). A runner that is not serialized then forgets it and marks the instrument in the indeterminacy ledger for an operator to clear, so too short a timeout costs trading on that instrument, never a duplicate order. A serialized runner keeps it owed, so the instrument trades again once evidence accounts for it; only an order never named marks the ledger, so an unattended run watches its obligations (obligations), not only the ledger. It needs a source that advances Portfolio::as_of_ on each holdings read.

Parameters
timeoutThe timeout.

Definition at line 1067 of file runner.hpp.

◆ set_maximum_portfolio_age()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_maximum_portfolio_age ( std::optional< std::chrono::nanoseconds > age)
inline

Sets how old the holdings may be before a reconciliation plan computed from them is held back (WithheldPlanReason::PORTFOLIO_STALE).

It applies to every plan that would cancel something, and to placement-only plans while require_known_portfolio is on. It takes no hold on the guard. Age is measured against the later of observed_at() and Context::now(). PollingLoop sets it from its own configuration.

Parameters
ageThe maximum age, or std::nullopt for no limit.

Definition at line 423 of file runner.hpp.

◆ set_maximum_price_limits_age()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_maximum_price_limits_age ( std::optional< std::chrono::nanoseconds > age)
inline

Sets how old a price band may be and still be applied to an order's price.

With no policy stated (the default), no band is applied; call allow_unbounded_price_limits_age to apply bands of any age.

A band not applied leaves the strategy's own price on the order, as if no band were known. That has costs: the exchange may reject a price outside today's real band that the clamp would have fixed (an exit below today's floor, say), or a local check (notional, buying power, exposure) may refuse a buy priced above the ceiling. unclamped_orders_rejected and unclamped_orders_refused count those; an order accepted at the raw price that never filled is not counted.

Parameters
ageThe maximum age. std::nullopt withdraws the policy (so no band is applied); it does not mean "any age".

Definition at line 597 of file runner.hpp.

◆ set_minimum_trade()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_minimum_trade ( Decimal64 quantity)
inline

Sets only the share-count floor of the trade tolerance.

Across instruments at different price levels, prefer a notional or fractional floor.

Parameters
quantityThe smallest drift worth trading, in shares.

Definition at line 1435 of file runner.hpp.

◆ set_observed_at()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_observed_at ( std::chrono::system_clock::time_point at)
inline

Sets the current wall-clock instant, used to measure the age of holdings and price bands.

PollingLoop sets it each iteration. Without it, age is measured against Context::now(), which for a daily bar is its period end and understates age. The epoch (time_point{}) is reserved for "no reading": a clock of your own should not start there (ManualClock{} does; give it a start).

Parameters
atThe instant.

Definition at line 436 of file runner.hpp.

◆ set_portfolio_value() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_portfolio_value ( Decimal64 value)
inline

Sets the portfolio's total value, which a weight-sized intent needs live.

Without it a weighted intent is refused (NO_PORTFOLIO_VALUE). The value is taken to be in each instrument's own currency; use the Money overload to state it.

Parameters
valueThe total value.

Definition at line 1447 of file runner.hpp.

◆ set_portfolio_value() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_portfolio_value ( Money value)
inline

Sets the portfolio's total value and its currency.

A weight on an instrument in another currency is then refused. The value is kept until replaced or cleared with clear_portfolio_value.

Parameters
valueThe total value and currency.

Definition at line 1460 of file runner.hpp.

◆ set_price_limits()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_price_limits ( const InstrumentId & id,
PriceLimits limits )
inline

Records an instrument's price band for today, used to clamp order prices.

The band is dated by the earlier of the exchange's timestamp, where the broker gave one (Toss, Kiwoom), and the instant last set with set_observed_at (the only date of a KIS band); a future exchange timestamp cannot make it fresher. A band recorded before any instant was set is dated at the epoch, so any realistic age limit rejects it. Its age is measured against the later of observed_at() and Context::now(); a band dated after that instant is never applied, whatever the policy. Whether a band is applied depends on set_maximum_price_limits_age.

Parameters
idThe instrument (bands are kept per full identity, venue included).
limitsThe band.

Definition at line 574 of file runner.hpp.

Referenced by algotradelib::runner::ManualSource< Runner >::poll().

◆ set_trade_tolerance()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
void algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::set_trade_tolerance ( strategy::TradeTolerance tolerance)
inline

Sets how small a drift from a target is not worth an order; see strategy::TradeTolerance.

Parameters
toleranceThe floors; all unset (the default) trades every share.

Definition at line 1424 of file runner.hpp.

◆ settle_closing()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::settle_closing ( )
inline

Settles instructions already queued on the context, without calling a handler.

PollingLoop queues its closing orders and settles them with this.

Returns
The pass's report.

Definition at line 1510 of file runner.hpp.

◆ start()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::start ( )
inline

Calls on_start and settles what it asked for.

Returns
The pass's report.

Definition at line 1475 of file runner.hpp.

◆ stop()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Report algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::stop ( )
inline

Calls on_stop and settles what it asked for.

For a caller driving a runner directly; PollingLoop uses notify_stop during a stop instead.

Returns
The pass's report.

Definition at line 1487 of file runner.hpp.

◆ strategy() [1/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
const Strategy & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::strategy ( ) const
inlinenoexcept

Returns the strategy, to read the state it kept.

Returns
The strategy.

Definition at line 532 of file runner.hpp.

◆ strategy() [2/2]

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
Strategy & algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::strategy ( )
inlinenoexcept

Returns the strategy.

Returns
The strategy.

Definition at line 537 of file runner.hpp.

◆ targets_deferred()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::targets_deferred ( ) const
inlinenoexcept

Returns how many targets have waited for a stop's cancellation; see deferred_targets.

Returns
The count over the runner's life.

Definition at line 724 of file runner.hpp.

◆ targets_retained()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::targets_retained ( ) const
inlinenoexcept

Returns how many targets are retained, for any reason; see retry_retained_targets.

Returns
The number retained now.

Definition at line 1289 of file runner.hpp.

◆ targets_retained_for_phase()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::targets_retained_for_phase ( ) const
inlinenoexcept

Returns how many retained targets wait for the market phase, an unreachable broker or a rate limit.

Returns
The number retained now.

Definition at line 1296 of file runner.hpp.

◆ unclamped_orders_refused()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::unclamped_orders_refused ( ) const
inlinenoexcept

Returns how many orders carrying a price a withheld band would have clamped were refused before sending (by the risk guard or the binding; not counting UNAVAILABLE).

Returns
The count over the runner's life.

Definition at line 639 of file runner.hpp.

◆ unclamped_orders_rejected()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::unclamped_orders_rejected ( ) const
inlinenoexcept

Returns how many sent orders the broker refused while carrying a price a withheld band would have clamped.

Co-occurrence, not proof that the band caused the refusal. Orders refused before sending are in unclamped_orders_refused.

Returns
The count over the runner's life.

Definition at line 632 of file runner.hpp.

◆ unconfirmed_awaiting_evidence()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::optional< std::chrono::system_clock::time_point > algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::unconfirmed_awaiting_evidence ( )
inline

Returns from when the broker's order history must be read to settle sent orders.

An order needs it when part of it is unexplained and either it passed the confirmation timeout (listed or not), or no listing carries it and it was listed before, its cancellation was accepted, or it was restored at startup. In a serialized runner, an order a sweep named and no dated row has confirmed always needs it. Excluded: an order the history already settled; one whose history had no answer after the timeout (until a later listing or holdings explain it again); an order held for an operator; in a serialized runner, an order with no name; and, overlapping, an order of unknown outcome with no reference while its instrument is in the ledger.

Returns
The earliest such order's send instant, or std::nullopt if none needs history.

Definition at line 1088 of file runner.hpp.

◆ unconfirmed_orders()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::unconfirmed_orders ( ) const
inlinenoexcept

Returns how many sent orders are still counted as reserved until the broker accounts for them.

A runner that keeps sent orders (keeps_sent_orders_until_listed) remembers each order the broker accepted with a reference, and each order of unknown outcome if its executor reports references (has last_ref(), as live::SessionExecutor does), provided holdings had been read and the instrument's net holding was known when it was sent. Before each pass it rebuilds a reserved working row from what neither holdings (moved in the order's direction since it was sent) nor a listing yet explains. An entry ends when holdings show the whole quantity, or the broker's history shows the order ended with less (confirm_from_history). This stops a target from ordering again while a fill has not reached the holdings yet.

An accepted order not tracked (no reference, or sent before holdings were read, as allow_absent_portfolio permits) has no such protection: its reservation lasts only until the next listing. An order of unknown outcome not tracked (an executor without last_ref()) gets no reservation at all once the ledger entry is resolved. Only orders sent in this process are tracked, and a restart starts with none, unless the runner is serialized (serialized).

Returns
The number of such orders.

Definition at line 784 of file runner.hpp.

◆ warmup_instructions_discarded()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
std::size_t algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::warmup_instructions_discarded ( ) const
inlinenoexcept

Returns how many instructions feed_warmup discarded.

Returns
The count over the runner's life.

Definition at line 1635 of file runner.hpp.

◆ withdrawal_accepted_for()

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::withdrawal_accepted_for ( const WorkingOrder< Tag > & working) const
inline

Tests whether working is a row of an order this runner sent whose withdrawal the broker has already accepted. Such an order is not withdrawn again: a second withdrawal is refused.

Acceptance is of the request, not of its result: the order may still fill. The row has to be dated within an hour of the order's send: brokers reuse order numbers from day to day, and an undated row, or one of another day, is not known to be that order.

Parameters
workingA row of the portfolio's working orders.
Returns
true if this runner's accepted withdrawal of that order is on record.

Definition at line 1346 of file runner.hpp.

Member Data Documentation

◆ journals_to_a_broker

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::journals_to_a_broker
staticconstexpr
Initial value:
=
runner_detail::sends_to_a_broker<Executor>::value && runner_detail::journals<Executor>::value

true when this runner journals what it sends to a broker (a JournalingExecutor), which makes it serialized unless allow_overlapping_orders is called; see serialized.

Definition at line 340 of file runner.hpp.

◆ keeps_sent_orders_until_listed

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::keeps_sent_orders_until_listed
staticconstexpr
Initial value:
=
runner_detail::sends_to_a_broker<Executor>::value && CapsType::has_working_orders

true when this runner keeps each order it sends in Portfolio::working_ until a broker listing accounts for it: a live runner whose broker lists working orders (every shipped binding).

PollingLoop then requires the working-order poll (see PollSchedule::working_orders_).

Definition at line 333 of file runner.hpp.

◆ on_fill_never_fires

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::on_fill_never_fires
staticconstexpr
Initial value:
=
runner_detail::sends_to_a_broker<Executor>::value &&
strategy::strategy_detail::declares_on_fill<Strategy>

true when this runner sends to a broker and the strategy defines on_fill, which then never fires (no shipped live source produces fills).

Nothing is refused; PollingLoop puts a note in its report. A program that feeds Fill events itself does reach on_fill.

Definition at line 315 of file runner.hpp.

◆ takes_bar_slices

template<typename Strategy, typename CapsType = strategy::NoCaps, typename BrokerTag = DryTag, typename Executor = RecordingExecutor<DryTag>>
bool algotradelib::runner::Runner< Strategy, CapsType, BrokerTag, Executor >::takes_bar_slices = strategy::strategy_detail::declares_on_bars<Strategy>
staticconstexpr

true when the strategy declares on_bars: bars are then fed with record and delivered with feed(const strategy::BarSlice&) (or feed_warmup of one), and the single-bar feed and feed_warmup do not compile.

Definition at line 324 of file runner.hpp.


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