3#include "./broker_caps.hpp"
4#include "./broker_session.hpp"
5#include "./broker_traits.hpp"
7#include <boost/asio/use_future.hpp>
78template <
typename Client,
typename Token>
90 if constexpr (Caps::has_buying_power) {
96 if constexpr (Caps::has_commission_schedule) {
99 if constexpr (Caps::has_working_orders) {
102 if constexpr (Caps::has_reference_data) {
105 if constexpr (Caps::has_calendar) {
108 if constexpr (Caps::has_price_limits) {
111 if constexpr (Caps::has_trade_prints) {
114 if constexpr (Caps::has_batch_prices) {
117 if constexpr (Caps::has_depth) {
120 if constexpr (Caps::has_order_by_id) {
123 if constexpr (Caps::has_account_discovery) {
134template <
typename Client>
140 static_cast<void>(session.
holdings());
146 if constexpr (Caps::has_buying_power) {
152 if constexpr (Caps::has_commission_schedule) {
155 if constexpr (Caps::has_working_orders) {
158 if constexpr (Caps::has_reference_data) {
161 if constexpr (Caps::has_calendar) {
162 static_cast<void>(session.
calendar(Country::KR));
164 if constexpr (Caps::has_price_limits) {
167 if constexpr (Caps::has_trade_prints) {
170 if constexpr (Caps::has_batch_prices) {
173 if constexpr (Caps::has_depth) {
176 if constexpr (Caps::has_order_by_id) {
177 static_cast<void>(session.
order(ref));
179 if constexpr (Caps::has_account_discovery) {
180 static_cast<void>(session.
accounts());
190template <
typename Client>
213#define ATL_ASSERT_BROKER(Client) \
215 ::algotradelib::conformance::claimed_verbs_compile<Client>() && \
216 ::algotradelib::answers_every_capability<Client>(), \
217 "every port verb this client's capabilities claim must compile, and every capability " \
A blocking broker client bound to one account, with the same broker operations as BrokerSession,...
Result< OrderPage > order_history(const OrderHistoryQuery &query)
Returns order history: placed orders and their executions.
Result< Placed > place(OrderRequest order)
Places a new order.
Result< WorkingSet > working_orders()
Returns the orders still open to modification or cancellation; requires Caps::has_working_orders.
Result< OrderSnapshot > order(const Ref &ref)
Returns one order by its reference; requires Caps::has_order_by_id.
Result< BarSeries > bars(BarQuery query)
Returns bars for an instrument, oldest first, paging until count_ bars are read.
Result< QuoteSnapshot > quote(InstrumentId instrument)
Returns the current quote for an instrument.
Result< Placed > replace(const Ref &ref, const AmendInstruction &instruction)
Modifies a working order.
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< BuyingPower > buying_power(Currency currency)
Returns what the account may spend in a currency; requires Caps::has_buying_power.
Result< Placed > cancel(const Ref &ref, const AmendInstruction &instruction)
Cancels a working order, in full or in part.
Result< HoldingsSnapshot > holdings()
Returns the account's holdings.
Result< Decimal64 > sellable_quantity(InstrumentId instrument)
Returns how much of an instrument the account may sell; only where Caps::sellable_source is INQUIRY.
Client & client() noexcept
Returns the broker client, for broker-specific operations the session does not offer.
OrderRef< BrokerTag > Ref
The order reference type this session issues and accepts.
Result< DepthSnapshot > depth(InstrumentId instrument)
Returns an instrument's order book, best levels first; requires Caps::has_depth.
Result< TradingCalendar > calendar(Country country, std::optional< Date > from=std::nullopt)
Returns the trading calendar; requires Caps::has_calendar.
Result< CommissionSchedule > commissions()
Returns the account's commission rates; requires Caps::has_commission_schedule.
Result< std::vector< QuoteSnapshot > > prices(std::vector< InstrumentId > instruments)
Returns quotes for several instruments in one request; requires Caps::has_batch_prices.
Result< Instrument > instrument(InstrumentId subject)
Returns an instrument's reference data; requires Caps::has_reference_data.
Result< std::vector< AccountInfo< Client > > > accounts()
Lists the broker's accounts; requires Caps::has_account_discovery.
An asynchronous broker client bound to one account, with broker-neutral operations.
auto async_quote(InstrumentId instrument, CompletionToken &&token)
Requests the current quote for an instrument.
auto async_order_history(OrderHistoryQuery query, CompletionToken &&token)
Requests order history: placed orders and their executions.
OrderRef< BrokerTag > Ref
The order reference type this session issues and accepts.
auto async_place(OrderRequest order, CompletionToken &&token)
Places a new order.
auto async_bars(BarQuery query, CompletionToken &&token)
Requests bars for an instrument, paging until count_ bars are read.
auto async_sellable_quantity(InstrumentId instrument, CompletionToken &&token)
Requests how much of an instrument the account may sell.
auto async_buying_power(Currency currency, CompletionToken &&token)
Requests what the account may spend in a currency.
auto async_price_limits(InstrumentId instrument, CompletionToken &&token)
Requests an instrument's price limits for today.
Client & client() noexcept
Returns the broker client, for broker-specific operations the session does not offer.
auto async_replace(Ref ref, AmendInstruction instruction, CompletionToken &&token)
Modifies a working order.
auto async_commissions(CompletionToken &&token)
Requests the account's commission rates.
auto async_instrument(InstrumentId instrument, CompletionToken &&token)
Requests an instrument's reference data.
auto async_holdings(CompletionToken &&token)
Requests the account's holdings.
auto async_working_orders(CompletionToken &&token)
Requests the orders still open to modification or cancellation.
auto async_trades(InstrumentId instrument, int count, CompletionToken &&token)
Requests recent trades for an instrument, newest first.
auto async_order(Ref ref, CompletionToken &&token)
Requests one order by its reference.
auto async_prices(std::vector< InstrumentId > instruments, CompletionToken &&token)
Requests quotes for several instruments in one request.
auto async_cancel(Ref ref, AmendInstruction instruction, CompletionToken &&token)
Cancels a working order, in full or in part.
auto async_calendar(Country country, std::optional< Date > from, CompletionToken &&token)
Requests the trading calendar.
auto async_depth(InstrumentId instrument, CompletionToken &&token)
Requests an instrument's order book, best levels first.
A three-letter currency code, such as KRW or USD (ISO 4217 style).
The library: broker-neutral types (core), and the modules below.
auto async_accounts(Client &client, CompletionToken &&token)
Lists a broker's accounts, before a session exists; requires BrokerCaps<Client>::has_account_discover...
Result< std::vector< AccountInfo< Client > > > list_accounts(Client &client)
Lists a broker's accounts with a blocking client, before a session exists; requires BrokerCaps<Client...
@ INQUIRY
From a per-instrument inquiry, made only where the snapshot has no figure.
A modification or cancellation of a working order.
What one broker client implements, as compile-time constants.
Describes one broker client to the library: its types, capabilities, call thunks and normalizers.
Identifies an instrument: its country, venue and symbol.
The filter for an order-history inquiry.
An order to place, in broker-neutral form.