![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
The executor that sends a runner's orders and cancellations through a broker session. More...
#include <algotradelib/src/live/session_executor.hpp>
Public Types | |
| using | Caps = typename Session::Caps |
| The broker's capabilities, from the session. | |
| using | BrokerTag = typename Session::BrokerTag |
| The broker tag, from the session. | |
Public Member Functions | |
| SessionExecutor (Session &session, Venue default_route=Venue::UNSPECIFIED) | |
| Constructs an executor for a session. | |
| Venue | default_route () const noexcept |
| Returns the venue an order that names none is sent to. | |
| Venue | requested_route (Venue asked) const noexcept |
| Returns the venue this executor requests for an order. | |
| Venue | effective_route (Venue asked) const noexcept |
| Returns the route an order is sent with, for the journal to record before sending (for SOR, COMBINED, not the venue it executes on). | |
| runner::SendOutcome | place (const strategy::PlannedOrder &order) |
| Places one order. | |
| runner::SendOutcome | cancel (const WorkingOrder< BrokerTag > &working) |
| Cancels the whole remaining quantity of a working order. | |
| std::optional< Decimal64 > | sellable_quantity (const InstrumentId &instrument) |
| Asks the broker how much of an instrument may be sold, where the broker answers that by a separate inquiry (SellableSource::INQUIRY). | |
| const std::optional< OrderRef< BrokerTag > > & | last_ref () const noexcept |
| Returns the reference the broker issued for the last accepted order. | |
| const std::optional< BrokerError > & | last_error () const noexcept |
| Returns why the last instruction failed. | |
Static Public Member Functions | |
| static constexpr SellableBasis | sellable_inquiry_basis () |
| Returns what the broker's sellable-quantity inquiry establishes, recorded with each figure. | |
Static Public Attributes | |
| static constexpr bool | reaches_a_broker = true |
| true: a runner built on this executor requires holdings to have been read before it places, however the runner was assembled (see Runner::allow_absent_portfolio). | |
| static constexpr bool | inquires_sellable = Caps::sellable_source == SellableSource::INQUIRY |
| true if the sellable quantity is a separate inquiry (one request per instrument sold). | |
The executor that sends a runner's orders and cancellations through a broker session.
It copies a strategy::PlannedOrder into an OrderRequest (prices and quantities are already on the grid) and classifies a failure with runner::outcome_of. Usually made by bind or bind_journaled.
| Session | The broker session type (it must not be a market-data-only session). |
Definition at line 25 of file session_executor.hpp.
| using algotradelib::live::SessionExecutor< Session >::BrokerTag = typename Session::BrokerTag |
The broker tag, from the session.
Definition at line 36 of file session_executor.hpp.
| using algotradelib::live::SessionExecutor< Session >::Caps = typename Session::Caps |
The broker's capabilities, from the session.
Definition at line 34 of file session_executor.hpp.
|
inlineexplicit |
Constructs an executor for a session.
| session | The session; borrowed, and must outlive the executor. |
| default_route | The venue for an order that names none; see default_route(). |
Definition at line 50 of file session_executor.hpp.
|
inline |
Cancels the whole remaining quantity of a working order.
An order with no broker reference is refused (REFUSED_LOCALLY) without a request.
| working | The order, as listed (or reserved). |
Definition at line 160 of file session_executor.hpp.
|
inlinenoexcept |
Returns the venue an order that names none is sent to.
A strategy's orders name no venue, so this is the route of every order a runner plans; an order that names a venue keeps it. The runner writes the route into the order before sending, so the journal and reports name it.
UNSPECIFIED (the default) takes the broker's own default: KRX at KIS, none needed at Toss, and a refusal at Kiwoom, which has no default (give Venue::KRX, Venue::NXT, or Venue::COMBINED for its SOR). At KIS, Venue::COMBINED selects SOR, which a demo account refuses. A route the broker cannot take is refused before any request.
Definition at line 73 of file session_executor.hpp.
Referenced by SessionExecutor().
|
inlinenoexcept |
Returns the route an order is sent with, for the journal to record before sending (for SOR, COMBINED, not the venue it executes on).
default_route() is applied first; then the broker's traits say where an unspecified venue goes (KRX at KIS). A session whose traits do not say returns the requested route.
| asked | The order's venue. |
Definition at line 94 of file session_executor.hpp.
|
inlinenoexcept |
Returns why the last instruction failed.
Definition at line 237 of file session_executor.hpp.
|
inlinenoexcept |
Returns the reference the broker issued for the last accepted order.
Definition at line 231 of file session_executor.hpp.
|
inline |
Places one order.
An order with an idempotency key (client_order_id_) at a broker that accepts none is refused (REFUSED_LOCALLY), not sent without the key.
| order | The order. |
Definition at line 108 of file session_executor.hpp.
|
inlinenoexcept |
Returns the venue this executor requests for an order.
| asked | The order's venue. |
Definition at line 80 of file session_executor.hpp.
Referenced by effective_route(), and place().
|
inlinestaticconstexpr |
Returns what the broker's sellable-quantity inquiry establishes, recorded with each figure.
Definition at line 221 of file session_executor.hpp.
|
inline |
Asks the broker how much of an instrument may be sold, where the broker answers that by a separate inquiry (SellableSource::INQUIRY).
Elsewhere the figure comes with the holdings, and this returns std::nullopt without a request.
| instrument | The instrument. |
Definition at line 199 of file session_executor.hpp.
|
staticconstexpr |
true if the sellable quantity is a separate inquiry (one request per instrument sold).
Definition at line 215 of file session_executor.hpp.
|
staticconstexpr |
true: a runner built on this executor requires holdings to have been read before it places, however the runner was assembled (see Runner::allow_absent_portfolio).
Definition at line 32 of file session_executor.hpp.