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

Toss Securities credentials (client id and secret). Toss has no demo environment. More...

#include <algotradelib/src/brokers/tossinvest/config.hpp>

Inheritance diagram for algotradelib::tossinvest::TossConfig:
Collaboration diagram for algotradelib::tossinvest::TossConfig:

Public Member Functions

void from_env_impl ()
 Reads the credentials from TOSS_CLIENT_ID and TOSS_CLIENT_SECRET; called by from_env().
void from_json_impl (const std::string &filename)
 Reads the credentials from a JSON file, { "client_id": "...", "client_secret": "..." }; called by from_json(filename). Nothing changes if it throws.
void from_json_text_impl (std::string_view text, const std::string &origin)
 Reads the credentials from JSON text in the file's format; called by from_json_text. Nothing changes if it throws.
std::string token_identity () const
 Names what a token of these credentials may not outlive, for a network::TokenStore.
Public Member Functions inherited from algotradelib::network::ClientCredentials< TossConfig >
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.
void from_json_text (std::string_view text, const std::string &origin)
 Loads the credentials from JSON text in the broker's format, as from_json reads a file's contents, for credentials kept somewhere other than a file (a system credential store).
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 constexpr std::string_view key_field () noexcept
 Returns the token request's field for the client id.
static constexpr std::string_view secret_field () noexcept
 Returns the token request's field for the client secret.

Additional Inherited Members

Static Public Attributes inherited from algotradelib::network::ClientCredentials< TossConfig >
static constexpr std::string_view grant_type
 The OAuth grant type sent in a token request.
Protected Attributes inherited from algotradelib::network::ClientCredentials< TossConfig >
std::string key_
 The app key (client id).
std::string secret_
 The app secret.

Detailed Description

Toss Securities credentials (client id and secret). Toss has no demo environment.

Load with from_env() (TOSS_CLIENT_ID, TOSS_CLIENT_SECRET), from_json(filename) or from_json_text(text, origin).

Definition at line 27 of file config.hpp.

Member Function Documentation

◆ from_env_impl()

void algotradelib::tossinvest::TossConfig::from_env_impl ( )
inline

Reads the credentials from TOSS_CLIENT_ID and TOSS_CLIENT_SECRET; called by from_env().

Exceptions
std::runtime_errorif either is not set.

Definition at line 37 of file config.hpp.

◆ from_json_impl()

void algotradelib::tossinvest::TossConfig::from_json_impl ( const std::string & filename)
inline

Reads the credentials from a JSON file, { "client_id": "...", "client_secret": "..." }; called by from_json(filename). Nothing changes if it throws.

Parameters
filenameThe file.
Exceptions
std::runtime_errorif the file cannot be read, is not a JSON object, or lacks either field or has one that is not a string.

Definition at line 54 of file config.hpp.

◆ from_json_text_impl()

void algotradelib::tossinvest::TossConfig::from_json_text_impl ( std::string_view text,
const std::string & origin )
inline

Reads the credentials from JSON text in the file's format; called by from_json_text. Nothing changes if it throws.

Parameters
textThe JSON document.
originWhat error messages call the source ("file creds.json"); not a secret.
Exceptions
std::runtime_errorif the text cannot be parsed, is not a JSON object, or lacks either field or has one that is not a string.

Definition at line 71 of file config.hpp.

Referenced by from_json_impl().

◆ key_field()

constexpr std::string_view algotradelib::tossinvest::TossConfig::key_field ( )
inlinestaticconstexprnoexcept

Returns the token request's field for the client id.

Returns
"client_id".

Definition at line 98 of file config.hpp.

◆ secret_field()

constexpr std::string_view algotradelib::tossinvest::TossConfig::secret_field ( )
inlinestaticconstexprnoexcept

Returns the token request's field for the client secret.

Returns
"client_secret".

Definition at line 106 of file config.hpp.

◆ token_identity()

std::string algotradelib::tossinvest::TossConfig::token_identity ( ) const
inline

Names what a token of these credentials may not outlive, for a network::TokenStore.

Returns
toss-real-, then the client id's SHA-256 digest (Toss has no demo environment).

Definition at line 114 of file config.hpp.


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