![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
KIS credentials (app key and secret), demo or real account, and the market-data tape. More...
#include <algotradelib/src/brokers/kis/config.hpp>
Public Member Functions | |
| void | from_env_impl () |
| Reads the credentials from KIS_APP_KEY and KIS_APP_SECRET, and the environment from KIS_DEMO (see demo_from_env); called by from_env(). Nothing changes if it throws. | |
| void | from_json_impl (const std::string &filename) |
| Reads the credentials from a JSON file; called by from_json(filename). Nothing changes if it throws. | |
| const char * | rest_host () const noexcept |
| Returns the REST host for the environment. | |
| const char * | rest_port () const noexcept |
| Returns the REST port for the environment. | |
| const char * | ws_host () const noexcept |
| Returns the WebSocket host (the same for both environments). | |
| const char * | ws_port () const noexcept |
| Returns the WebSocket port for the environment. | |
| std::string | ws_to_jsonbody () const |
| Builds the WebSocket approval-key request body (the secret under secretkey). | |
| Public Member Functions inherited from algotradelib::network::ClientCredentials< KisConfig > | |
| void | from_env () |
| Loads the credentials from the broker's environment variables. | |
| void | from_json (const std::string &filename) |
| Loads the credentials from a JSON file, in the broker's format. | |
| const std::string & | key () const noexcept |
| Returns the app key (client id). | |
| const std::string & | secret () const noexcept |
| Returns the app secret. | |
| std::string | to_jsonbody () const |
| Builds a JSON token-request body (grant type, key and secret under the broker's field names). | |
| std::string | to_form_urlencoded_body () const |
| Builds a form-encoded token-request body (grant_type, client_id, client_secret). | |
Static Public Member Functions | |
| static bool | demo_from_env () |
| Reads KIS_DEMO. | |
| static bool | demo_from_json (const json::object &doc, const std::string &filename) |
| Reads a credential file's "demo". | |
| static constexpr std::string_view | key_field () noexcept |
| Returns the token request's field for the app key. | |
| static constexpr std::string_view | secret_field () noexcept |
| Returns the token request's field for the app secret. | |
Public Attributes | |
| bool | is_demo_ = true |
| Whether to use KIS's demo (모의투자) endpoints; true unless stated otherwise. | |
| MarketTape | market_tape_ = MarketTape::CONSOLIDATED |
| Which venue's prices every KIS market-data request reads (quotes, bars, depth, price bands, trades); KRX and NXT combined by default, as Toss reports. | |
Additional Inherited Members | |
| Static Public Attributes inherited from algotradelib::network::ClientCredentials< KisConfig > | |
| static constexpr std::string_view | grant_type |
| The OAuth grant type sent in a token request. | |
| Protected Attributes inherited from algotradelib::network::ClientCredentials< KisConfig > | |
| std::string | key_ |
| The app key (client id). | |
| std::string | secret_ |
| The app secret. | |
KIS credentials (app key and secret), demo or real account, and the market-data tape.
Load with from_env() (KIS_APP_KEY, KIS_APP_SECRET, KIS_DEMO) or from_json(filename).
Definition at line 90 of file config.hpp.
|
inlinestatic |
Reads KIS_DEMO.
| std::runtime_error | for any other value. |
Definition at line 179 of file config.hpp.
Referenced by from_env_impl(), and kis_credentials::load().
|
inlinestatic |
Reads a credential file's "demo".
| doc | The file's contents. |
| filename | The file, for the error message. |
| std::runtime_error | if it is not a boolean. |
Definition at line 200 of file config.hpp.
Referenced by from_json_impl().
|
inline |
Reads the credentials from KIS_APP_KEY and KIS_APP_SECRET, and the environment from KIS_DEMO (see demo_from_env); called by from_env(). Nothing changes if it throws.
| std::runtime_error | if a key variable is missing or KIS_DEMO is invalid. |
Definition at line 116 of file config.hpp.
|
inline |
Reads the credentials from a JSON file; called by from_json(filename). Nothing changes if it throws.
Format: { "app_key": "...", "app_secret": "...", "demo": false }; without "demo" the config is demo.
| filename | The file. |
| std::runtime_error | if the file cannot be read or parsed, a key is missing or not a string, or "demo" is not a boolean. |
Definition at line 140 of file config.hpp.
|
inlinestaticconstexprnoexcept |
Returns the token request's field for the app key.
Definition at line 218 of file config.hpp.
|
inlinenoexcept |
Returns the REST host for the environment.
Definition at line 230 of file config.hpp.
|
inlinenoexcept |
Returns the REST port for the environment.
Definition at line 238 of file config.hpp.
|
inlinestaticconstexprnoexcept |
Returns the token request's field for the app secret.
Definition at line 224 of file config.hpp.
|
inlinenoexcept |
Returns the WebSocket host (the same for both environments).
Definition at line 244 of file config.hpp.
|
inlinenoexcept |
Returns the WebSocket port for the environment.
Definition at line 250 of file config.hpp.
|
inline |
Builds the WebSocket approval-key request body (the secret under secretkey).
Definition at line 256 of file config.hpp.
| bool algotradelib::kis::KisConfig::is_demo_ = true |
Whether to use KIS's demo (모의투자) endpoints; true unless stated otherwise.
Real trading must be stated: KIS_DEMO=0, "demo": false in the credential file, or is_demo_ = false. Real-account keys sent to the demo endpoints are refused at the first token request, so a forgotten setting fails rather than trades.
Definition at line 101 of file config.hpp.
Referenced by from_env_impl(), from_json_impl(), kis_credentials::load_config(), rest_host(), rest_port(), and ws_port().
| MarketTape algotradelib::kis::KisConfig::market_tape_ = MarketTape::CONSOLIDATED |
Which venue's prices every KIS market-data request reads (quotes, bars, depth, price bands, trades); KRX and NXT combined by default, as Toss reports.
It does not change the instrument's identity or where orders go.
Definition at line 109 of file config.hpp.