algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::BrokerCaps< Client > Struct Template Reference

What one broker client implements, as compile-time constants. More...

#include <algotradelib/src/core/broker_caps.hpp>

Collaboration diagram for algotradelib::BrokerCaps< Client >:

Public Types

using Traits = BrokerTraits<Client>
 The traits specialization the constants are read from.

Static Public Member Functions

static constexpr bool supports_interval (BarInterval interval)
 Tests whether the broker publishes bars of an interval.

Static Public Attributes

static constexpr bool has_account_discovery = Traits::has_account_discovery
 Whether the broker lists the selectable accounts.
static constexpr bool has_client_order_id = Traits::has_client_order_id
 Whether the broker accepts an idempotency key (OrderRequest::client_order_id_).
static constexpr bool has_working_orders = Traits::has_working_orders
 Whether the broker lists the orders still open to amendment. A listing shows only what the broker's API lists (at Toss, not orders of types placed outside it).
static constexpr bool has_amendable_quantity = Traits::has_amendable_quantity
 Whether the broker reports the quantity still amendable on an open order.
static constexpr bool working_orders_state_terminal = caps_detail::terminal_working_state<Traits>()
 Whether the working-order listing can show a terminal status (filled, cancelled, ...).
static constexpr bool has_trigger_price = Traits::has_trigger_price
 Whether the adapter sends trigger prices (stop-limit orders).
static constexpr bool data_only = Traits::data_only
 Whether the client is a market-data source that takes no orders (built on DataOnlyTraits).
static constexpr bool has_order_by_id = Traits::has_order_by_id
 Whether the broker can look up one order by its id.
static constexpr bool has_partial_cancel = Traits::has_partial_cancel
 Whether the broker can cancel part of an order.
static constexpr bool history_requires_range = Traits::history_requires_range
 Whether an order-history inquiry needs a date range (OrderHistoryQuery::from_).
static constexpr bool has_history_cursor = Traits::has_history_cursor
 Whether an order-history answer can carry a cursor to the next page.
static constexpr bool has_history_limit = Traits::has_history_limit
 Whether an order-history inquiry accepts a row limit (OrderHistoryQuery::limit_).
static constexpr bool has_history_symbol_filter = Traits::has_history_symbol_filter
 Whether an order-history inquiry can filter by symbol.
static constexpr bool has_depth = Traits::has_depth
 Whether the broker publishes the order book (depth).
static constexpr bool has_price_limits = Traits::has_price_limits
 Whether the broker publishes the day's price limits.
static constexpr bool has_trade_prints = Traits::has_trade_prints
 Whether the broker publishes recent trades.
static constexpr bool has_batch_prices = Traits::has_batch_prices
 Whether the broker quotes several instruments in one request.
static constexpr bool has_buying_power = Traits::has_buying_power
 Whether the broker reports buying power.
static constexpr bool has_buying_power_quantity = Traits::has_buying_power_quantity
 Whether the broker can also say how many shares are affordable.
static constexpr SellableSource sellable_source = Traits::sellable_source
 Where the library gets the sellable quantity: HOLDINGS costs nothing, INQUIRY one request per instrument sold, NONE means it is not available.
static constexpr SellableBasis sellable_inquiry_basis = caps_detail::inquiry_basis<Traits>()
 What a sellable figure from the per-instrument inquiry covers.
static constexpr bool has_commission_schedule = Traits::has_commission_schedule
 Whether the broker publishes the account's commission rates.
static constexpr bool has_reference_data = Traits::has_reference_data
 Whether the broker publishes instrument reference data.
static constexpr bool has_batch_reference_data = Traits::has_batch_reference_data
 Whether one reference-data request can cover several instruments.
static constexpr bool has_calendar = Traits::has_calendar
 Whether the broker publishes the trading calendar.
static constexpr bool has_calendar_range = Traits::has_calendar_range
 Whether one calendar request covers a span of dates.
static constexpr bool has_calendar_sessions = Traits::has_calendar_sessions
 Whether the broker publishes intraday session hours (only Toss); the library does not expose them yet.

Detailed Description

template<typename Client>
struct algotradelib::BrokerCaps< Client >

What one broker client implements, as compile-time constants.

Gate broker-specific code with if constexpr on these, so one strategy compiles against every broker. A traits specialization must answer every constant (none has a default); working_orders_state_terminal and sellable_inquiry_basis only where the inquiry they describe exists. ATL_ASSERT_BROKER reads them all.

