algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::kis::KisBlockingClient Class Reference

A blocking KIS client: each call runs a KisClient request on a private event loop and returns its result. Not thread-safe. More...

#include <algotradelib/src/brokers/kis/client.hpp>

Public Member Functions

 KisBlockingClient (ssl::context &context, KisConfig config, network::HttpClientOptions options={})
 Constructs a client.
Result< QuoteSnapshot > quote (InstrumentId instrument)
 Returns a quote; see KisClient::async_quote.
Result< Instrument > instrument (InstrumentId subject)
 Returns an instrument's reference data.
Result< TradingCalendar > calendar (Date from, bool refresh=false)
 Returns the trading calendar from a date on; see KisClient::async_calendar (cached).
Result< PriceLimits > price_limits (InstrumentId instrument)
 Returns an instrument's price band for today.
Result< std::vector< TradePrint > > trades (InstrumentId instrument, int count)
 Returns an instrument's recent trades.
Result< DepthSnapshot > depth (InstrumentId instrument)
 Returns the order book (ten levels a side).
Result< BarSeries > bars (BarQuery query)
 Returns bars; see KisClient::async_bars.
Result< HoldingsSnapshot > holdings (KisAccount account)
 Returns the account's holdings.
Result< BuyingPower > buying_power (Currency currency, KisAccount account)
 Returns the account's buying power, in won.
Result< KisOrderAck > place_order (KisAccount account, OrderRequest order)
 Places a cash order; see KisClient::async_place_order.
Result< KisOrderAck > replace_order (KisAccount account, KisAmendment amendment)
 Amends an order's price or quantity; the outcome can be unknown after an error (see KisClient::async_replace_order).
Result< KisOrderAck > cancel_order (KisAccount account, KisAmendment amendment)
 Cancels an order; the outcome can be unknown after an error, and the order may still rest (see KisClient::async_cancel_order).
Result< KisOpenOrderPage > open_orders (KisAccount account)
 Returns the orders that can still be amended or cancelled; see KisClient::async_open_orders (including how demo accounts are answered).
Result< OrderPage > order_history (KisAccount account, KisHistoryRange range)
 Returns the orders placed over a date range, with their fills.
const network::RateLimitStats * rate_limit_stats () const
 Returns the rate limiter's statistics (safe to read between calls).
KisRest token () const
 Returns the access token; see KisClient::token.
bool adopt_token (KisRest token)
 Uses a token issued earlier; see KisClient::adopt_token.

Detailed Description

A blocking KIS client: each call runs a KisClient request on a private event loop and returns its result. Not thread-safe.

A call whose loop stops before the request completes returns a TRANSPORT error (event_loop_stopped).

Definition at line 4540 of file client.hpp.

Constructor & Destructor Documentation

◆ KisBlockingClient()

algotradelib::kis::KisBlockingClient::KisBlockingClient ( ssl::context & context,
KisConfig config,
network::HttpClientOptions options = {} )
inline

Constructs a client.

Parameters
contextThe TLS context; borrowed, and must outlive the client.
configThe credentials and environment.
optionsHTTP options.

Definition at line 4548 of file client.hpp.

Member Function Documentation

◆ adopt_token()

bool algotradelib::kis::KisBlockingClient::adopt_token ( KisRest token)
inline

Uses a token issued earlier; see KisClient::adopt_token.

Parameters
tokenThe token.
Returns
false if the token is empty or expires within five minutes.

Definition at line 4769 of file client.hpp.

◆ bars()

Result< BarSeries > algotradelib::kis::KisBlockingClient::bars ( BarQuery query)
inline

Returns bars; see KisClient::async_bars.

Parameters
queryThe query.
Returns
The bars or an error.

Definition at line 4636 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::bars().

◆ buying_power()

Result< BuyingPower > algotradelib::kis::KisBlockingClient::buying_power ( Currency currency,
KisAccount account )
inline

Returns the account's buying power, in won.

Parameters
currencyThe currency; anything but KRW is refused before sending.
accountThe account.
Returns
The buying power or an error.

Definition at line 4661 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::buying_power().

◆ calendar()

Result< TradingCalendar > algotradelib::kis::KisBlockingClient::calendar ( Date from,
bool refresh = false )
inline

Returns the trading calendar from a date on; see KisClient::async_calendar (cached).

Parameters
fromThe first date; an invalid date is refused (invalid_date) before sending.
refreshtrue to request again even if the cache covers from.
Returns
The calendar or an error.

Definition at line 4585 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::calendar().

