algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::runner::OrderUpdateWatch< Broker > Class Template Reference

Turns successive working-order listings into order updates: the rows that changed since the previous listing. More...

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

Inheritance diagram for algotradelib::runner::OrderUpdateWatch< Broker >:

Public Member Functions

std::vector< OrderSnapshot > changed (const std::vector< WorkingOrder< Broker > > &rows)
 Compares a listing with the previous one and returns the rows that changed.
void adopt (const std::vector< WorkingOrder< Broker > > &rows)
 Takes a listing as the baseline without reporting anything (such as the startup read, which appears in Portfolio::working_ instead).
std::size_t untracked_rows () const noexcept
 Returns how many rows had an empty reference, and so were never reported.
std::size_t tracked_orders () const noexcept
 Returns how many orders the watch is tracking.
std::size_t contradicted_rows () const noexcept
 Returns how many times a listing stated one order twice with disagreeing readings (and so it was not reported).

Detailed Description

template<typename Broker>
class algotradelib::runner::OrderUpdateWatch< Broker >

Turns successive working-order listings into order updates: the rows that changed since the previous listing.

Runner feeds each update to on_order_update; a live loop and a backtest both use it.

What a caller is told: what the broker last stated about an order it still lists. An order that leaves the listing produces nothing, because the listing does not say whether it filled, was cancelled, expired or was rejected. Whether a listing can show a terminal status at all is BrokerCaps::working_orders_state_terminal (false for every shipped broker).

A change is a difference in status_, execution_.filled_quantity_, price_, trigger_price_, quantity_, order_amount_ or canceled_at_, compared as numbers whatever their decimal scale. Identity fields and fill money (average price, amounts, fees, fill time) are not compared; read them off the row. A new row is reported; two UNKNOWN statuses in a row are not a change.

Rows are matched by OrderRef (both parts). A row with an empty reference is counted in untracked_rows() and never reported; a runner's reservation row (WorkingOrder::reserved_) is skipped.

Note
In a live loop the update arrives during the working-order poll, before that iteration's holdings read, so a TargetPosition stated in on_order_update is withheld as PORTFOLIO_SUPERSEDED and planned after the holdings read; an OrderIntent stated there is dropped.
Template Parameters
BrokerThe broker tag.

Definition at line 97 of file order_updates.hpp.

Member Function Documentation

◆ adopt()

template<typename Broker>
void algotradelib::runner::OrderUpdateWatch< Broker >::adopt ( const std::vector< WorkingOrder< Broker > > & rows)
inline

Takes a listing as the baseline without reporting anything (such as the startup read, which appears in Portfolio::working_ instead).

Parameters
rowsThe complete listing.

Definition at line 119 of file order_updates.hpp.

◆ changed()

template<typename Broker>
std::vector< OrderSnapshot > algotradelib::runner::OrderUpdateWatch< Broker >::changed ( const std::vector< WorkingOrder< Broker > > & rows)
inline

Compares a listing with the previous one and returns the rows that changed.

A row not seen before is returned. Rows missing from rows are forgotten, so an order that leaves and returns is reported again as new. An order listed twice with disagreeing readings is not reported and is counted in contradicted_rows().

Parameters
rowsThe complete listing, every page; a partial listing makes orders appear and disappear. The shipped adapters return complete listings.
Returns
The changed rows' snapshots.

Definition at line 110 of file order_updates.hpp.

◆ contradicted_rows()

template<typename Broker>
std::size_t algotradelib::runner::OrderUpdateWatch< Broker >::contradicted_rows ( ) const
inlinenoexcept

Returns how many times a listing stated one order twice with disagreeing readings (and so it was not reported).

Returns
The count over the watch's life.

Definition at line 141 of file order_updates.hpp.

◆ tracked_orders()

template<typename Broker>
std::size_t algotradelib::runner::OrderUpdateWatch< Broker >::tracked_orders ( ) const
inlinenoexcept

Returns how many orders the watch is tracking.

Returns
The number of orders kept from the last listing (not counting reserved rows, rows with an empty reference, or orders the listing contradicted).

Definition at line 134 of file order_updates.hpp.

◆ untracked_rows()

template<typename Broker>
std::size_t algotradelib::runner::OrderUpdateWatch< Broker >::untracked_rows ( ) const
inlinenoexcept

Returns how many rows had an empty reference, and so were never reported.

Returns
The count of such rows over the watch's life (per sighting).

Definition at line 127 of file order_updates.hpp.


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