dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::Session Struct Reference

Session represents a continuous period of time during which apply same rules regarding trading activity. More...

#include <Session.hpp>

Public Types

using Ptr = std::shared_ptr<Session>
 The alias to a type of shared pointer to the Session object.
 
using Unique = std::unique_ptr<Session>
 The alias to a type of unique pointer to the Session object.
 

Public Member Functions

Day::Ptr getDay () const noexcept
 Returns day to which this session belongs.
 
const SessionTypegetType () const &noexcept
 Returns type of this session.
 
bool isTrading () const noexcept
 
bool isEmpty () const noexcept
 
std::int64_t getStartTime () const noexcept
 
std::int64_t getEndTime () const noexcept
 
bool containsTime (std::int64_t time) const noexcept
 
Session::Ptr getPrevSession (const SessionFilter &filter) const noexcept
 Returns previous session accepted by specified filter.
 
Session::Ptr getNextSession (const SessionFilter &filter) const noexcept
 Returns following session accepted by specified filter.
 
Session::Ptr findPrevSession (const SessionFilter &filter) const noexcept
 Returns previous session accepted by specified filter.
 
Session::Ptr findNextSession (const SessionFilter &filter) const noexcept
 Returns following session accepted by specified filter.
 
bool operator== (const Session &other) const noexcept
 Returns true if this object is equal to other object.
 
bool operator== (const Session::Ptr &other) const noexcept
 Returns true if this object is equal to other object.
 
std::size_t getHashCode () const noexcept
 
std::string toString () const noexcept
 Returns a string representation of the current object.
 

Detailed Description

Session represents a continuous period of time during which apply same rules regarding trading activity.

For example, regular trading session is a period of time consisting of one day of business activities in a financial market, from the opening bell to the closing bell, when regular trading occurs.

Sessions can be either trading or non-trading, with different sets of rules and reasons to exist. Sessions do not overlap with each other - rather they form consecutive chain of adjacent periods of time that cover entire time scale. The point on a border line is considered to belong to following session that starts there. Each session completely fits inside a certain day. Day may contain sessions with zero duration - e.g. indices that post value once a day. Such sessions can be of any appropriate type, trading or non-trading.

Member Function Documentation

◆ containsTime()

bool dxfcpp::Session::containsTime ( std::int64_t time) const
noexcept
Returns
true if specified time belongs to this session.

◆ findNextSession()

Session::Ptr dxfcpp::Session::findNextSession ( const SessionFilter & filter) const
noexcept

Returns following session accepted by specified filter.

This method may cross the day boundary and return appropriate session from following days - up to a year in the future. If no such session was found within one year this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

To find following trading session of any type use this code:

session = session->findNextSession(SessionFilter::TRADING);

To find following regular trading session use this code:

session = session->findNextSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
nearest following session that is accepted by the filter

◆ findPrevSession()

Session::Ptr dxfcpp::Session::findPrevSession ( const SessionFilter & filter) const
noexcept

Returns previous session accepted by specified filter.

This method may cross the day boundary and return appropriate session from previous days - up to a year back in time. If no such session was found within one year this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

To find previous trading session of any type use this code:

session = session->findPrevSession(SessionFilter::TRADING);

To find previous regular trading session use this code:

session = session->findPrevSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
nearest previous session that is accepted by the filter

◆ getDay()

Day::Ptr dxfcpp::Session::getDay ( ) const
noexcept

Returns day to which this session belongs.

Returns
The day to which this session belongs.

◆ getEndTime()

std::int64_t dxfcpp::Session::getEndTime ( ) const
noexcept
Returns
end time of this session (exclusive). For normal sessions the end time is greater than the start time, for empty sessions they are equal.

◆ getHashCode()

std::size_t dxfcpp::Session::getHashCode ( ) const
noexcept
Returns
A hash code value for this object.

◆ getNextSession()

Session::Ptr dxfcpp::Session::getNextSession ( const SessionFilter & filter) const
noexcept

Returns following session accepted by specified filter.

This method may cross the day boundary and return appropriate session from following days - up to a year in the future. If no such session was found within one year this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

To find following trading session of any type use this code:

session = session->getNextSession(SessionFilter::TRADING);

To find following regular trading session use this code:

session = session->getNextSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
The nearest following session that is accepted by the filter or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if no such session was found within one year

◆ getPrevSession()

Session::Ptr dxfcpp::Session::getPrevSession ( const SessionFilter & filter) const
noexcept

Returns previous session accepted by specified filter.

This method may cross the day boundary and return appropriate session from previous days - up to a year back in time. If no such session was found within one year this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

To find previous trading session of any type use this code:

session = session->getPrevSession(SessionFilter::TRADING);

To find previous regular trading session use this code:

session = session->getPrevSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
The nearest previous session that is accepted by the filter or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if no such session was found within one year

◆ getStartTime()

std::int64_t dxfcpp::Session::getStartTime ( ) const
noexcept
Returns
start time of this session (inclusive). For normal sessions the start time is less than the end time, for empty sessions they are equal.

◆ getType()

const SessionType & dxfcpp::Session::getType ( ) const &
noexcept

Returns type of this session.

Returns
The type of this session.

◆ isEmpty()

bool dxfcpp::Session::isEmpty ( ) const
noexcept
Returns
true if this session has zero duration. Empty sessions can be used for indices that post value once a day or for convenience. Such sessions can be of any appropriate type, trading or non-trading.

◆ isTrading()

bool dxfcpp::Session::isTrading ( ) const
noexcept
Returns
true if trading activity is allowed within this session. This method is equivalent to expression getType().isTrading().

Some sessions may have zero duration - e.g. indices that post value once a day. Such sessions can be of any appropriate type, trading or non-trading.

◆ operator==() [1/2]

bool dxfcpp::Session::operator== ( const Session & other) const
noexcept

Returns true if this object is equal to other object.

Parameters
otherAnother object
Returns
true if this object is equal to other object

◆ operator==() [2/2]

bool dxfcpp::Session::operator== ( const Session::Ptr & other) const
inlinenoexcept

Returns true if this object is equal to other object.

Parameters
otherAnother object
Returns
true if this object is equal to other object

◆ toString()

std::string dxfcpp::Session::toString ( ) const
noexcept

Returns a string representation of the current object.

Returns
a string representation