algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
example-live-program.cpp
Go to the documentation of this file.
1
59
60#include "kis_credentials.hpp"
62#include "live_program.hpp"
63
64#include <algotradelib/kis>
65#include <algotradelib/kiwoom>
66#include <algotradelib/network>
67#include <algotradelib/tossinvest>
68
69#include <boost/asio/ssl/context.hpp>
70
71#include <cctype>
72#include <cstdint>
73#include <cstdlib>
74#include <exception>
75#include <filesystem>
76#include <iostream>
77#include <memory>
78#include <optional>
79#include <string>
80#include <utility>
81#include <vector>
82
83namespace {
84
85namespace ssl = boost::asio::ssl;
86namespace atl = algotradelib;
89
91struct Arguments {
92 std::string broker_;
93 std::string symbol_;
94 bool live_{false};
95 std::optional<std::string> journal_;
96 std::optional<std::string> control_;
97 std::optional<std::int64_t> toss_account_;
98 std::optional<std::filesystem::path> credentials_;
99 bool credentials_from_flag_{false};
100 std::optional<std::string> market_data_;
101 std::optional<std::string> kiwoom_account_;
102 std::optional<std::string> tokens_;
103};
104
111struct HoldsShares {
113 atl::InstrumentId instrument_;
115 atl::Decimal64 quantity_;
116
117 template <class Ctx>
118 void on_bar(Ctx& ctx, const strategy::BarEvent& bar) {
119 if (!(bar.instrument_ == instrument_)) {
120 return;
121 }
122 strategy::TargetPosition target;
123 target.instrument_ = instrument_;
124 target.target_quantity_ = quantity_;
125 target.tag_ = "hold";
126 ctx.submit(target);
127 }
128};
129
131HoldsShares strategy_for(const atl::InstrumentId& instrument) {
132 return HoldsShares{instrument, atl::Decimal64::parse("1")};
133}
134
140live_program::Settings settings_for(const atl::InstrumentId& instrument) {
141 live_program::Settings settings;
142 settings.universe_ = {instrument};
143
146 settings.limits_.max_orders_per_window_ = 2;
147
148 // Daily bars, `SessionSource`'s default. The loop reads the order list and holdings before it feeds
149 // a bar. At start the strategy is shown the history read, but only the newest closed bar's decision
150 // can be sent: at once if the market is open; otherwise an opening order waits for the first `OPEN`
151 // iteration (which needs a calendar), and an exit goes out at once and is kept if the broker refuses
152 // it. After that a day's bar is fed once the day has ended, at the first poll after midnight KST,
153 // and the same rule applies ("kept for the next session" in running-a-strategy-live.md). Polled
154 // every minute so that poll comes promptly; a minute-bar strategy sets `bar_interval_`.
155 settings.schedule_.bars_ = std::chrono::minutes(1);
156 settings.schedule_.holdings_ = std::chrono::seconds(30);
157 settings.schedule_.working_orders_ = std::chrono::seconds(30);
158 // A band is a per-trading-day value; refresh it well inside a session.
159 settings.schedule_.price_limits_ = std::chrono::minutes(10);
160 // The calendar keeps its six-hour default.
161
162 // Every age stated. A holdings snapshot older than two minutes -- four missed polls -- stops
163 // sizing; a band older than twenty -- two missed polls -- stops clamping.
164 settings.maximum_portfolio_age_ = std::chrono::minutes(2);
165 settings.maximum_price_limits_age_ = std::chrono::minutes(20);
166 return settings;
167}
168
170std::string file_safe(std::string text) {
171 for (auto& ch : text) {
172 if (!std::isalnum(static_cast<unsigned char>(ch)) && ch != '-') {
173 ch = '_';
174 }
175 }
176 return text;
177}
178
186void name_journal(
187 live_program::Settings& settings, const Arguments& arguments, const std::string& broker, bool demo,
188 const std::string& account
189) {
190 settings.journal_scope_ = broker + ':' + (demo ? "demo" : "live") + ':' + account;
191 const std::string stem = "atl-" + broker + '-' + (demo ? "demo" : "live") + '-' + file_safe(account);
192 settings.journal_path_ = arguments.journal_ ? *arguments.journal_ : stem + ".jsonl";
193 settings.control_file_ = arguments.control_ ? *arguments.control_ : stem + ".stop";
194}
195
201void announce(
202 const Arguments& arguments, const live_program::Settings& settings, bool demo, const char* demo_variable
203) {
204 std::cout << "broker : " << arguments.broker_ << (demo ? " (demo)" : " (LIVE ACCOUNT)") << '\n';
205 // Demo because nothing said live: say how to say it, since live keys on the demo endpoints fail with
206 // the broker's own authentication error, which does not point here.
207 if (demo && demo_variable != nullptr && std::getenv(demo_variable) == nullptr) {
208 std::cout << " demo by default; set " << demo_variable << "=0 to trade live\n";
209 }
210 std::cout
211 << "instrument : " << arguments.symbol_ << '\n'
212 << "mode : " << (arguments.live_ ? "TRADE -- orders will be sent" : "observe") << '\n'
213 << "limits : at most " << settings.limits_.max_position_quantity_->str() << " share(s), "
214 << settings.limits_.max_order_notional_->str() << " per order\n";
215 if (settings.default_route_ != atl::Venue::UNSPECIFIED) {
216 std::cout << "route : " << atl::venue_name(settings.default_route_) << '\n';
217 }
218 if (arguments.live_) {
219 std::cout << "journal : " << settings.journal_path_ << " (scope " << settings.journal_scope_ << ")\n";
220 }
221}
222
224std::shared_ptr<atl::network::TokenStore> token_store(const Arguments& arguments) {
225#if defined(_WIN32)
226 (void)arguments;
227 return nullptr;
228#else
229 return std::make_shared<atl::network::FileTokenStore>(arguments.tokens_ ? *arguments.tokens_ : "atl-tokens");
230#endif
231}
232
234std::shared_ptr<atl::network::CalendarCache> calendar_cache(const Arguments& arguments) {
235#if defined(_WIN32)
236 (void)arguments;
237 return nullptr;
238#else
239 const std::filesystem::path tokens = arguments.tokens_ ? *arguments.tokens_ : "atl-tokens";
240 return std::make_shared<atl::network::FileCalendarCache>((tokens.parent_path() / "atl-calendars").string());
241#endif
242}
243
245template <typename Session, typename MarketData>
246int run(
247 Session& session, MarketData& market_data, const atl::InstrumentId& instrument,
248 const live_program::Settings& settings, bool live
249) {
252 const auto exit = live ?
253 live_program::trade(session, market_data, strategy_for(instrument), settings, stop, std::cout) :
254 live_program::observe(session, market_data, strategy_for(instrument), settings, stop, std::cout);
256 return static_cast<int>(exit);
257}
258
260template <typename Session>
261int run(Session& session, const atl::InstrumentId& instrument, const live_program::Settings& settings, bool live) {
262 return run(session, session, instrument, settings, live);
263}
264
265int run_kis(ssl::context& tls, const Arguments& arguments) {
266 namespace kis = algotradelib::kis;
267
268 kis::KisConfig config;
269 kis::KisAccount account;
270 kis_credentials::load(arguments.credentials_, config, &account, std::cout);
271 const bool demo = config.is_demo_;
272
273 const atl::InstrumentId instrument{atl::Country::KR, atl::Venue::COMBINED, arguments.symbol_};
274 auto settings = settings_for(instrument);
275 name_journal(settings, arguments, "kis", demo, account.account_number_ + '-' + account.product_code_);
276 announce(arguments, settings, demo, "KIS_DEMO");
277
278 const auto tokens = token_store(arguments);
279 const auto calendars = calendar_cache(arguments);
281 std::make_shared<kis::KisBlockingClient>(
282 tls, std::move(config), kis_credentials::paced_options(), tokens, calendars
283 ),
284 std::move(account)
285 );
286
287 // Market data from a session with no account, so it cannot trade: swapped by mistake, every order
288 // and account read through it is refused before any I/O.
289 if (arguments.market_data_ == "toss") {
290 if (!demo) {
291 // Toss publishes the next session's band after the close, before KIS does, and when each rolls
292 // over is not settled: a KIS demo run only.
293 throw std::runtime_error("--market-data toss is for a KIS demo run only");
294 }
295 if (!arguments.credentials_) {
296 throw std::runtime_error("--market-data toss reads tossinvest/real.json; give --credentials DIR");
297 }
298 const auto path = *arguments.credentials_ / "tossinvest" / "real.json";
300 toss_config.from_json(path.string());
302 std::make_shared<algotradelib::tossinvest::TossBlockingClient>(
303 tls, std::move(toss_config), atl::network::HttpClientOptions{}, tokens
304 ),
305 0
306 );
307 std::cout << "market data: toss " << path.string() << " (no account: cannot trade)\n";
308 return run(session, market_data, instrument, settings, arguments.live_);
309 }
310 if (!demo && arguments.market_data_ == "kis") {
311 throw std::runtime_error("--market-data kis is for a demo run; a live run reads its own market data");
312 }
313 if (demo) {
314 auto market_config = kis_credentials::market_data_config(arguments.credentials_);
315 if (market_config) {
317 std::make_shared<kis::KisBlockingClient>(
318 tls, std::move(*market_config), kis_credentials::paced_options(), tokens, calendars
319 ),
320 kis::KisAccount{}
321 );
322 std::cout
323 << "market data: kis " << (*arguments.credentials_ / "kis" / "real.json").string()
324 << " (no account: cannot trade)\n";
325 return run(session, market_data, instrument, settings, arguments.live_);
326 }
327 if (arguments.market_data_ == "kis") {
328 throw std::runtime_error(
329 arguments.credentials_ ?
330 "--market-data kis reads kis/real.json, and there is none" :
331 "--market-data kis reads kis/real.json; give --credentials DIR"
332 );
333 }
334 std::cout
335 << "market data: the demo account's own (no kis/real.json); a demo host refuses\n"
336 << " reference data, so this run stops there\n";
337 }
338 return run(session, instrument, settings, arguments.live_);
339}
340
341int run_kiwoom(ssl::context& tls, const Arguments& arguments) {
342 namespace kiwoom = algotradelib::kiwoom;
343
344 kiwoom::KiwoomConfig config;
345 kiwoom_credentials::load(arguments.credentials_, arguments.kiwoom_account_, config, std::cout);
346 // Kiwoom's balance inquiry names one venue and does not say whether that filters the positions or
347 // only values them, so the adapter refuses holdings until you state both. Until then the loop has
348 // no portfolio and holds: this program runs and places nothing. Measure what your account returns
349 // (run `example-kiwoom-account`, then set its `holdings_venue_` to NXT, rebuild and run it again),
350 // then assert what you measured. The sellable scope is the third thing to state: without it the
351 // guard refuses every sell, a flatten's closing sell included.
352 config.holdings_venue_ = atl::Venue::KRX;
353 // config.holdings_position_scope_ = kiwoom::KiwoomPositionScope::WHOLE_HOLDING;
354 // config.holdings_sellable_scope_ = kiwoom::KiwoomSellableScope::WHOLE_HOLDING;
355 const bool demo = config.is_demo_;
356
358 std::make_shared<kiwoom::KiwoomBlockingClient>(
359 tls, std::move(config), kiwoom_credentials::paced_options(), token_store(arguments)
360 ),
361 kiwoom::KiwoomAccount{}
362 );
363 // Kiwoom takes no account number on a request -- the application key is the account -- so the
364 // journal is named after the account the key drives, as Kiwoom reports it.
365 const auto accounts = session.accounts();
366 if (!accounts || accounts.value().empty()) {
367 std::cerr
368 << "could not read which account this Kiwoom key drives"
369 << (accounts ? std::string() : ": " + accounts.error().message_) << '\n';
370 return static_cast<int>(live_program::Exit::ACCOUNT_UNRESOLVED);
371 }
372
373 const atl::InstrumentId instrument{atl::Country::KR, atl::Venue::COMBINED, arguments.symbol_};
374 auto settings = settings_for(instrument);
375 // A Kiwoom order must name its venue (`dmst_stex_tp` has no default), and a strategy's orders name
376 // none, so the binding states where they go. KRX here; `Venue::NXT` for Nextrade, or
377 // `Venue::COMBINED` for Kiwoom's SOR, which its order endpoints document -- whether a demo account
378 // accepts SOR, and whether the listing's `sor_yn` flag reads as documented, has not been observed,
379 // so KRX is the route with the fewest open questions.
380 settings.default_route_ = atl::Venue::KRX;
381 name_journal(settings, arguments, "kiwoom", demo, accounts.value().front().display_number_);
382 announce(arguments, settings, demo, "KIWOOM_DEMO");
383 // Two reasons nothing is placed on Kiwoom yet, said up front so nobody waits for an order that
384 // cannot come. Both are statements you can make:
385 // - Holdings refuse until the scopes above are asserted, so the loop has no portfolio and holds.
386 // - Kiwoom publishes no trading calendar, so the market phase stays unknown, and the default
387 // limits open a position only while the market is open.
388 std::cout
389 << "note : on Kiwoom this program places nothing yet -- holdings need a stated\n"
390 << " scope, and the market phase is unknown without a calendar\n";
391 return run(session, instrument, settings, arguments.live_);
392}
393
394int run_toss(ssl::context& tls, const Arguments& arguments) {
395 namespace toss = algotradelib::tossinvest;
396
397 toss::TossConfig config;
398 config.from_env();
399 std::cout << "credentials: environment variables (Toss reads no credentials directory)\n";
400 auto client = std::make_shared<toss::TossBlockingClient>(
401 tls, std::move(config), atl::network::HttpClientOptions{}, token_store(arguments)
402 );
403
404 // Toss selects an account by sequence number and publishes the list. With one account that is the
405 // one; with several, the program will not guess which should trade, because a sequence is a request
406 // selector rather than an identity.
407 const int unresolved = static_cast<int>(live_program::Exit::ACCOUNT_UNRESOLVED);
408 auto accounts = atl::list_accounts(*client);
409 if (!accounts || accounts.value().empty()) {
410 std::cerr
411 << "could not list the accounts these Toss credentials reach"
412 << (accounts ? std::string() : ": " + accounts.error().message_) << '\n';
413 return unresolved;
414 }
415 if (!arguments.toss_account_ && accounts.value().size() > 1) {
416 std::cerr
417 << "these Toss credentials reach " << accounts.value().size() << " accounts; choose one with --toss-account:\n";
418 for (const auto& account : accounts.value()) {
419 std::cerr << " --toss-account " << account.selector_ << " (" << account.type_ << ")\n";
420 }
421 return unresolved;
422 }
423 auto chosen = accounts.value().front();
424 if (arguments.toss_account_) {
425 bool found = false;
426 for (const auto& account : accounts.value()) {
427 if (account.selector_ == *arguments.toss_account_) {
428 chosen = account;
429 found = true;
430 }
431 }
432 if (!found) {
433 std::cerr << "no Toss account has sequence " << *arguments.toss_account_ << '\n';
434 return unresolved;
435 }
436 }
437 if (chosen.display_number_.empty()) {
438 std::cerr
439 << "Toss reported no account number for sequence " << chosen.selector_
440 << ", so the journal could not be named after the account\n";
441 return unresolved;
442 }
443
444 const atl::InstrumentId instrument{atl::Country::KR, atl::Venue::COMBINED, arguments.symbol_};
445 auto settings = settings_for(instrument);
446 // Named after the account number, not the sequence: two credential sets can both have a sequence 1,
447 // and a journal that one account's run could continue would read its orders as the other's.
448 name_journal(settings, arguments, "toss", false, chosen.display_number_);
449 announce(arguments, settings, false, nullptr);
450 std::cout << "note : Toss has no paper-trading environment; --live trades real money\n";
451
452 atl::BlockingSession<toss::TossBlockingClient> session(std::move(client), chosen.selector_);
453 return run(session, instrument, settings, arguments.live_);
454}
455
457std::optional<Arguments> parse(int argc, char** argv) {
458 Arguments arguments;
459 const int given = argc;
460 try {
461 arguments.credentials_ = kis_credentials::take_directory(argc, argv);
462 arguments.credentials_from_flag_ = argc != given;
463 arguments.kiwoom_account_ = kiwoom_credentials::take_label(argc, argv);
464 } catch (const std::runtime_error& error) {
465 std::cerr << "example-live-program: " << error.what() << '\n';
466 return std::nullopt;
467 }
468 std::vector<std::string> positional;
469 for (int i = 1; i < argc; ++i) {
470 const std::string argument = argv[i];
471 const bool has_value = i + 1 < argc;
472 if (argument == "--live") {
473 arguments.live_ = true;
474 } else if (argument == "--journal" && has_value) {
475 arguments.journal_ = argv[++i];
476 } else if (argument == "--control" && has_value) {
477 arguments.control_ = argv[++i];
478 } else if (argument == "--tokens" && has_value) {
479 arguments.tokens_ = argv[++i];
480 } else if (argument == "--toss-account" && has_value) {
481 arguments.toss_account_ = std::strtoll(argv[++i], nullptr, 10);
482 } else if (argument == "--market-data" && has_value) {
483 arguments.market_data_ = argv[++i];
484 if (*arguments.market_data_ != "kis" && *arguments.market_data_ != "toss") {
485 return std::nullopt;
486 }
487 } else if (argument.rfind("--", 0) == 0) {
488 return std::nullopt;
489 } else {
490 positional.push_back(argument);
491 }
492 }
493 if (positional.size() != 2) {
494 return std::nullopt;
495 }
496 arguments.broker_ = positional[0];
497 arguments.symbol_ = positional[1];
498 if (arguments.broker_ != "kis" && arguments.broker_ != "kiwoom" && arguments.broker_ != "toss") {
499 return std::nullopt;
500 }
501 // A setting the chosen broker would ignore is refused: ignored, it would trade whichever account
502 // the environment names. Market data is KIS's; Toss reads only its environment variables; the
503 // label selects a Kiwoom file.
504 if (arguments.market_data_ && arguments.broker_ != "kis") {
505 return std::nullopt;
506 }
507 if (arguments.credentials_from_flag_ && arguments.broker_ == "toss") {
508 return std::nullopt;
509 }
510 if (arguments.kiwoom_account_ && arguments.broker_ != "kiwoom") {
511 return std::nullopt;
512 }
513 return arguments;
514}
515
516} // namespace
517
525int main(int argc, char** argv) {
526 const auto arguments = parse(argc, argv);
527 if (!arguments) {
528 std::cerr
529 << "usage: example-live-program <kis|kiwoom|toss> <symbol> [--live] [--journal PATH]\n"
530 << " [--control PATH] [--toss-account SEQUENCE]\n"
531 << " [--credentials DIR] [--market-data kis|toss]\n"
532 << " [--kiwoom-account LABEL] [--tokens DIR]\n\n"
533 << "Without --live it observes: nothing can be sent. KIS and Kiwoom are demo unless\n"
534 << "KIS_DEMO=0 / KIWOOM_DEMO=0; Toss has no demo, so toss --live trades real money.\n";
535 return 64;
536 }
537
538 try {
539 ssl::context tls(ssl::context::tls_client);
540 tls.set_default_verify_paths();
541 tls.set_verify_mode(ssl::verify_peer);
542
543 if (arguments->broker_ == "kis") {
544 return run_kis(tls, *arguments);
545 }
546 if (arguments->broker_ == "kiwoom") {
547 return run_kiwoom(tls, *arguments);
548 }
549 return run_toss(tls, *arguments);
550 } catch (const std::exception& exception) {
551 std::cerr << "example-live-program: " << exception.what() << '\n';
552 return 70;
553 }
554}
A blocking broker client bound to one account, with the same broker operations as BrokerSession,...
Result< std::vector< AccountInfo< Client > > > accounts()
Lists the broker's accounts; requires Caps::has_account_discovery.
static Decimal64 parse(std::string_view input)
Parses a decimal string exactly (no binary floating point).
Definition types.hpp:468
void from_json(const std::string &filename)
Loads the credentials from a JSON file, in the broker's format.
Definition oauth.hpp:57
static void install(StopSource &source) noexcept
Installs the handlers: SIGINT and SIGTERM request a quiesce on source; SIGHUP, where it exists,...
static void uninstall() noexcept
Restores the default disposition of SIGINT, SIGTERM and (POSIX) SIGHUP, and forgets the source.
A stop request the loop polls; safe to set from a signal handler.
Definition stop.hpp:163
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.
std::optional< algotradelib::kis::KisConfig > market_data_config(const std::optional< std::filesystem::path > &directory)
Returns a configuration for market data alone, from DIR/kis/real.json.
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.
The examples' Kiwoom credentials: one JSON file per key, or the environment.
algotradelib::network::HttpClientOptions paced_options()
Returns transport options that pace a Kiwoom client at one request a second.
std::optional< std::string > take_label(int &argc, char **argv)
Removes --kiwoom-account LABEL from the command line and returns the label.
void load(const std::optional< std::filesystem::path > &directory, const std::optional< std::string > &label, algotradelib::kiwoom::KiwoomConfig &config, std::ostream &out)
Loads the credentials from DIR/kiwoom/{demo,real}-LABEL.json (as KIWOOM_DEMO chooses; label kr by def...
The production wiring of a live run, with no broker named: the part of example-live-program a consume...
Exit observe(Session &session, MarketData &market_data, Strategy strategy_instance, const Settings &settings, runner::StopSource &stop, std::ostream &out, Clock clock={})
Runs a strategy against a session's account and another's market data, with nothing to send through.
@ ACCOUNT_UNRESOLVED
The program could not settle which account to trade (used by example-live-program).
Exit trade(Session &session, MarketData &market_data, Strategy strategy_instance, const Settings &settings, runner::StopSource &stop, std::ostream &out, Clock clock={})
Trades a strategy through a session, reading market data and reference data from another.
The Korea Investment & Securities (KIS) Open API client.
Definition auth.hpp:9
The Kiwoom Securities REST API client.
Definition auth.hpp:12
Runs a strategy: the runner, the polling loop, the order journal, and stopping.
Definition clock.hpp:7
void stop(S &strategy, Ctx &context)
Calls strategy.on_stop(context) if the strategy declares on_stop; otherwise does nothing.
Definition concept.hpp:259
void bar(S &strategy, Ctx &context, const BarEvent &event)
Calls strategy.on_bar(context, event) if the strategy declares on_bar; otherwise does nothing.
Definition concept.hpp:282
What a strategy sees and emits: events, intents, the portfolio, reconciliation and risk limits.
Definition concept.hpp:16
The Toss Securities Open API client.
Definition auth.hpp:9
The library: broker-neutral types (core), and the modules below.
Result< std::vector< AccountInfo< Client > > > list_accounts(Client &client)
Lists a broker's accounts with a blocking client, before a session exists; requires BrokerCaps<Client...
constexpr std::string_view venue_name(Venue venue) noexcept
Returns a display name for a venue, such as "KRX".
Definition types.hpp:60
Identifies an instrument: its country, venue and symbol.
Definition types.hpp:85
Deadlines, size limits and pacing for an HTTP client.
std::optional< std::chrono::nanoseconds > holdings_
How often to read holdings; without it the portfolio is never refreshed.
Definition loop.hpp:197
std::optional< std::chrono::nanoseconds > price_limits_
How often to read today's price bands.
Definition loop.hpp:233
std::optional< std::chrono::nanoseconds > bars_
How often to fetch bars.
Definition loop.hpp:193
std::optional< std::chrono::nanoseconds > working_orders_
How often to read the working orders.
Definition loop.hpp:207
std::optional< Decimal64 > max_position_quantity_
The largest absolute position, in shares, any instrument may reach.
Definition risk.hpp:421
std::optional< std::size_t > max_orders_per_window_
The most orders that may be sent within rate_window_.
Definition risk.hpp:437
std::optional< Decimal64 > max_order_notional_
The largest value one order may have, in its own currency.
Definition risk.hpp:414
InstrumentId instrument_
The instrument.
Definition intent.hpp:453
std::string tag_
A label carried to the orders and their fills.
Definition intent.hpp:459
Decimal64 target_quantity_
The position to hold, signed: negative is short, and zero means flat.
Definition intent.hpp:455
Toss Securities credentials (client id and secret). Toss has no demo environment.
Definition config.hpp:27
What a run is told, gathered so main states it once and a test can state it differently.
std::vector< atl::InstrumentId > universe_
The instruments the source polls.
std::string journal_path_
Where the order journal lives.
std::chrono::nanoseconds maximum_portfolio_age_
How old a holdings snapshot – and the order listing – may be before the loop stops sizing against it.
std::chrono::nanoseconds maximum_price_limits_age_
How old a price band may be before the loop stops clamping to it.
std::string control_file_
The file an operator writes quiesce, withdraw or flatten into to stop the run.
runner::PollSchedule schedule_
How often each kind is polled. trade needs working_orders_ set, shorter than maximum_portfolio_age_: ...
atl::Venue default_route_
The venue an order is sent to, since a strategy's orders name none; UNSPECIFIED takes the broker's ow...
std::string journal_scope_
Which account the journal belongs to; a journal naming another refuses to open.
strategy::RiskLimits limits_
The limits the guard enforces.