![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
Connects a runner to a broker session for live trading. More...
Classes | |
| class | SessionExecutor |
| The executor that sends a runner's orders and cancellations through a broker session. More... | |
| class | SessionSource |
| The source a runner::PollingLoop polls: reads a broker session and feeds bars, quotes, holdings, orders, buying power, price bands and the calendar to a runner. More... | |
Typedefs | |
| template<typename Strategy, typename Session> | |
| using | BoundRunner |
| The runner type bind returns. | |
| template<typename Strategy, typename Session> | |
| using | ObservingRunner |
| The runner type bind_observer returns: the same capabilities and tag, sending nowhere. | |
| template<typename Strategy, typename Session, typename Journal, typename Clock = runner::SteadyClock> | |
| using | JournaledRunner |
| The runner type bind_journaled returns: the same pipeline, journaling before it sends. | |
Functions | |
| template<typename Strategy, typename Session> | |
| BoundRunner< Strategy, Session > | bind (Session &session, Strategy strategy, strategy::RiskLimits limits={}, std::size_t series_capacity=default_series_capacity, Venue default_route=Venue::UNSPECIFIED) |
| Binds a strategy to a broker session, so its instructions are sent to the broker. | |
| template<typename Strategy, typename Session, typename Journal, typename Clock = runner::SteadyClock> | |
| JournaledRunner< Strategy, Session, Journal, Clock > | bind_journaled (Session &session, Journal &journal, Strategy strategy, strategy::RiskLimits limits={}, std::size_t series_capacity=default_series_capacity, Venue default_route=Venue::UNSPECIFIED, Clock clock={}) |
| Binds a strategy to a broker session, recording every instruction in a journal before it is sent. | |
| template<typename Strategy, typename Session> | |
| ObservingRunner< Strategy, Session > | bind_observer (Session &session, Strategy strategy, strategy::RiskLimits limits={}, std::size_t series_capacity=default_series_capacity) |
| Binds a strategy for observation: the session's capabilities and broker tag, and nothing to send through. | |
| runner::PollOutcome | poll_outcome_of (const BrokerError &error) noexcept |
| Classifies a failed inquiry for a poll. | |
| BrokerError | incomplete_history (std::string code, std::string message) |
| Makes the error an order-history read reports when the history is incomplete (a page said there is more, and it was not read). | |
| BrokerError | history_not_continued () |
| Makes the incomplete-history error for a broker whose adapter cannot read a further page (has_history_cursor is false). | |
| BrokerError | history_page_limit (int pages) |
| Makes the incomplete-history error for a history longer than the page limit. | |
Variables | |
| constexpr std::size_t | default_series_capacity = 512 |
| The number of trailing bars per instrument a bound runner keeps by default. | |
Connects a runner to a broker session for live trading.
| using algotradelib::live::BoundRunner |
The runner type bind returns.
| Strategy | The strategy type. |
| Session | The broker session type. |
| using algotradelib::live::JournaledRunner |
The runner type bind_journaled returns: the same pipeline, journaling before it sends.
| Strategy | The strategy type. |
| Session | The broker session type. |
| Journal | The journal type (such as runner::FileJournal). |
| Clock | The clock journal lines are stamped with. |
| using algotradelib::live::ObservingRunner |
The runner type bind_observer returns: the same capabilities and tag, sending nowhere.
| Strategy | The strategy type. |
| Session | The broker session type. |
| BoundRunner< Strategy, Session > algotradelib::live::bind | ( | Session & | session, |
| Strategy | strategy, | ||
| strategy::RiskLimits | limits = {}, | ||
| std::size_t | series_capacity = default_series_capacity, | ||
| Venue | default_route = Venue::UNSPECIFIED ) |
Binds a strategy to a broker session, so its instructions are sent to the broker.
This can place orders. bind_observer is the same pipeline with nowhere to send. The runner requires holdings to have been read before it places (see Runner::allow_absent_portfolio for a run that reads none).
| Strategy | The strategy type. |
| Session | The broker session type. |
| session | The session; borrowed, and must outlive the runner. |
| strategy | The strategy. |
| limits | The risk limits. |
| series_capacity | How many trailing bars each cached series keeps. |
| default_route | The venue for an order that names none, which is every order a strategy plans. UNSPECIFIED takes the broker's own default; Kiwoom has none, so a Kiwoom runner places nothing until a route is given here. See SessionExecutor::default_route. |
Definition at line 71 of file bind.hpp.
Referenced by bind().
| JournaledRunner< Strategy, Session, Journal, Clock > algotradelib::live::bind_journaled | ( | Session & | session, |
| Journal & | journal, | ||
| Strategy | strategy, | ||
| strategy::RiskLimits | limits = {}, | ||
| std::size_t | series_capacity = default_series_capacity, | ||
| Venue | default_route = Venue::UNSPECIFIED, | ||
| Clock | clock = {} ) |
Binds a strategy to a broker session, recording every instruction in a journal before it is sent.
Use this rather than building a runner::JournalingExecutor yourself: bind makes its own executor, so a journaling executor built beside it would never be used, and nothing would report it.
The runner is serialized (runner::Runner::serialized): one order per instrument until holdings account for it. Call runner::recover_runner with the journal before trading, on every start: it restores what a previous process left owed, and the runner places nothing until it has run. To keep several orders on one instrument outstanding instead, call allow_overlapping_orders first.
| Strategy | The strategy type. |
| Session | The broker session type. |
| Journal | The journal type. |
| Clock | The clock journal lines are stamped with. |
| session | The session; borrowed, and must outlive the runner. |
| journal | The journal; borrowed, and must outlive the runner. |
| strategy | The strategy. |
| limits | The risk limits. |
| series_capacity | How many trailing bars each cached series keeps. |
| default_route | As for bind; the journal records the route the order is sent with (SessionExecutor::effective_route, such as KRX for an unspecified KIS order). |
| clock | The clock journal lines are stamped with, and recovery's history sweep later asks the broker about. Give the loop's clock when it is not the wall clock (a paper broker over stored history, a test): through a runner::ClockReference unless copies of it read the same time. |
Definition at line 137 of file bind.hpp.
Referenced by bind_journaled().
| ObservingRunner< Strategy, Session > algotradelib::live::bind_observer | ( | Session & | session, |
| Strategy | strategy, | ||
| strategy::RiskLimits | limits = {}, | ||
| std::size_t | series_capacity = default_series_capacity ) |
Binds a strategy for observation: the session's capabilities and broker tag, and nothing to send through.
A capability-gated strategy compiles the same branch as it would live. Nothing can be sent because the runner has no executor that reaches a broker; its reports list what would have been sent.
| Strategy | The strategy type. |
| Session | The broker session type. |
| session | The session; only its type is used. |
| strategy | The strategy. |
| limits | The risk limits. |
| series_capacity | How many trailing bars each cached series keeps. |
Definition at line 175 of file bind.hpp.
Referenced by bind_observer().
|
inline |
Makes the incomplete-history error for a broker whose adapter cannot read a further page (has_history_cursor is false).
Definition at line 65 of file session_source.hpp.
Referenced by history_not_continued(), and algotradelib::live::SessionSource< Session, Journal, MarketData >::read_order_list().
|
inline |
Makes the incomplete-history error for a history longer than the page limit.
| pages | The page limit. |
Definition at line 78 of file session_source.hpp.
Referenced by history_page_limit(), and algotradelib::live::SessionSource< Session, Journal, MarketData >::read_order_list().
|
inline |
Makes the error an order-history read reports when the history is incomplete (a page said there is more, and it was not read).
Its category is PROTOCOL, with reached_broker_ set. Callers treat it as a failed read and conclude nothing from the pages that were read.
| code | The error code. |
| message | The message. |
Definition at line 51 of file session_source.hpp.
Referenced by history_not_continued(), history_page_limit(), and incomplete_history().
|
inlinenoexcept |
Classifies a failed inquiry for a poll.
A rate-limit refusal is not a failure: it does not count toward runner::FailurePolicy's budget. No order instruction was sent, so no failed read needs reconciling.
| error | The error. |
Definition at line 34 of file session_source.hpp.
Referenced by poll_outcome_of(), and algotradelib::live::SessionSource< Session, Journal, MarketData >::read_order_list().