algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::network::HttpClientOptions Struct Reference

Deadlines, size limits and pacing for an HTTP client. More...

#include <algotradelib/src/network/http_client.hpp>

Public Attributes

std::chrono::seconds timeout_ {30}
 The deadline for each of DNS lookup, connect, TLS handshake, write and read, in AsyncHttpClient; HttpClient's blocking operations are not bounded by it.
std::size_t body_limit_ {8 * 1024 * 1024}
 The largest response body accepted, in bytes.
std::size_t queue_limit_ {1024}
 How many requests the queue may hold, the one being sent included (AsyncHttpClient); one more fails with queue_full, unsent.
std::optional< RateLimitBudget > rate_limit_
 The rate-limit budget that paces this connection's requests, or empty (the default) for no pacing (AsyncHttpClient only). The caller sets it; the broker clients pass it through, and a client may set its own default when it is empty (alpaca::AlpacaBlockingClient does).
std::chrono::milliseconds unreplayed_idle_limit_ {1000}
 How long a kept-alive connection may sit idle and still carry a request other than a GET (one second by default).
std::optional< bool > fresh_connection_for_orders_
 Whether AsyncHttpClient writes every order (RateLimitGroup::TRADING) on a connection no request has used; empty (the default) lets the broker client choose.

Detailed Description

Deadlines, size limits and pacing for an HTTP client.

Definition at line 77 of file http_client.hpp.

Member Data Documentation

◆ body_limit_

std::size_t algotradelib::network::HttpClientOptions::body_limit_ {8 * 1024 * 1024}

The largest response body accepted, in bytes.

Definition at line 84 of file http_client.hpp.

◆ fresh_connection_for_orders_

std::optional<bool> algotradelib::network::HttpClientOptions::fresh_connection_for_orders_

Whether AsyncHttpClient writes every order (RateLimitGroup::TRADING) on a connection no request has used; empty (the default) lets the broker client choose.

A server may close a connection that has carried requests without saying so, well inside its idle timeout; an order written into it is an order of unknown outcome, never sent again. On, each order is preceded by a TLS handshake whenever the connection has been used. Off, an order follows unreplayed_idle_limit_ like any other request. Empty is off for AsyncHttpClient itself; kis::KisClient turns it on for a demo configuration and off for a real one (in October 2026 the KIS demo server closed such connections 0.66 s and 3 s after an order's reply; its real server was not observed doing so). Kiwoom and Toss leave it off. It makes a stale connection unlikely, not impossible: an unused connection can be closed too. The blocking HttpClient ignores it.

Definition at line 121 of file http_client.hpp.

◆ queue_limit_

std::size_t algotradelib::network::HttpClientOptions::queue_limit_ {1024}

How many requests the queue may hold, the one being sent included (AsyncHttpClient); one more fails with queue_full, unsent.

Definition at line 89 of file http_client.hpp.

◆ rate_limit_

std::optional<RateLimitBudget> algotradelib::network::HttpClientOptions::rate_limit_

The rate-limit budget that paces this connection's requests, or empty (the default) for no pacing (AsyncHttpClient only). The caller sets it; the broker clients pass it through, and a client may set its own default when it is empty (alpaca::AlpacaBlockingClient does).

Definition at line 96 of file http_client.hpp.

Referenced by kis_credentials::paced_options(), and kiwoom_credentials::paced_options().

◆ timeout_

std::chrono::seconds algotradelib::network::HttpClientOptions::timeout_ {30}

The deadline for each of DNS lookup, connect, TLS handshake, write and read, in AsyncHttpClient; HttpClient's blocking operations are not bounded by it.

Definition at line 82 of file http_client.hpp.

◆ unreplayed_idle_limit_

std::chrono::milliseconds algotradelib::network::HttpClientOptions::unreplayed_idle_limit_ {1000}

How long a kept-alive connection may sit idle and still carry a request other than a GET (one second by default).

A server closes idle connections on its own schedule, and a request written into a closed connection fails. A GET is then sent again, but any other request is not, so its outcome would be unknown. Such a request after a longer idle period is therefore sent on a fresh connection, at the cost of a TLS handshake (once per request in AsyncHttpClient; see its description).

With fresh_connection_for_orders_ on, an order (RateLimitGroup::TRADING) does not depend on this limit: it is written on a connection no request has used, and this limit only bounds how long such an unused connection may wait for it.

Definition at line 108 of file http_client.hpp.


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