A capability says the broker implements an operation, not that every account may call it: KIS does not offer its modifiable-order inquiry to demo accounts, so its adapter answers that read from the daily order inquiry there instead.

Template Parameters
ClientThe broker client type.

Definition at line 56 of file broker_caps.hpp.

Member Typedef Documentation

◆ Traits

template<typename Client>
using algotradelib::BrokerCaps< Client >::Traits = BrokerTraits<Client>

The traits specialization the constants are read from.

Definition at line 58 of file broker_caps.hpp.

Member Function Documentation

◆ supports_interval()

template<typename Client>
constexpr bool algotradelib::BrokerCaps< Client >::supports_interval ( BarInterval interval)
inlinestaticconstexpr

Tests whether the broker publishes bars of an interval.

KIS and Toss both publish minute and daily bars; only KIS publishes weekly, monthly and yearly. An interval a broker does not publish is refused, not aggregated from shorter bars.

Parameters
intervalThe interval.
Returns
true if the broker publishes it.

Definition at line 204 of file broker_caps.hpp.

Member Data Documentation

◆ data_only

template<typename Client>
bool algotradelib::BrokerCaps< Client >::data_only = Traits::data_only
staticconstexpr

Whether the client is a market-data source that takes no orders (built on DataOnlyTraits).

Binding such a client as the trading session of live::SessionExecutor or live::SessionSource does not compile. Calling place or holdings on its session directly fails at run time.

Definition at line 100 of file broker_caps.hpp.

◆ has_account_discovery

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_account_discovery = Traits::has_account_discovery
staticconstexpr

Whether the broker lists the selectable accounts.

Definition at line 61 of file broker_caps.hpp.

Referenced by algotradelib::BlockingSession< Client >::accounts(), algotradelib::async_accounts(), and algotradelib::list_accounts().

◆ has_amendable_quantity

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_amendable_quantity = Traits::has_amendable_quantity
staticconstexpr

Whether the broker reports the quantity still amendable on an open order.

Definition at line 73 of file broker_caps.hpp.

◆ has_batch_prices

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_batch_prices = Traits::has_batch_prices
staticconstexpr

Whether the broker quotes several instruments in one request.

Definition at line 138 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_prices(), and algotradelib::BlockingSession< Client >::prices().

◆ has_batch_reference_data

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_batch_reference_data = Traits::has_batch_reference_data
staticconstexpr

Whether one reference-data request can cover several instruments.

Toss takes up to 200 symbols; KIS one. The port asks for one; use session.client() for more.

Definition at line 176 of file broker_caps.hpp.

◆ has_buying_power

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_buying_power = Traits::has_buying_power
staticconstexpr

Whether the broker reports buying power.

Definition at line 141 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_buying_power(), and algotradelib::BlockingSession< Client >::buying_power().

◆ has_buying_power_quantity

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_buying_power_quantity = Traits::has_buying_power_quantity
staticconstexpr

Whether the broker can also say how many shares are affordable.

true for Kiwoom (per margin tier), false for Toss and KIS. The port returns only the amount; reach the quantity through session.client().

Definition at line 149 of file broker_caps.hpp.

◆ has_calendar

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_calendar = Traits::has_calendar
staticconstexpr

Whether the broker publishes the trading calendar.

Definition at line 179 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_calendar(), and algotradelib::BlockingSession< Client >::calendar().

◆ has_calendar_range

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_calendar_range = Traits::has_calendar_range
staticconstexpr

Whether one calendar request covers a span of dates.

KIS answers from a base date onward; Toss answers the requested day and the trading day either side.

Definition at line 187 of file broker_caps.hpp.

◆ has_calendar_sessions

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_calendar_sessions = Traits::has_calendar_sessions
staticconstexpr

Whether the broker publishes intraday session hours (only Toss); the library does not expose them yet.

Definition at line 193 of file broker_caps.hpp.

◆ has_client_order_id

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_client_order_id = Traits::has_client_order_id
staticconstexpr

Whether the broker accepts an idempotency key (OrderRequest::client_order_id_).

Definition at line 64 of file broker_caps.hpp.

◆ has_commission_schedule

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_commission_schedule = Traits::has_commission_schedule
staticconstexpr

Whether the broker publishes the account's commission rates.

Definition at line 166 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_commissions(), and algotradelib::BlockingSession< Client >::commissions().

◆ has_depth

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_depth = Traits::has_depth
staticconstexpr

Whether the broker publishes the order book (depth).

Definition at line 129 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_depth(), and algotradelib::BlockingSession< Client >::depth().

