3#include <algotradelib/kis>
5#include <boost/asio/io_context.hpp>
6#include <boost/asio/ssl/context.hpp>
14namespace net = boost::asio;
15namespace ssl = net::ssl;
17int main(
int argc,
char* argv[]) {
20 const std::string symbol = argc > 1 ? argv[1] :
"005930";
24 std::cout <<
"environment: " << (config.
is_demo_ ?
"demo" :
"live") <<
'\n';
25 std::cout <<
"symbol: " << symbol <<
'\n';
28 ssl::context tls(ssl::context::tls_client);
29 tls.set_default_verify_paths();
30 tls.set_verify_mode(ssl::verify_peer);
32 auto client = std::make_shared<algotradelib::kis::KisClient>(
37 {algotradelib::Country::KR, algotradelib::Venue::COMBINED, symbol},
40 const auto& error = result.error();
41 std::cerr <<
"quote failed";
42 if (!error.broker_code_.empty()) {
43 std::cerr <<
" [" << error.broker_code_ <<
']';
45 if (error.http_status_ != 0) {
46 std::cerr <<
" HTTP " << error.http_status_;
48 if (!error.message_.empty()) {
49 std::cerr <<
": " << error.message_;
55 const auto&
quote = result.value();
56 std::cout <<
quote.instrument_.symbol_ <<
' ' <<
quote.last_price_.str() <<
' '
57 <<
quote.currency_.str() <<
'\n';
63 }
catch (
const std::exception& exception) {
64 std::cerr <<
"example failed: " << exception.what() <<
'\n';
Either a value or a BrokerError.
The examples' KIS credentials: one JSON file per account, or the environment.
algotradelib::network::HttpClientOptions paced_options()
Returns transport options that pace a KIS client at one request a second.
void 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 v...
std::optional< std::filesystem::path > take_directory(int &argc, char **argv)
Removes --credentials DIR from the command line and returns the directory, else ATL_CREDENTIALS_DIR.
void quote(S &strategy, Ctx &context, const QuoteEvent &event)
Calls strategy.on_quote(context, event) if the strategy declares on_quote; otherwise does nothing.
KIS credentials (app key and secret), demo or real account, and the market-data tape.
bool is_demo_
Whether to use KIS's demo (모의투자) endpoints; true unless stated otherwise.