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

The intraday session of a market, as the operator states it. More...

#include <algotradelib/src/strategy/event.hpp>

Public Member Functions

MarketPhase phase (std::chrono::system_clock::time_point now, std::optional< bool > trading_day) const
 Returns the market phase at an instant.
Date local_date (std::chrono::system_clock::time_point now) const
 Returns the market's local date at an instant.
std::chrono::system_clock::time_point opens_at (std::chrono::system_clock::time_point now) const
 Returns the instant the session opens on the local date of an instant.
std::chrono::system_clock::time_point closes_at (std::chrono::system_clock::time_point now) const
 Returns the instant the session closes on the local date of an instant.

Static Public Member Functions

static SessionWindow krx ()
 Returns the KRX regular session, 09:00-15:30 KST.

Public Attributes

std::chrono::minutes open_ {std::chrono::hours(9)}
 The session open, in minutes from local midnight.
std::chrono::minutes close_ {std::chrono::hours(15) + std::chrono::minutes(30)}
 The session close, in minutes from local midnight.
std::chrono::minutes utc_offset_ {std::chrono::hours(9)}
 The market's offset from UTC.
std::string source_ {"KRX regular session, 09:00-15:30 KST (library default)"}
 A description of where the window came from, for reports.

Detailed Description

The intraday session of a market, as the operator states it.

Times are minutes from local midnight, with a fixed UTC offset. The default is the KRX regular session, 09:00-15:30 KST.

Note
The offset is fixed: a market that observes daylight saving needs a different window each season, or an adapter that fills each day's session hours (see stated_session_phase).

Definition at line 122 of file event.hpp.

Member Function Documentation

◆ closes_at()

std::chrono::system_clock::time_point algotradelib::strategy::SessionWindow::closes_at ( std::chrono::system_clock::time_point now) const
inline

Returns the instant the session closes on the local date of an instant.

Parameters
nowAny instant on the date in question.
Returns
The close of local_date(now), whether or not that date trades.

Definition at line 197 of file event.hpp.

◆ krx()

Returns the KRX regular session, 09:00-15:30 KST.

Returns
The default window.

Definition at line 136 of file event.hpp.

◆ local_date()

Date algotradelib::strategy::SessionWindow::local_date ( std::chrono::system_clock::time_point now) const
inline

Returns the market's local date at an instant.

Ask the TradingCalendar about this date, not the machine's own: in another time zone they differ for part of each day.

Parameters
nowThe instant.
Returns
The date in the market's time zone.

Definition at line 176 of file event.hpp.

◆ opens_at()

std::chrono::system_clock::time_point algotradelib::strategy::SessionWindow::opens_at ( std::chrono::system_clock::time_point now) const
inline

Returns the instant the session opens on the local date of an instant.

Parameters
nowAny instant on the date in question.
Returns
The open of local_date(now), whether or not that date trades.

Definition at line 187 of file event.hpp.

◆ phase()

MarketPhase algotradelib::strategy::SessionWindow::phase ( std::chrono::system_clock::time_point now,
std::optional< bool > trading_day ) const
inline

Returns the market phase at an instant.

Parameters
nowThe instant.
trading_dayWhether now's local date (see local_date) is a trading day, as TradingCalendar::is_trading_day answered it.
Returns
UNKNOWN if trading_day is empty, CLOSED if it is false, and otherwise PRE_OPEN, OPEN or POST_CLOSE by local time. The open is inclusive, the close exclusive.

Definition at line 149 of file event.hpp.

Member Data Documentation

◆ close_

std::chrono::minutes algotradelib::strategy::SessionWindow::close_ {std::chrono::hours(15) + std::chrono::minutes(30)}

The session close, in minutes from local midnight.

Definition at line 126 of file event.hpp.

◆ open_

std::chrono::minutes algotradelib::strategy::SessionWindow::open_ {std::chrono::hours(9)}

The session open, in minutes from local midnight.

Definition at line 124 of file event.hpp.

◆ source_

std::string algotradelib::strategy::SessionWindow::source_ {"KRX regular session, 09:00-15:30 KST (library default)"}

A description of where the window came from, for reports.

Definition at line 130 of file event.hpp.

◆ utc_offset_

std::chrono::minutes algotradelib::strategy::SessionWindow::utc_offset_ {std::chrono::hours(9)}

The market's offset from UTC.

Definition at line 128 of file event.hpp.


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