◆ has_history_cursor

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_history_cursor = Traits::has_history_cursor
staticconstexpr

Whether an order-history answer can carry a cursor to the next page.

When false, the adapter returns the whole history in one answer.

Definition at line 116 of file broker_caps.hpp.

◆ has_history_limit

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_history_limit = Traits::has_history_limit
staticconstexpr

Whether an order-history inquiry accepts a row limit (OrderHistoryQuery::limit_).

false for KIS, which refuses a query with a limit (INVALID_ARGUMENT, before any I/O).

Definition at line 123 of file broker_caps.hpp.

◆ has_history_symbol_filter

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_history_symbol_filter = Traits::has_history_symbol_filter
staticconstexpr

Whether an order-history inquiry can filter by symbol.

Definition at line 126 of file broker_caps.hpp.

◆ has_order_by_id

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_order_by_id = Traits::has_order_by_id
staticconstexpr

Whether the broker can look up one order by its id.

Definition at line 103 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_order(), and algotradelib::BlockingSession< Client >::order().

◆ has_partial_cancel

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_partial_cancel = Traits::has_partial_cancel
staticconstexpr

Whether the broker can cancel part of an order.

Definition at line 106 of file broker_caps.hpp.

◆ has_price_limits

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_price_limits = Traits::has_price_limits
staticconstexpr

Whether the broker publishes the day's price limits.

Definition at line 132 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_price_limits(), and algotradelib::BlockingSession< Client >::price_limits().

◆ has_reference_data

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_reference_data = Traits::has_reference_data
staticconstexpr

Whether the broker publishes instrument reference data.

Definition at line 169 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_instrument(), and algotradelib::BlockingSession< Client >::instrument().

◆ has_trade_prints

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_trade_prints = Traits::has_trade_prints
staticconstexpr

Whether the broker publishes recent trades.

Definition at line 135 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_trades(), and algotradelib::BlockingSession< Client >::trades().

◆ has_trigger_price

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_trigger_price = Traits::has_trigger_price
staticconstexpr

Whether the adapter sends trigger prices (stop-limit orders).

When false, BrokerSession refuses a placement or modification carrying a trigger (unsupported_trigger_price) before the adapter runs; cancellations are unaffected. true for KIS and Kiwoom, false for Toss.

Definition at line 91 of file broker_caps.hpp.

◆ has_working_orders

template<typename Client>
bool algotradelib::BrokerCaps< Client >::has_working_orders = Traits::has_working_orders
staticconstexpr

Whether the broker lists the orders still open to amendment. A listing shows only what the broker's API lists (at Toss, not orders of types placed outside it).

Definition at line 70 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_working_orders(), and algotradelib::BlockingSession< Client >::working_orders().

◆ history_requires_range

template<typename Client>
bool algotradelib::BrokerCaps< Client >::history_requires_range = Traits::history_requires_range
staticconstexpr

Whether an order-history inquiry needs a date range (OrderHistoryQuery::from_).

Definition at line 109 of file broker_caps.hpp.

◆ sellable_inquiry_basis

template<typename Client>
SellableBasis algotradelib::BrokerCaps< Client >::sellable_inquiry_basis = caps_detail::inquiry_basis<Traits>()
staticconstexpr

What a sellable figure from the per-instrument inquiry covers.

Set only where sellable_source is INQUIRY (unestablished otherwise). If unestablished, checked sells are refused.

Definition at line 163 of file broker_caps.hpp.

◆ sellable_source

template<typename Client>
SellableSource algotradelib::BrokerCaps< Client >::sellable_source = Traits::sellable_source
staticconstexpr

Where the library gets the sellable quantity: HOLDINGS costs nothing, INQUIRY one request per instrument sold, NONE means it is not available.

Definition at line 155 of file broker_caps.hpp.

Referenced by algotradelib::BrokerSession< Client >::async_sellable_quantity(), and algotradelib::BlockingSession< Client >::sellable_quantity().

◆ working_orders_state_terminal

template<typename Client>
bool algotradelib::BrokerCaps< Client >::working_orders_state_terminal = caps_detail::terminal_working_state<Traits>()
staticconstexpr

Whether the working-order listing can show a terminal status (filled, cancelled, ...).

false for KIS, Toss and Kiwoom: their listings show only open orders. Then an order that leaves the listing has no terminal on_order_update; read its outcome from holdings or an order inquiry instead of waiting for one. false here when has_working_orders is false.

Definition at line 82 of file broker_caps.hpp.


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