![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
HTTP and WebSocket transport, OAuth tokens, and request pacing. More...
Classes | |
| class | AsyncHttpClient |
| An asynchronous HTTP/1.1 client over TLS that keeps one connection to one host, used by the broker clients. More... | |
| struct | AuthBody |
| An OAuth access token and its expiry, the base of each broker's token-response class. More... | |
| class | BasicRateLimitBucket |
| A rate limiter (the generic cell rate algorithm) that computes when a request may go; it neither waits nor reads the clock itself. More... | |
| class | ClientCredentials |
| OAuth client credentials (an app key and secret), the base of each broker's credentials class. More... | |
| class | HttpClient |
| A blocking HTTP/1.1 client over TLS that keeps one connection to one host. More... | |
| struct | HttpClientOptions |
| Deadlines, size limits and pacing for an HTTP client. More... | |
| struct | HttpRequest |
| An HTTP request for AsyncHttpClient. More... | |
| struct | RateLimitBudget |
| The request rate a connection may use. More... | |
| class | RateLimitController |
| The rate limiter of one connection (one app key): a RateLimitBucket on the steady clock, plus counters. More... | |
| struct | RateLimitGroupStats |
| A rate limiter's counters for one traffic class. More... | |
| struct | RateLimitStats |
| A rate limiter's counters per traffic class, its current budget, and the broker's refusals (from RateLimitController::stats). More... | |
| class | WebSocketSessionBase |
| The base of the WebSocket clients WsSession and WssSession: connecting, sending, receiving, closing and reconnecting. More... | |
| struct | WebSocketSessionOptions |
| Options for a WebSocket session (WsSession, WssSession). More... | |
| class | WsSession |
| A WebSocket client over plain TCP (no TLS); derive from it and override on_message. More... | |
| class | WssSession |
| A WebSocket client over TLS; derive from it and override on_message. More... | |
Typedefs | |
| using | HttpResponse = http::response<http::string_body> |
| The HTTP response type the transport clients return. | |
| using | RateLimitBucket = BasicRateLimitBucket<> |
| A rate-limit bucket on the steady clock. | |
| using | WssSessionOptions = WebSocketSessionOptions |
| Options for a WssSession. | |
Enumerations | |
| enum class | RateLimitGroup { TRADING , AUTH , ACCOUNT , MARKET_DATA , REFERENCE } |
| The traffic class of a request, for rate limiting and queue priority. The broker adapter that builds a request sets it. More... | |
Functions | |
| BrokerError | transport_error (std::string stage, beast::error_code ec) |
| Converts a transport error into a BrokerError. | |
| std::string | make_host_header (const std::string &host, const std::string &port) |
| Builds an HTTP Host header value. | |
| void | shutdown_ssl_stream (beast::ssl_stream< beast::tcp_stream > &stream, std::chrono::seconds timeout) noexcept |
| Shuts a TLS stream down (best effort) and closes its socket. | |
| void | close_ssl_stream (beast::ssl_stream< beast::tcp_stream > &stream) noexcept |
| Cancels a TLS stream's operations and closes its socket, without waiting for the TLS shutdown. | |
| constexpr int | rate_limit_priority (RateLimitGroup group) noexcept |
| Returns a traffic class's queue priority. | |
| constexpr std::string_view | rate_limit_group_name (RateLimitGroup group) noexcept |
| Returns a lowercase name for a traffic class, such as "market_data", for logs. | |
| constexpr std::size_t | rate_limit_group_index (RateLimitGroup group) noexcept |
| Returns a traffic class's index, for per-class arrays. | |
| constexpr int | usable_burst (const RateLimitBudget &budget, RateLimitGroup group) noexcept |
| Returns how much of the burst a traffic class may use. | |
Variables | |
| constexpr std::array< RateLimitGroup, 5 > | all_rate_limit_groups |
| Every RateLimitGroup, in declaration order. | |
| constexpr std::size_t | rate_limit_group_count = all_rate_limit_groups.size() |
| The number of traffic classes. | |
HTTP and WebSocket transport, OAuth tokens, and request pacing.
| using algotradelib::network::HttpResponse = http::response<http::string_body> |
The HTTP response type the transport clients return.
Definition at line 48 of file http_client.hpp.
A rate-limit bucket on the steady clock.
Definition at line 341 of file rate_limit.hpp.
Options for a WssSession.
Definition at line 15 of file wss_session.hpp.
|
strong |
The traffic class of a request, for rate limiting and queue priority. The broker adapter that builds a request sets it.
| Enumerator | |
|---|---|
| TRADING | Order placement, amendment and cancellation. |
| AUTH | Access-token issue and refresh. |
| ACCOUNT | Holdings, working orders, order history and buying power. |
| MARKET_DATA | Quotes, bars, order book and trades. |
| REFERENCE | Instrument reference data and trading calendars. |
Definition at line 26 of file rate_limit.hpp.
|
inlinenoexcept |
Cancels a TLS stream's operations and closes its socket, without waiting for the TLS shutdown.
| stream | The stream. |
Definition at line 159 of file http_client.hpp.
Referenced by close_ssl_stream().
|
inline |
Builds an HTTP Host header value.
| host | The host name. |
| port | The port. |
Definition at line 133 of file http_client.hpp.
Referenced by make_host_header().
|
inlineconstexprnoexcept |
Returns a traffic class's index, for per-class arrays.
| group | The class. |
Definition at line 107 of file rate_limit.hpp.
Referenced by algotradelib::network::RateLimitStats::group(), algotradelib::network::RateLimitStats::group(), and rate_limit_group_index().
|
inlineconstexprnoexcept |
Returns a lowercase name for a traffic class, such as "market_data", for logs.
| group | The class. |
Definition at line 78 of file rate_limit.hpp.
Referenced by rate_limit_group_name().
|
inlineconstexprnoexcept |
Returns a traffic class's queue priority.
From highest: AUTH (every other request waits for a token), TRADING, ACCOUNT, MARKET_DATA, REFERENCE.
| group | The class. |
Definition at line 57 of file rate_limit.hpp.
Referenced by rate_limit_priority().
|
inlinenoexcept |
Shuts a TLS stream down (best effort) and closes its socket.
The TLS shutdown is a blocking call that timeout does not bound, so it can wait for an unresponsive peer.
| stream | The stream. |
| timeout | Set as the stream's expiry, which does not bound the blocking shutdown. |
Definition at line 146 of file http_client.hpp.
Referenced by shutdown_ssl_stream().
|
inline |
Converts a transport error into a BrokerError.
| stage | Where it failed (such as "connect"), stored as the error code. |
| ec | The error. |
Definition at line 117 of file http_client.hpp.
Referenced by transport_error().
|
inlineconstexprnoexcept |
Returns how much of the burst a traffic class may use.
| budget | The budget. |
| group | The class. |
Definition at line 138 of file rate_limit.hpp.
Referenced by algotradelib::network::RateLimitController::acquire(), algotradelib::network::RateLimitController::delay_until(), and usable_burst().
|
inlineconstexpr |
Every RateLimitGroup, in declaration order.
Definition at line 40 of file rate_limit.hpp.
|
inlineconstexpr |
The number of traffic classes.
Definition at line 100 of file rate_limit.hpp.