dxFeed Graal CXX API
Loading...
Searching...
No Matches
Day Struct Reference

Day represents a continuous period of time approximately 24 hours long. More...

#include <Day.hpp>

Public Types

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

Public Member Functions

std::shared_ptr< SchedulegetSchedule () const noexcept
 
std::int32_t getDayId () const noexcept
 
std::int32_t getYearMonthDay () const noexcept
 Returns year, month and day numbers packed in the following way:
 
std::int32_t getYear () const noexcept
 
std::int32_t getMonthOfYear () const noexcept
 
std::int32_t getDayOfMonth () const noexcept
 
std::int32_t getDayOfWeek () const noexcept
 
bool isHoliday () const noexcept
 
bool isShortDay () const noexcept
 
bool isTrading () const noexcept
 
std::int64_t getStartTime () const noexcept
 
std::int64_t getEndTime () const noexcept
 
bool containsTime (std::int64_t time) const noexcept
 
std::int64_t getResetTime () const noexcept
 
std::shared_ptr< SessiongetSessionByTime (std::int64_t time) const noexcept
 Returns session belonging to this day that contains specified time.
 
std::shared_ptr< SessiongetFirstSession (const SessionFilter &filter) const noexcept
 Returns first session belonging to this day accepted by specified filter.
 
std::shared_ptr< SessiongetLastSession (const SessionFilter &filter) const noexcept
 Returns last session belonging to this day accepted by specified filter.
 
std::shared_ptr< SessionfindFirstSession (const SessionFilter &filter) const noexcept
 Returns first session belonging to this day accepted by specified filter.
 
std::shared_ptr< SessionfindLastSession (const SessionFilter &filter) const noexcept
 Returns last session belonging to this day accepted by specified filter.
 
Day::Ptr getPrevDay (const DayFilter &filter) const noexcept
 Returns previous day accepted by specified filter.
 
Day::Ptr getNextDay (const DayFilter &filter) const noexcept
 Returns following day accepted by specified filter.
 
Day::Ptr findPrevDay (const DayFilter &filter) const noexcept
 Returns previous day accepted by specified filter.
 
Day::Ptr findNextDay (const DayFilter &filter) const noexcept
 Returns following day accepted by specified filter.
 
bool operator== (const Day &other) const noexcept
 Returns true if this object is equal to other object.
 
bool operator== (const Day::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.
 

Friends

struct Schedule
 
struct Session
 

Detailed Description

Day represents a continuous period of time approximately 24 hours long.

The day is aligned to the start and the end of business activities of a certain business entity or business process. For example, the day may be aligned to a trading schedule of a particular instrument on an exchange. Thus, different days may start and end at various local times depending on the related trading schedules.

The length of the day depends on the trading schedule and other circumstances. For example, it is possible that day for Monday is longer than 24 hours because it includes part of Sunday; consequently, the day for Sunday will be shorter than 24 hours to avoid overlapping with Monday.

Days 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 day that starts there.

Each day consists of sessions that cover entire duration of the day. If day contains at least one trading session (i.e. session within which trading activity is allowed), then the day is considered trading day. Otherwise the day is considered non-trading day (e.g. weekend or holiday).

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. Day may have zero duration as well - e.g. when all time within it is transferred to other days.

Member Function Documentation

◆ containsTime()

bool Day::containsTime ( std::int64_t time) const
noexcept
Returns
true if specified time belongs to this day.

◆ findFirstSession()

std::shared_ptr< Session > Day::findFirstSession ( const SessionFilter & filter) const
noexcept

Returns first session belonging to this day accepted by specified filter.

This method does not cross the day boundary. If no such session was found within this day this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr})

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

auto session = day->findFirstSession(SessionFilter::TRADING);

To find first regular trading session use this code:

auto session = day->findFirstSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
The first session that is accepted by the filter

◆ findLastSession()

std::shared_ptr< Session > Day::findLastSession ( const SessionFilter & filter) const
noexcept

Returns last session belonging to this day accepted by specified filter.

This method does not cross the day boundary. If no such session was found within this day this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr})

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

auto session = day->findLastSession(SessionFilter::TRADING);

To find last regular trading session use this code:

auto session = day->findLastSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
The last session that is accepted by the filter

◆ findNextDay()

Day::Ptr Day::findNextDay ( const DayFilter & filter) const
noexcept

Returns following day accepted by specified filter.

This method looks for appropriate day up to a year in the future. If no such day was found within one year this method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}).

Parameters
filterThe filter to test days
Returns
The nearest following day that is accepted by the filter

◆ findPrevDay()

Day::Ptr Day::findPrevDay ( const DayFilter & filter) const
noexcept

