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

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={})
 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.

Detailed Description

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).

Definition at line 3795 of file client.hpp.

Constructor & Destructor Documentation

◆ KiwoomBlockingClient()

algotradelib::kiwoom::KiwoomBlockingClient::KiwoomBlockingClient ( ssl::context & context,
KiwoomConfig 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 3803 of file client.hpp.

Member Function Documentation

◆ accounts()

Result< std::vector< KiwoomAccountInfo > > algotradelib::kiwoom::KiwoomBlockingClient::accounts ( )
inline

Returns the one account the bound credential drives.

Returns
The result, or an error.

Definition at line 3953 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::accounts().

◆ bars()

Result< BarSeries > algotradelib::kiwoom::KiwoomBlockingClient::bars ( BarQuery query)
inline

Returns bars; see KiwoomClient::async_bars.

Parameters
queryThe query.
Returns
The result, or an error.

Definition at line 3878 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::bars().

◆ buying_power()

Result< BuyingPower > algotradelib::kiwoom::KiwoomBlockingClient::buying_power ( Currency currency,
KiwoomAccount account )
inline

Returns what the bound credential's account may spend.

Parameters
currencyThe currency; anything but KRW is refused before sending.
accountThe bound account.
Returns
The result, or an error.

Definition at line 3909 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::buying_power().

◆ cancel_order()

Result< KiwoomOrderAck > algotradelib::kiwoom::KiwoomBlockingClient::cancel_order ( KiwoomAccount account,
KiwoomAmendment amendment )
inline

Cancels an existing order. The outcome can be unknown after an error; see KiwoomClient::async_cancel_order.

Parameters
accountThe bound account.
amendmentThe amendment.
Returns
The result, or an error.

Definition at line 3999 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::cancel_order().

◆ close()

void algotradelib::kiwoom::KiwoomBlockingClient::close ( )
inline

Closes the client for good; see KiwoomClient::close.

Definition at line 4036 of file client.hpp.

◆ config()

const KiwoomConfig & algotradelib::kiwoom::KiwoomBlockingClient::config ( ) const
inlinenoexcept

Returns the configuration; see KiwoomClient::config.

Returns
The configuration.

Definition at line 3889 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::holdings(), and KiwoomBlockingClient().

◆ deposit()

Result< KiwoomDeposit > algotradelib::kiwoom::KiwoomBlockingClient::deposit ( )
inline

Returns Kiwoom's own fuller deposit detail.

Returns
The result, or an error.

Definition at line 3920 of file client.hpp.

◆ depth()

Result< DepthSnapshot > algotradelib::kiwoom::KiwoomBlockingClient::depth ( InstrumentId instrument)
inline

Returns the resting orders on both sides of the book.

Parameters
instrumentThe instrument.
Returns
The result, or an error.

Definition at line 3841 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::depth().

◆ holdings()

Result< HoldingsSnapshot > algotradelib::kiwoom::KiwoomBlockingClient::holdings ( KiwoomAccount account)
inline

Returns the holdings for KiwoomConfig::holdings_venue_; see KiwoomClient::async_holdings.

Parameters
accountThe account (empty).
Returns
The result, or an error.

Definition at line 3896 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::holdings().

◆ instrument()

Result< Instrument > algotradelib::kiwoom::KiwoomBlockingClient::instrument ( InstrumentId subject)
inline

Returns static reference data for one instrument.

Parameters
subjectThe instrument.
Returns
The result, or an error.

Definition at line 3866 of file client.hpp.

Referenced by depth(), algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::instrument(), orderable_amount(), price_limits(), quote(), and trades().

◆ open_orders()

Result< KiwoomOpenOrderPage > algotradelib::kiwoom::KiwoomBlockingClient::open_orders ( KiwoomAccount account)
inline

Returns every order still open to amendment.

Parameters
accountThe bound account.
Returns
The result, or an error.

Definition at line 4013 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::working_orders().

◆ order_history()

Result< OrderPage > algotradelib::kiwoom::KiwoomBlockingClient::order_history ( KiwoomAccount account,
KiwoomHistoryQuery query )
inline

Returns one day of order history.

Parameters
accountThe bound account.
queryThe query.
Returns
The result, or an error.

Definition at line 4026 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::order_history().

◆ orderable_amount()

Result< KiwoomOrderableAmount > algotradelib::kiwoom::KiwoomBlockingClient::orderable_amount ( InstrumentId instrument,
OrderSide side,
std::optional< Decimal64 > price = std::nullopt )
inline

Returns what may be ordered of one instrument, per margin tier.

Parameters
instrumentThe instrument.
sideThe side.
priceThe unit price to evaluate at (uv), or empty to send none.
Returns
The result, or an error.

Definition at line 3934 of file client.hpp.

◆ place_order()

Result< KiwoomOrderAck > algotradelib::kiwoom::KiwoomBlockingClient::place_order ( KiwoomAccount account,
OrderRequest order )
inline

Submits a new order. The outcome can be unknown after an error; see KiwoomClient::async_place_order.

Parameters
accountThe bound account.
orderThe order.
Returns
The result, or an error.

Definition at line 3967 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::place_order().

◆ price_limits()

Result< PriceLimits > algotradelib::kiwoom::KiwoomBlockingClient::price_limits ( InstrumentId instrument)
inline

Returns today's upper and lower price bound.

Parameters
instrumentThe instrument.
Returns
The result, or an error.

Definition at line 3829 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::price_limits().

◆ quote()

Result< QuoteSnapshot > algotradelib::kiwoom::KiwoomBlockingClient::quote ( InstrumentId instrument)
inline

Returns the current normalized quote or a structured error.

Parameters
instrumentThe instrument.
Returns
The result, or an error.

Definition at line 3817 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::quote().

◆ rate_limit_stats()

const network::RateLimitStats * algotradelib::kiwoom::KiwoomBlockingClient::rate_limit_stats ( ) const
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).

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

Definition at line 4046 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::rate_limit_stats().

◆ replace_order()

Result< KiwoomOrderAck > algotradelib::kiwoom::KiwoomBlockingClient::replace_order ( KiwoomAccount account,
KiwoomAmendment amendment )
inline

Modifies an existing order. The outcome can be unknown after an error; see KiwoomClient::async_replace_order.

Parameters
accountThe bound account.
amendmentThe amendment.
Returns
The result, or an error.

Definition at line 3983 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::replace_order().

◆ trades()

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

Returns recent executions, newest first.

Parameters
instrumentThe instrument.
countThe most trades to return.
Returns
The result, or an error.

Definition at line 3854 of file client.hpp.

Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::trades().


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