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

The error a broker or transport operation returns. More...

#include <algotradelib/src/core/types.hpp>

Public Attributes

ErrorCategory category_ {ErrorCategory::PROTOCOL}
 The kind of failure; the field to branch on.
bool reached_broker_ {true}
 Whether a request was sent before this error.
int http_status_ {0}
 The HTTP status of the reply: set for an HTTP error and for a reply whose body is not a JSON object. 0 if no reply arrived, and on some errors built from a reply that did parse (a declared failure, a missing field) that do not carry it.
std::string broker_code_
 The broker's own error code, verbatim (for example KIS's EGW00201).
std::string request_id_
 The broker's request id for this call, if it gave one.
std::string message_
 A human-readable description, for logs; do not parse it.
std::optional< std::chrono::seconds > retry_after_
 How long the broker asked the caller to wait (Retry-After), for a rate-limit error.
std::optional< int > rate_limit_
 The rate limit the broker says it enforces, in requests per second, for a rate-limit error.

Detailed Description

The error a broker or transport operation returns.

Branch on category_; the other fields are for diagnosis and logs.

Definition at line 1003 of file types.hpp.

Member Data Documentation

◆ broker_code_

◆ category_

ErrorCategory algotradelib::BrokerError::category_ {ErrorCategory::PROTOCOL}

◆ http_status_

int algotradelib::BrokerError::http_status_ {0}

The HTTP status of the reply: set for an HTTP error and for a reply whose body is not a JSON object. 0 if no reply arrived, and on some errors built from a reply that did parse (a declared failure, a missing field) that do not carry it.

Definition at line 1020 of file types.hpp.

Referenced by algotradelib::kiwoom::kiwoom_recognized_refusal(), and algotradelib::runner::outcome_of().

◆ message_

std::string algotradelib::BrokerError::message_

A human-readable description, for logs; do not parse it.

For an HTTP error from KIS or Kiwoom it carries the start of the reply's body (at most 512 bytes, then the count of bytes left out); that is an excerpt, not redaction. A broker's declared error carries its own message field. A whole successful reply the adapter cannot read is not copied (a token reply holds the token).

Definition at line 1033 of file types.hpp.

Referenced by algotradelib::mock::Market::buying_power(), algotradelib::network::calendar_cache_error(), algotradelib::backtest::CommissionPolicy::charge(), algotradelib::network::AsyncHttpClient::close(), algotradelib::backtest::commission_model_from(), algotradelib::backtest::NextBarFillModel::decide(), algotradelib::backtest::Backtester< Strategy, CapsType >::feed(), algotradelib::mock::Market::holdings(), algotradelib::live::incomplete_history(), algotradelib::kiwoom::invalid_trigger(), algotradelib::kiwoom::kiwoom_declared_error(), algotradelib::kiwoom::kiwoom_recognized_refusal(), algotradelib::mock::MockClient::lose_next_reply(), algotradelib::kiwoom::order_division(), algotradelib::mock::Market::quote(), algotradelib::data_only::refusal(), algotradelib::network::token_store_error(), algotradelib::network::token_unusable_error(), algotradelib::network::transport_error(), algotradelib::kiwoom::unestablished_holdings_scope(), algotradelib::kis::unsupported_bar_interval(), algotradelib::kiwoom::unsupported_bar_interval(), algotradelib::tossinvest::unsupported_bar_interval(), algotradelib::kis::unsupported_client_order_id(), and algotradelib::kiwoom::unsupported_client_order_id().

◆ rate_limit_

std::optional<int> algotradelib::BrokerError::rate_limit_

The rate limit the broker says it enforces, in requests per second, for a rate-limit error.

Empty if the broker stated none or an unusable one. KIS never states one.

Definition at line 1046 of file types.hpp.

◆ reached_broker_

bool algotradelib::BrokerError::reached_broker_ {true}

Whether a request was sent before this error.

false when nothing was written: the client refused before any I/O (an order id too long, an unsupported time in force), or the transport failed before writing (resolving, connecting, handshaking, a full queue, or a closed client). Such an error is not counted against a rate limit and was not the broker's; a runner may offer the instruction again. Defaults to true.

Definition at line 1014 of file types.hpp.

Referenced by algotradelib::network::calendar_cache_error(), algotradelib::backtest::CommissionPolicy::charge(), algotradelib::network::AsyncHttpClient::close(), algotradelib::backtest::commission_model_from(), algotradelib::backtest::NextBarFillModel::decide(), algotradelib::backtest::Backtester< Strategy, CapsType >::feed(), algotradelib::live::incomplete_history(), algotradelib::kiwoom::invalid_trigger(), algotradelib::kiwoom::kiwoom_declared_error(), algotradelib::kiwoom::kiwoom_recognized_refusal(), algotradelib::mock::MockClient::lose_next_reply(), algotradelib::kiwoom::order_division(), algotradelib::runner::outcome_of(), algotradelib::data_only::refusal(), algotradelib::network::token_store_error(), algotradelib::network::token_unusable_error(), algotradelib::kiwoom::unestablished_holdings_scope(), algotradelib::kis::unsupported_bar_interval(), algotradelib::kiwoom::unsupported_bar_interval(), algotradelib::tossinvest::unsupported_bar_interval(), algotradelib::kis::unsupported_client_order_id(), and algotradelib::kiwoom::unsupported_client_order_id().

◆ request_id_

std::string algotradelib::BrokerError::request_id_

The broker's request id for this call, if it gave one.

Definition at line 1024 of file types.hpp.

◆ retry_after_

std::optional<std::chrono::seconds> algotradelib::BrokerError::retry_after_

How long the broker asked the caller to wait (Retry-After), for a rate-limit error.

Empty if the broker sent none or an unreadable one; back off on your own then rather than retrying at once.

Definition at line 1040 of file types.hpp.


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