![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
The examples' KIS credentials: one JSON file per account, or the environment. More...
#include <algotradelib/kis>#include <cstdlib>#include <filesystem>#include <optional>#include <ostream>#include <stdexcept>#include <string>#include <string_view>Go to the source code of this file.
Functions | |
| std::optional< std::filesystem::path > | kis_credentials::environment_directory () |
| Returns ATL_CREDENTIALS_DIR, for an example that parses no arguments of its own. | |
| std::optional< std::filesystem::path > | kis_credentials::take_directory (int &argc, char **argv) |
| Removes --credentials DIR from the command line and returns the directory, else ATL_CREDENTIALS_DIR. | |
| algotradelib::network::HttpClientOptions | kis_credentials::paced_options () |
| Returns transport options that pace a KIS client at one request a second. | |
| std::filesystem::path | kis_credentials::required_file (const std::filesystem::path &directory, const char *name) |
| Returns the path of a credential file in the directory. | |
| void | kis_credentials::load_config (algotradelib::kis::KisConfig &config, const std::filesystem::path &path, bool demo) |
| Loads a configuration from a file and refuses one whose "demo" contradicts its name. | |
| void | kis_credentials::load (const std::optional< std::filesystem::path > &directory, algotradelib::kis::KisConfig &config, algotradelib::kis::KisAccount *account, std::ostream &out) |
| Loads the credentials (and account) KIS_DEMO chooses, and prints where from (a path or "environment variables", never a key). | |
| std::optional< algotradelib::kis::KisConfig > | kis_credentials::market_data_config (const std::optional< std::filesystem::path > &directory) |
| Returns a configuration for market data alone, from DIR/kis/real.json. | |
The examples' KIS credentials: one JSON file per account, or the environment.
Not part of the library. With a credentials directory – --credentials DIR on the command line, else ATL_CREDENTIALS_DIR – the examples read DIR/kis/demo.json or DIR/kis/real.json, as KIS_DEMO chooses (unset or 1: demo; 0: real). Without one they read the environment variables, as before. A directory that is given but lacks the file stops the program: it never falls back to the environment, which may hold the other account's keys.
Each file holds app_key, app_secret, account_number, account_product_code and demo (KisConfig::from_json, KisAccount::from_json). Keep it chmod 600.
Definition in file kis_credentials.hpp.
|
inline |
Returns ATL_CREDENTIALS_DIR, for an example that parses no arguments of its own.
| std::runtime_error | if it is set but empty. |
Definition at line 34 of file kis_credentials.hpp.
|
inline |
Loads the credentials (and account) KIS_DEMO chooses, and prints where from (a path or "environment variables", never a key).
| directory | The credentials directory, or std::nullopt to read the environment. |
| config | The configuration to load into. |
| account | The account to load into, or null. |
| out | Where to print the source. |
| std::runtime_error | if the file or variables are missing or invalid. |
Definition at line 129 of file kis_credentials.hpp.
|
inline |
Loads a configuration from a file and refuses one whose "demo" contradicts its name.
| config | The configuration to load into. |
| path | The file. |
| demo | Whether the file is the demo one. |
| std::runtime_error | if the file cannot be loaded or contradicts its name. |
Definition at line 110 of file kis_credentials.hpp.
|
inline |
Returns a configuration for market data alone, from DIR/kis/real.json.
Pair it with an empty KisAccount, which refuses every account request and order before any I/O.
| directory | The credentials directory. |
| std::runtime_error | if the file exists but cannot be loaded or is not a real-account file. |
Definition at line 161 of file kis_credentials.hpp.
|
inline |
Returns transport options that pace a KIS client at one request a second.
A KIS demo account refuses reads closer than about a second apart (EGW00201), and with real keys the holiday calendar was refused at eight a second. The library paces nothing unless asked (HttpClientOptions::rate_limit_), so these examples ask. A key with a larger allowance may raise it.
Definition at line 80 of file kis_credentials.hpp.
|
inline |
Returns the path of a credential file in the directory.
| directory | The credentials directory. |
| name | The file name, such as "demo.json". |
| std::runtime_error | if the file does not exist (the environment is not read instead). |
Definition at line 93 of file kis_credentials.hpp.
|
inline |
Removes --credentials DIR from the command line and returns the directory, else ATL_CREDENTIALS_DIR.
| argc | The argument count; reduced by the arguments removed. |
| argv | The arguments; the rest are moved down. |
| std::runtime_error | if --credentials has no usable value (missing, empty, or another flag), so a mistyped command never falls back to another source, or if no --credentials is given and ATL_CREDENTIALS_DIR is set but empty. |
Definition at line 52 of file kis_credentials.hpp.