◆ cancel_order()

Result< KisOrderAck > algotradelib::kis::KisBlockingClient::cancel_order ( KisAccount account,
KisAmendment amendment )
inline

Cancels an order; the outcome can be unknown after an error, and the order may still rest (see KisClient::async_cancel_order).

Parameters
accountThe account.
amendmentThe order and quantity.
Returns
The acknowledgement or an error.

Definition at line 4713 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::cancel_order().

◆ depth()

Result< DepthSnapshot > algotradelib::kis::KisBlockingClient::depth ( InstrumentId instrument)
inline

Returns the order book (ten levels a side).

Parameters
instrumentThe instrument.
Returns
The book or an error.

Definition at line 4624 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::depth().

◆ holdings()

Result< HoldingsSnapshot > algotradelib::kis::KisBlockingClient::holdings ( KisAccount account)
inline

Returns the account's holdings.

Parameters
accountThe account.
Returns
The holdings or an error.

Definition at line 4648 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::holdings().

◆ instrument()

Result< Instrument > algotradelib::kis::KisBlockingClient::instrument ( InstrumentId subject)
inline

Returns an instrument's reference data.

Parameters
subjectThe instrument.
Returns
The data or an error.

Definition at line 4572 of file client.hpp.

Referenced by depth(), algotradelib::BrokerTraits< kis::KisBlockingClient >::instrument(), price_limits(), quote(), and trades().

◆ open_orders()

Result< KisOpenOrderPage > algotradelib::kis::KisBlockingClient::open_orders ( KisAccount account)
inline

Returns the orders that can still be amended or cancelled; see KisClient::async_open_orders (including how demo accounts are answered).

Parameters
accountThe account.
Returns
The orders or an error.

Definition at line 4728 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::working_orders().

◆ order_history()

Result< OrderPage > algotradelib::kis::KisBlockingClient::order_history ( KisAccount account,
KisHistoryRange range )
inline

Returns the orders placed over a date range, with their fills.

Parameters
accountThe account.
rangeThe dates (an invalid range, or to_ before from_, is refused before sending).
Returns
The orders or an error.

Definition at line 4741 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::order_history().

◆ place_order()

Result< KisOrderAck > algotradelib::kis::KisBlockingClient::place_order ( KisAccount account,
OrderRequest order )
inline

Places a cash order; see KisClient::async_place_order.

Never resent. After an error of unknown outcome (see KisClient::async_place_order), read open_orders() or order_history() before placing again.

Parameters
accountThe account.
orderThe order.
Returns
The acknowledgement or an error.

Definition at line 4681 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::place_order().

◆ price_limits()

Result< PriceLimits > algotradelib::kis::KisBlockingClient::price_limits ( InstrumentId instrument)
inline

Returns an instrument's price band for today.

Parameters
instrumentThe instrument.
Returns
The band or an error.

Definition at line 4597 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::price_limits().

◆ quote()

Result< QuoteSnapshot > algotradelib::kis::KisBlockingClient::quote ( InstrumentId instrument)
inline

Returns a quote; see KisClient::async_quote.

Parameters
instrumentThe instrument.
Returns
The quote or an error.

Definition at line 4560 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::quote().

◆ rate_limit_stats()

const network::RateLimitStats * algotradelib::kis::KisBlockingClient::rate_limit_stats ( ) const
inline

Returns the rate limiter's statistics (safe to read between calls).

Returns
The statistics, or null if the client has no rate-limit budget.

Definition at line 4754 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::rate_limit_stats().

◆ replace_order()

Result< KisOrderAck > algotradelib::kis::KisBlockingClient::replace_order ( KisAccount account,
KisAmendment amendment )
inline

Amends an order's price or quantity; the outcome can be unknown after an error (see KisClient::async_replace_order).

Parameters
accountThe account.
amendmentThe amendment.
Returns
The acknowledgement or an error.

Definition at line 4697 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::replace_order().

◆ token()

KisRest algotradelib::kis::KisBlockingClient::token ( ) const
inline

Returns the access token; see KisClient::token.

Returns
The token, empty until a request has obtained one.

Definition at line 4762 of file client.hpp.

Referenced by adopt_token().

◆ trades()

Result< std::vector< TradePrint > > algotradelib::kis::KisBlockingClient::trades ( InstrumentId instrument,
int count )
inline

Returns an instrument's recent trades.

Parameters
instrumentThe instrument.
countThe most trades to return (zero or less: the whole window).
Returns
The trades or an error.

Definition at line 4610 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::trades().


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