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

How often a PollingLoop polls each kind; an unset interval disables that poll. More...

#include <algotradelib/src/runner/loop.hpp>

Public Member Functions

std::optional< std::chrono::nanoseconds > interval_for (PollKind kind) const noexcept
 Returns the interval for a poll kind.

Public Attributes

std::optional< std::chrono::nanoseconds > bars_
 How often to fetch bars.
std::optional< std::chrono::nanoseconds > quotes_
 How often to fetch quotes.
std::optional< std::chrono::nanoseconds > holdings_
 How often to read holdings; without it the portfolio is never refreshed.
std::optional< std::chrono::nanoseconds > working_orders_
 How often to read the working orders.
std::optional< std::chrono::nanoseconds > buying_power_
 How often to read buying power.
std::chrono::nanoseconds tick_ {std::chrono::seconds(1)}
 The loop's step, which bounds how quickly a stop is noticed; not a poll.
std::optional< std::chrono::nanoseconds > calendar_ {std::chrono::hours(6)}
 How often to read the trading calendar; six hours by default.
std::optional< std::chrono::nanoseconds > price_limits_
 How often to read today's price bands.
std::optional< std::chrono::nanoseconds > data_
 How often to call the data poll (PollingLoop::set_data_poll); without it, or without a data poll, no record is read.

Detailed Description

How often a PollingLoop polls each kind; an unset interval disables that poll.

Only calendar_ is on by default. tick_ is the loop's own step: it bounds how quickly a stop is noticed, even when no poll is due.

Note
Members are positional in aggregate initialization (PollSchedule{std::chrono::seconds(5)} sets bars_); new members are appended.

Definition at line 191 of file loop.hpp.

Member Function Documentation

◆ interval_for()

std::optional< std::chrono::nanoseconds > algotradelib::runner::PollSchedule::interval_for ( PollKind kind) const
inlinenoexcept

Returns the interval for a poll kind.

Parameters
kindThe kind.
Returns
The interval, or std::nullopt if that poll is disabled.

Definition at line 244 of file loop.hpp.

Member Data Documentation

◆ bars_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::bars_

How often to fetch bars.

Definition at line 193 of file loop.hpp.

Referenced by interval_for(), and main().

◆ buying_power_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::buying_power_

How often to read buying power.

With RiskLimits::enforce_buying_power_ on and this unset, every placement is held (BUYING_POWER_UNREAD). Read only from a source whose broker reports buying power (source_reports_buying_power).

Definition at line 215 of file loop.hpp.

Referenced by interval_for().

◆ calendar_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::calendar_ {std::chrono::hours(6)}

How often to read the trading calendar; six hours by default.

Without a calendar the phase is UNKNOWN and the default RiskLimits::permitted_phases_ refuses every order that opens or increases a position (closing a position is still allowed). Keep it under the nine hours between local midnight and a 09:00 open. KIS's client caches the calendar, so four polls a day cost about one request.

Definition at line 226 of file loop.hpp.

Referenced by interval_for(), and main().

◆ data_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::data_

How often to call the data poll (PollingLoop::set_data_poll); without it, or without a data poll, no record is read.

Definition at line 238 of file loop.hpp.

Referenced by interval_for().

◆ holdings_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::holdings_

How often to read holdings; without it the portfolio is never refreshed.

Definition at line 197 of file loop.hpp.

Referenced by interval_for().

◆ price_limits_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::price_limits_

How often to read today's price bands.

A band is valid for one trading day. Bands are applied only under an age policy; see PollingLoop::set_maximum_price_limits_age.

Definition at line 233 of file loop.hpp.

Referenced by interval_for(), and main().

◆ quotes_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::quotes_

How often to fetch quotes.

Definition at line 195 of file loop.hpp.

Referenced by interval_for().

◆ tick_

std::chrono::nanoseconds algotradelib::runner::PollSchedule::tick_ {std::chrono::seconds(1)}

The loop's step, which bounds how quickly a stop is noticed; not a poll.

Definition at line 217 of file loop.hpp.

Referenced by main().

◆ working_orders_

std::optional<std::chrono::nanoseconds> algotradelib::runner::PollSchedule::working_orders_

How often to read the working orders.

Do not make it shorter than holdings_: a listing newer than the holdings withholds every plan as PORTFOLIO_SUPERSEDED (equal cadences read both in one iteration, listing first). Required for a runner that sends to a broker: without it, or when the last listing is older than PollingLoop::set_maximum_portfolio_age, the loop holds placements as PORTFOLIO_STALE (leave a tick of margin between the cadence and the age).

Definition at line 207 of file loop.hpp.

Referenced by interval_for().


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