Returns previous day accepted by specified filter.

This method looks for appropriate day up to a year back in time. If no such day was found within one year this method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}).

Parameters
filterThe filter to test days
Returns
The nearest previous day that is accepted by the filter

◆ getDayId()

std::int32_t Day::getDayId ( ) const
noexcept
Returns
The number of this day since January 1, 1970 (that day has identifier of 0 and previous days have negative identifiers).

◆ getDayOfMonth()

std::int32_t Day::getDayOfMonth ( ) const
noexcept
Returns
The ordinal day number in the month starting with 1 for the first day of month.

◆ getDayOfWeek()

std::int32_t Day::getDayOfWeek ( ) const
noexcept
Returns
The ordinal day number in the week starting with 1=Monday and ending with 7=Sunday.

◆ getEndTime()

std::int64_t Day::getEndTime ( ) const
noexcept
Returns
The end time of this day (exclusive).

◆ getFirstSession()

std::shared_ptr< Session > Day::getFirstSession ( const SessionFilter & filter) const
noexcept

Returns first session belonging to this day accepted by specified filter.

This method does not cross the day boundary. If no such session was found within this day this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr})

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

Session session = day->getFirstSession(SessionFilter::TRADING);

To find first regular trading session use this code:

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

◆ getHashCode()

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

◆ getLastSession()

std::shared_ptr< Session > Day::getLastSession ( const SessionFilter & filter) const
noexcept

Returns last session belonging to this day accepted by specified filter.

This method does not cross the day boundary. If no such session was found within this day this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr})

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

auto session = day->getLastSession(SessionFilter::TRADING);

To find last regular trading session use this code:

auto session = day->getLastSession(SessionFilter::REGULAR);
Parameters
filterThe filter to test sessions
Returns
The last session that is accepted by the filter or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if no such session was found within this day

◆ getMonthOfYear()

std::int32_t Day::getMonthOfYear ( ) const
noexcept
Returns
The calendar month number in the year starting with 1=January and ending with 12=December.

◆ getNextDay()

Day::Ptr Day::getNextDay ( const DayFilter & filter) const
noexcept

Returns following day accepted by specified filter.

This method looks for appropriate day up to a year in the future. If no such day was found within one year this method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}).

Parameters
Thefilter the filter to test days
Returns
The nearest following day that is accepted by the filter or Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if no such day was found within one year

◆ getPrevDay()

Day::Ptr Day::getPrevDay ( const DayFilter & filter) const
noexcept

Returns previous day accepted by specified filter.

This method looks for appropriate day up to a year back in time. If no such day was found within one year this method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}).

Parameters
Thefilter the filter to test days
Returns
The nearest previous day that is accepted by the filter or Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if no such day was found within one year

◆ getResetTime()

std::int64_t Day::getResetTime ( ) const
noexcept
Returns
The reset time for this day. Reset of daily data is performed on trading days only, the result has no meaning for non-trading days.

◆ getSchedule()

std::shared_ptr< Schedule > Day::getSchedule ( ) const
noexcept
Returns
The schedule to which this day belongs.

◆ getSessionByTime()

std::shared_ptr< Session > Day::getSessionByTime ( std::int64_t time) const
noexcept

Returns session belonging to this day that contains specified time.

If no such session was found within this day this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

Parameters
timeThe time to search for
Returns
The session that contains specified time or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if no such session was found within this day

◆ getStartTime()

std::int64_t Day::getStartTime ( ) const
noexcept
Returns
The start time of this day (inclusive).

◆ getYear()

std::int32_t Day::getYear ( ) const
noexcept
Returns
The calendar year - i.e. it returns 1977 for the year 1977.

◆ getYearMonthDay()

std::int32_t Day::getYearMonthDay ( ) const
noexcept

Returns year, month and day numbers packed in the following way:

YearMonthDay = year * 10000 + month * 100 + day

For example, September 28, 1977 has value 19770928.

Returns
Packed year, month and day numbers

◆ isHoliday()

bool Day::isHoliday ( ) const
noexcept
Returns
true if this day is an exchange holiday. Usually there are no trading takes place on an exchange holiday.

◆ isShortDay()

bool Day::isShortDay ( ) const
noexcept
Returns
true if this day is a short day. Usually trading stops earlier on a short day.

◆ isTrading()

bool Day::isTrading ( ) const
noexcept
Returns
true if trading activity is allowed within this day. Positive result assumes that day has at least one trading session.

◆ operator==() [1/2]

bool Day::operator== ( const Day & 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 Day::operator== ( const Day::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 Day::toString ( ) const
noexcept

Returns a string representation of the current object.

Returns
A string representation