![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
A blocking Kiwoom client: each call runs a KiwoomClient request on a private event loop and returns its result. Not thread-safe. Order references work with either client. More...
#include <algotradelib/src/brokers/kiwoom/client.hpp>
Public Member Functions | |
| KiwoomBlockingClient (ssl::context &context, KiwoomConfig config, network::HttpClientOptions options={}, std::shared_ptr< network::TokenStore > store=nullptr) | |
| Constructs a client. | |
| Result< QuoteSnapshot > | quote (InstrumentId instrument) |
| Returns the current normalized quote or a structured error. | |
| Result< PriceLimits > | price_limits (InstrumentId instrument) |
| Returns today's upper and lower price bound. | |
| Result< DepthSnapshot > | depth (InstrumentId instrument) |
| Returns the resting orders on both sides of the book. | |
| Result< std::vector< TradePrint > > | trades (InstrumentId instrument, int count) |
| Returns recent executions, newest first. | |
| Result< Instrument > | instrument (InstrumentId subject) |
| Returns static reference data for one instrument. | |
| Result< BarSeries > | bars (BarQuery query) |
| Returns bars; see KiwoomClient::async_bars. | |
| const KiwoomConfig & | config () const noexcept |
| Returns the configuration; see KiwoomClient::config. | |
| Result< HoldingsSnapshot > | holdings (KiwoomAccount account) |
| Returns the holdings for KiwoomConfig::holdings_venue_; see KiwoomClient::async_holdings. | |
| Result< BuyingPower > | buying_power (Currency currency, KiwoomAccount account) |
| Returns what the bound credential's account may spend. | |
| Result< KiwoomDeposit > | deposit () |
| Returns Kiwoom's own fuller deposit detail. | |
| Result< KiwoomOrderableAmount > | orderable_amount (InstrumentId instrument, OrderSide side, std::optional< Decimal64 > price=std::nullopt) |
| Returns what may be ordered of one instrument, per margin tier. | |
| Result< std::vector< KiwoomAccountInfo > > | accounts () |
| Returns the one account the bound credential drives. | |
| Result< KiwoomOrderAck > | place_order (KiwoomAccount account, OrderRequest order) |
| Submits a new order. The outcome can be unknown after an error; see KiwoomClient::async_place_order. | |
| Result< KiwoomOrderAck > | replace_order (KiwoomAccount account, KiwoomAmendment amendment) |
| Modifies an existing order. The outcome can be unknown after an error; see KiwoomClient::async_replace_order. | |
| Result< KiwoomOrderAck > | cancel_order (KiwoomAccount account, KiwoomAmendment amendment) |
| Cancels an existing order. The outcome can be unknown after an error; see KiwoomClient::async_cancel_order. | |
| Result< KiwoomOpenOrderPage > | open_orders (KiwoomAccount account) |
| Returns every order still open to amendment. | |
| Result< OrderPage > | order_history (KiwoomAccount account, KiwoomHistoryQuery query) |
| Returns one day of order history. | |
| void | close () |
| Closes the client for good; see KiwoomClient::close. | |
| const network::RateLimitStats * | rate_limit_stats () const |
| Returns the rate limiter's statistics. | |
| KiwoomRest | token () const |
| Returns the access token; see KiwoomClient::token. | |
| bool | adopt_token (KiwoomRest token) |
| Uses a token issued earlier; see KiwoomClient::adopt_token. | |
Friends | |
| struct | KiwoomClientTestAccess |
A blocking Kiwoom client: each call runs a KiwoomClient request on a private event loop and returns its result. Not thread-safe. Order references work with either client.
A call whose loop stops before the request completes returns a TRANSPORT error (event_loop_stopped).
With a token store, clients on one key and environment share one token, in this process or others (network::TokenStore); a Kiwoom token is bound to the address that requested it, so share it on one machine only. Every token is then requested under the store's lock before a call, and none during it: a call whose token stops being usable while it runs returns token_unusable (AUTHENTICATION, not sent), and the next call prepares one. A request authorized just before another program replaced the token can still be refused; it is not sent again. A program stopped after Kiwoom issued a token and before it was stored leaves the old one stored until Kiwoom refuses it.
Definition at line 3644 of file client.hpp.
|
inline |
Constructs a client.
| context | The TLS context; borrowed, and must outlive the client. |
| config | The credentials and environment. |
| options | HTTP options. |
| store | Where to share the access token (network::TokenStore), or null to keep it to this client. |
Definition at line 3653 of file client.hpp.
|
inline |
Returns the one account the bound credential drives.
Definition at line 3820 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::accounts().
|
inline |
Uses a token issued earlier; see KiwoomClient::adopt_token.
| token | The token. |
Definition at line 3936 of file client.hpp.
Returns bars; see KiwoomClient::async_bars.
| query | The query. |
Definition at line 3739 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::bars().
|
inline |
Returns what the bound credential's account may spend.
| currency | The currency; anything but KRW is refused before sending. |
| account | The bound account. |
Definition at line 3776 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::buying_power().
|
inline |
Cancels an existing order. The outcome can be unknown after an error; see KiwoomClient::async_cancel_order.
| account | The bound account. |
| amendment | The amendment. |
Definition at line 3868 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::cancel_order().
|
inline |
Closes the client for good; see KiwoomClient::close.
Definition at line 3907 of file client.hpp.
|
inlinenoexcept |
Returns the configuration; see KiwoomClient::config.
Definition at line 3752 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::holdings(), and KiwoomBlockingClient().
|
inline |
Returns Kiwoom's own fuller deposit detail.
Definition at line 3789 of file client.hpp.
|
inline |
Returns the resting orders on both sides of the book.
| instrument | The instrument. |
Definition at line 3696 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::depth().
|
inline |
Returns the holdings for KiwoomConfig::holdings_venue_; see KiwoomClient::async_holdings.
| account | The account (empty). |
Definition at line 3761 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::holdings().
|
inline |
Returns static reference data for one instrument.
| subject | The instrument. |
Definition at line 3725 of file client.hpp.
Referenced by depth(), algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::instrument(), orderable_amount(), price_limits(), quote(), and trades().
|
inline |
Returns every order still open to amendment.
| account | The bound account. |
Definition at line 3882 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::working_orders().
|
inline |
Returns one day of order history.
| account | The bound account. |
| query | The query. |
Definition at line 3897 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::order_history().
|
inline |
Returns what may be ordered of one instrument, per margin tier.
| instrument | The instrument. |
| side | The side. |
| price | The unit price to evaluate at (uv), or empty to send none. |
Definition at line 3805 of file client.hpp.
|
inline |
Submits a new order. The outcome can be unknown after an error; see KiwoomClient::async_place_order.
| account | The bound account. |
| order | The order. |
Definition at line 3836 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::place_order().
|
inline |
Returns today's upper and lower price bound.
| instrument | The instrument. |
Definition at line 3682 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::price_limits().
|
inline |
Returns the current normalized quote or a structured error.
| instrument | The instrument. |
Definition at line 3668 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::quote().
|
inline |
Returns the rate limiter's statistics.
Read them on the client's strand or while no request is in progress (between calls on the blocking client).
Definition at line 3919 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::rate_limit_stats().
|
inline |
Modifies an existing order. The outcome can be unknown after an error; see KiwoomClient::async_replace_order.
| account | The bound account. |
| amendment | The amendment. |
Definition at line 3852 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::replace_order().
|
inline |
Returns the access token; see KiwoomClient::token.
Definition at line 3927 of file client.hpp.
Referenced by adopt_token().
|
inline |
Returns recent executions, newest first.
| instrument | The instrument. |
| count | The most trades to return. |
Definition at line 3711 of file client.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::trades().
|
friend |
Definition at line 3941 of file client.hpp.