![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
A blocking broker client bound to one account, with the same broker operations as BrokerSession, plus accounts(). More...
#include <algotradelib/src/core/broker_session.hpp>
Public Types | |
| using | Traits = BrokerTraits<Client> |
| The client's traits. | |
| using | Caps = BrokerCaps<Client> |
| The client's capabilities. | |
| using | Account = typename Traits::Account |
| The broker's account selector type. | |
| using | Config = typename Traits::Config |
| The broker's configuration type. | |
| using | BrokerTag = typename Traits::BrokerTag |
| The broker's tag type. | |
| using | Ref = OrderRef<BrokerTag> |
| The order reference type this session issues and accepts. | |
| using | Placed = PlacedOrder<BrokerTag> |
| What an order-writing call returns: acknowledgement and reference. | |
| using | Working = WorkingOrder<BrokerTag> |
| One working order of this broker. | |
| using | WorkingSet = WorkingOrders<BrokerTag> |
| A working-order listing of this broker. | |
Public Member Functions | |
| BlockingSession (std::shared_ptr< Client > client, Account account) | |
| Binds a blocking client and an account. | |
| const Account & | account () const noexcept |
| Returns the bound account. | |
| Client & | client () noexcept |
| Returns the broker client, for broker-specific operations the session does not offer. | |
| const Client & | client () const noexcept |
| Returns the broker client. | |
| const network::RateLimitStats * | rate_limit_stats () const |
| Returns the client's request-pacing counters. | |
| Result< QuoteSnapshot > | quote (InstrumentId instrument) |
| Returns the current quote for an instrument. | |
| Result< HoldingsSnapshot > | holdings () |
| Returns the account's holdings. | |
| Result< BuyingPower > | buying_power (Currency currency) |
| Returns what the account may spend in a currency; requires Caps::has_buying_power. | |
| Result< Decimal64 > | sellable_quantity (InstrumentId instrument) |
| Returns how much of an instrument the account may sell; only where Caps::sellable_source is INQUIRY. | |
| Result< CommissionSchedule > | commissions () |
| Returns the account's commission rates; requires Caps::has_commission_schedule. | |
| Result< Instrument > | instrument (InstrumentId subject) |
| Returns an instrument's reference data; requires Caps::has_reference_data. | |
| Result< TradingCalendar > | calendar (Country country, std::optional< Date > from=std::nullopt) |
| Returns the trading calendar; requires Caps::has_calendar. | |
| Result< PriceLimits > | price_limits (InstrumentId instrument) |
| Returns an instrument's price limits for today; requires Caps::has_price_limits. | |
| Result< std::vector< TradePrint > > | trades (InstrumentId instrument, int count) |
| Returns recent trades for an instrument, newest first; requires Caps::has_trade_prints. | |
| Result< std::vector< QuoteSnapshot > > | prices (std::vector< InstrumentId > instruments) |
| Returns quotes for several instruments in one request; requires Caps::has_batch_prices. | |
| Result< DepthSnapshot > | depth (InstrumentId instrument) |
| Returns an instrument's order book, best levels first; requires Caps::has_depth. | |
| Result< BarSeries > | bars (BarQuery query) |
| Returns bars for an instrument, oldest first, paging until count_ bars are read. | |
| Result< Placed > | place (OrderRequest order) |
| Places a new order. | |
| Result< Placed > | replace (const Ref &ref, const AmendInstruction &instruction) |
| Modifies a working order. | |
| Result< Placed > | cancel (const Ref &ref, const AmendInstruction &instruction) |
| Cancels a working order, in full or in part. | |
| Result< WorkingSet > | working_orders () |
| Returns the orders still open to modification or cancellation; requires Caps::has_working_orders. | |
| Result< OrderPage > | order_history (const OrderHistoryQuery &query) |
| Returns order history: placed orders and their executions. | |
| Result< OrderSnapshot > | order (const Ref &ref) |
| Returns one order by its reference; requires Caps::has_order_by_id. | |
| Result< std::vector< AccountInfo< Client > > > | accounts () |
| Lists the broker's accounts; requires Caps::has_account_discovery. | |
Static Public Member Functions | |
| static constexpr std::string_view | broker_name () noexcept |
| Returns the broker's name. | |
A blocking broker client bound to one account, with the same broker operations as BrokerSession, plus accounts().
Every operation returns Result<T>. An operation the broker does not offer does not compile.
| Client | A blocking broker client (BrokerTraits<Client>::blocking is true). |
Definition at line 862 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Account = typename Traits::Account |
The broker's account selector type.
Definition at line 871 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::BrokerTag = typename Traits::BrokerTag |
The broker's tag type.
Definition at line 877 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Caps = BrokerCaps<Client> |
The client's capabilities.
Definition at line 868 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Config = typename Traits::Config |
The broker's configuration type.
Definition at line 874 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Placed = PlacedOrder<BrokerTag> |
What an order-writing call returns: acknowledgement and reference.
Definition at line 883 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Ref = OrderRef<BrokerTag> |
The order reference type this session issues and accepts.
Definition at line 880 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Traits = BrokerTraits<Client> |
The client's traits.
Definition at line 865 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::Working = WorkingOrder<BrokerTag> |
One working order of this broker.
Definition at line 886 of file broker_session.hpp.
| using algotradelib::BlockingSession< Client >::WorkingSet = WorkingOrders<BrokerTag> |
A working-order listing of this broker.
Definition at line 889 of file broker_session.hpp.
|
inline |
Binds a blocking client and an account.
| client | The client; must not be null. |
| account | The account to act for. |
| std::invalid_argument | if client is null. |
Definition at line 903 of file broker_session.hpp.
|
inlinenoexcept |
Returns the bound account.
Definition at line 920 of file broker_session.hpp.
Referenced by BlockingSession().
|
inline |
Lists the broker's accounts; requires Caps::has_account_discovery.
Definition at line 1246 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns bars for an instrument, oldest first, paging until count_ bars are read.
| query | What to fetch. |
Definition at line 1125 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inlinestaticconstexprnoexcept |
|
inline |
Returns what the account may spend in a currency; requires Caps::has_buying_power.
| currency | The currency. |
Definition at line 967 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the trading calendar; requires Caps::has_calendar.
| country | The market. |
| from | The date the answer is anchored to; empty means today. |
Definition at line 1036 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Cancels a working order, in full or in part.
| ref | The order. |
| instruction | Build it with cancel_all or cancel_quantity; the session's has_trigger_price check does not apply, though the adapter still validates it. |
Definition at line 1185 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inlinenoexcept |
|
inlinenoexcept |
Returns the broker client, for broker-specific operations the session does not offer.
Definition at line 926 of file broker_session.hpp.
Referenced by BlockingSession(), and algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the account's commission rates; requires Caps::has_commission_schedule.
Definition at line 1001 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns an instrument's order book, best levels first; requires Caps::has_depth.
| instrument | The instrument. |
Definition at line 1108 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the account's holdings.
Definition at line 960 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns an instrument's reference data; requires Caps::has_reference_data.
| subject | The instrument. |
Definition at line 1018 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs(), depth(), price_limits(), quote(), sellable_quantity(), and trades().
|
inline |
Returns one order by its reference; requires Caps::has_order_by_id.
| ref | The order. |
Definition at line 1229 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs(), and place().
|
inline |
Returns order history: placed orders and their executions.
| query | The filter. |
Definition at line 1216 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Places a new order.
| order | The order; refused before any I/O as for BrokerSession::async_place. |
Definition at line 1143 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns an instrument's price limits for today; requires Caps::has_price_limits.
| instrument | The instrument. |
Definition at line 1056 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns quotes for several instruments in one request; requires Caps::has_batch_prices.
| instruments | The instruments. |
Definition at line 1091 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the current quote for an instrument.
| instrument | The instrument. |
Definition at line 952 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the client's request-pacing counters.
A rising delayed_ on a polling group while TRADING stays undelayed means trading capacity is being kept free; a rising shed_ means the queue was full or the budget is too slow for the timeout. Safe to read between calls.
Definition at line 943 of file broker_session.hpp.
|
inline |
Modifies a working order.
| ref | The order. |
| instruction | What to change; build it with replace_with or reprice. |
Definition at line 1162 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns how much of an instrument the account may sell; only where Caps::sellable_source is INQUIRY.
| instrument | The instrument. |
Definition at line 984 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns recent trades for an instrument, newest first; requires Caps::has_trade_prints.
| instrument | The instrument. |
| count | How many trades to request. |
Definition at line 1074 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().
|
inline |
Returns the orders still open to modification or cancellation; requires Caps::has_working_orders.
Definition at line 1199 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs().