algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::SessionEdges Class Reference

Follows a strategy's bars and says which bar opens its session and which closes it, by the session window, whatever the bar interval. More...

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

Public Member Functions

SessionEdge next (const BarEvent &event, const SessionWindow &session)
 Decides whether the next bar opens or closes its session.
std::size_t opened () const noexcept
 Returns how many sessions a bar has opened so far.
std::size_t closed () const noexcept
 Returns how many sessions a bar has closed so far.
std::size_t outside () const noexcept
 Returns how many bars lay wholly outside their session (before its open or after its close).

Detailed Description

Follows a strategy's bars and says which bar opens its session and which closes it, by the session window, whatever the bar interval.

Bar-driven: a bar is known at its period end, so the bar that opens a session is known at the end of its first period (a minute after the open on minute bars, at the close on a daily bar), and the bar that closes it at the close or after. A session with no bar reaching its close has no closing bar. A daily bar is both the opening and the closing bar of its session; a daily bar stamped at the open (a point) before one stamped at the close opens the session, and the second closes it.

Which minute bar closes depends on its stamp: of start-stamped KRX minute bars, the 15:29 bar (its period, 15:29 to 15:30, holds the close), and the 15:30 auction bar after it closes nothing more; of end-stamped ones, the bar stamped 15:30. Bars wholly before the open or after the close count in outside() and close nothing. Under the KRX window a close-stamped daily bar at midnight UTC is a point at the open (09:00 KST), which opens the session and closes nothing; one at midnight KST ends before its session opens and is neither edge.

Feed it the bars of one series, or the first bar of each BarSlice (one interval), in time order.

Definition at line 450 of file event.hpp.

Member Function Documentation

◆ closed()

std::size_t algotradelib::strategy::SessionEdges::closed ( ) const
inlinenoexcept

Returns how many sessions a bar has closed so far.

Returns
The count; zero tells a tool that no bar's period held a session's close.

Definition at line 497 of file event.hpp.

◆ next()

SessionEdge algotradelib::strategy::SessionEdges::next ( const BarEvent & event,
const SessionWindow & session )
inline

Decides whether the next bar opens or closes its session.

Parameters
eventThe bar, later than the previous one.
sessionThe session window.
Returns
Its edges.

Definition at line 458 of file event.hpp.

◆ opened()

std::size_t algotradelib::strategy::SessionEdges::opened ( ) const
inlinenoexcept

Returns how many sessions a bar has opened so far.

Returns
The count; zero tells a tool that the bars never reached into a session.

Definition at line 489 of file event.hpp.

◆ outside()

std::size_t algotradelib::strategy::SessionEdges::outside ( ) const
inlinenoexcept

Returns how many bars lay wholly outside their session (before its open or after its close).

Returns
The count; above zero, pre-market or after-hours bars are in the data.

Definition at line 505 of file event.hpp.


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