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

The Korea Investment & Securities (KIS) Open API client. More...

Classes

struct  Broker
 The KIS broker tag: order references are typed by it, so a KIS reference works with both KIS clients and with no other broker. More...
struct  KisAccount
 A KIS account: the account number and product code every account request names. More...
struct  KisAmendment
 An amendment or cancellation of a KIS order. More...
class  KisAuth
 Obtains and caches KIS access tokens and WebSocket approval keys with blocking requests; thread-safe. More...
class  KisBlockingClient
 A blocking KIS client: each call runs a KisClient request on a private event loop and returns its result. Not thread-safe. More...
class  KisClient
 The asynchronous KIS REST client: market data, account inquiries and orders for domestic stocks. More...
struct  KisConfig
 KIS credentials (app key and secret), demo or real account, and the market-data tape. More...
struct  KisHistoryRange
 The date range of a KIS order-history inquiry, both ends included (Korean dates). More...
struct  KisOpenOrder
 A KIS order that can still be amended or cancelled. More...
struct  KisOpenOrderPage
 KIS's list of orders that can still be amended or cancelled. More...
struct  KisOrderAck
 KIS's acknowledgement of an accepted order, amendment or cancellation. More...
struct  KisOrderRef
 A KIS order's address: branch number and order number, both kept. More...
struct  KisRest
 A KIS REST access token and its expiry. More...
struct  KisWebsocket
 A KIS WebSocket approval key and when it was issued. More...

Typedefs

using KisHttpClient = network::HttpClient
 The blocking HTTP client KisAuth uses.

Enumerations

enum class  KisRateLimitLayer { NONE , LEDGER , PERSONAL }
 Which of KIS's two request-rate limits a refusal reports. More...
enum class  MarketTape { CONSOLIDATED , KRX , NXT }
 Which venue's prices KIS market-data requests read (see KisConfig::market_tape_). More...

Functions

Date today_in_seoul ()
 Returns today's date in Korea (UTC+9), the date KIS requests are made in.
KisRateLimitLayer kis_rate_limit_layer (std::string_view code)
 Classifies a KIS error code as a rate-limit refusal.
std::optional< BrokerError > unsupported_client_order_id (const OrderRequest &order)
 Refuses an idempotency key, which KIS does not offer to individual customers.
constexpr bool publishes_bar_interval (BarInterval interval) noexcept
 Tests whether KIS publishes a chart at an interval.
std::optional< BrokerError > unsupported_bar_interval (BarInterval interval)
 Refuses a bar interval KIS publishes no chart for (publishes_bar_interval).
constexpr const char * market_division_code (MarketTape tape) noexcept
 Returns KIS's FID_COND_MRKT_DIV_CODE for a tape.
static std::chrono::system_clock::time_point parse_expiry (const char *s)
 Reads KIS's token expiry, YYYY-MM-DD HH:MM:SS in Korean time.

Detailed Description

The Korea Investment & Securities (KIS) Open API client.

Typedef Documentation

◆ KisHttpClient

The blocking HTTP client KisAuth uses.

Definition at line 9 of file network.hpp.

Enumeration Type Documentation

◆ KisRateLimitLayer

Which of KIS's two request-rate limits a refusal reports.

Enumerator
NONE 

Not a rate-limit refusal.

LEDGER 

An endpoint's own cap shared by all customers (EGW00215; 120 per second for holdings and ETF quotes). Your budget cannot avoid it; wait and retry.

PERSONAL 

This app key's own per-second limit (EGW00201); lower the budget.

Definition at line 219 of file client.hpp.

◆ MarketTape

enum class algotradelib::kis::MarketTape
strong

Which venue's prices KIS market-data requests read (see KisConfig::market_tape_).

Enumerator
CONSOLIDATED 

KRX and NXT combined (UN).

KRX 

KRX alone (J).

NXT 

NXT alone (NX).

Definition at line 25 of file config.hpp.

Function Documentation

◆ kis_rate_limit_layer()

KisRateLimitLayer algotradelib::kis::kis_rate_limit_layer ( std::string_view code)
inline

Classifies a KIS error code as a rate-limit refusal.

EGW00317 (an endpoint closed for a scheduled window) is not a rate limit.

Parameters
codeKIS's message code.
Returns
PERSONAL for EGW00201, LEDGER for EGW00215, otherwise NONE.

Definition at line 239 of file client.hpp.

Referenced by kis_rate_limit_layer().

◆ market_division_code()

const char * algotradelib::kis::market_division_code ( MarketTape tape)
inlineconstexprnoexcept

Returns KIS's FID_COND_MRKT_DIV_CODE for a tape.

Parameters
tapeThe tape.
Returns
"UN", "J" or "NX".

Definition at line 39 of file config.hpp.

Referenced by market_division_code().

◆ parse_expiry()

std::chrono::system_clock::time_point algotradelib::kis::parse_expiry ( const char * s)
inlinestatic

Reads KIS's token expiry, YYYY-MM-DD HH:MM:SS in Korean time.

Parameters
sThe text.
Returns
The instant, or the epoch if the text does not have that form.

Definition at line 58 of file config.hpp.

Referenced by algotradelib::kis::KisRest::from_json_impl(), and parse_expiry().

◆ publishes_bar_interval()

bool algotradelib::kis::publishes_bar_interval ( BarInterval interval)
inlineconstexprnoexcept

Tests whether KIS publishes a chart at an interval.

Parameters
intervalThe interval.
Returns
true for one minute and for a day or longer; false for 5, 15, 30 and 60 minutes (its minute chart is one minute only).

Definition at line 277 of file client.hpp.

Referenced by publishes_bar_interval(), and unsupported_bar_interval().

◆ today_in_seoul()

Date algotradelib::kis::today_in_seoul ( )
inline

Returns today's date in Korea (UTC+9), the date KIS requests are made in.

Returns
The date.

Definition at line 200 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::calendar(), algotradelib::BrokerTraits< kis::KisClient >::calendar(), and today_in_seoul().

◆ unsupported_bar_interval()

std::optional< BrokerError > algotradelib::kis::unsupported_bar_interval ( BarInterval interval)
inline

Refuses a bar interval KIS publishes no chart for (publishes_bar_interval).

Parameters
intervalThe interval.
Returns
An INVALID_ARGUMENT error (not sent), or std::nullopt.

Definition at line 299 of file client.hpp.

Referenced by unsupported_bar_interval().

◆ unsupported_client_order_id()

std::optional< BrokerError > algotradelib::kis::unsupported_client_order_id ( const OrderRequest & order)
inline

Refuses an idempotency key, which KIS does not offer to individual customers.

Without one, resending after a transport failure can place a second order, so an order carrying client_order_id_ is refused before sending rather than sent without it. confirm_high_value_ is accepted (and ignored).

Parameters
orderThe order.
Returns
An INVALID_ARGUMENT error (idempotency_key_unsupported, not sent) if the order has a client order id, otherwise std::nullopt.

Definition at line 257 of file client.hpp.

Referenced by unsupported_client_order_id().