algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::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.

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.

Definition at line 106 of file event.hpp.

Member Function Documentation

◆ krx()

SessionWindow algotradelib::strategy::SessionWindow::krx ( )
inlinestatic

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

Returns
The default window.

Definition at line 120 of file event.hpp.

Referenced by main(), and algotradelib::backtest::ReplayClock::ReplayClock().

◆ 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 162 of file event.hpp.

Referenced by main().

◆ 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 175 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 131 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 110 of file event.hpp.

Referenced by algotradelib::backtest::periods_per_year(), and phase().

◆ open_

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

The session open, in minutes from local midnight.

Definition at line 108 of file event.hpp.

Referenced by opens_at(), algotradelib::backtest::periods_per_year(), and phase().

◆ 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 114 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 112 of file event.hpp.

Referenced by opens_at(), and phase().


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