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.

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 169 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 216 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 171 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).

Definition at line 192 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 203 of file loop.hpp.

Referenced by interval_for(), and main().

◆ 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 175 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 210 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 173 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 194 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 185 of file loop.hpp.

Referenced by interval_for().


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