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

Schedule class provides API to retrieve and explore trading schedules of different exchanges and different classes of financial instruments. More...

#include <Schedule.hpp>

Public Types

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

Public Member Functions

Session::Ptr getSessionByTime (std::int64_t time) const noexcept
 Returns session that contains specified time.
 
Day::Ptr getDayByTime (std::int64_t time) const noexcept
 Returns day that contains specified time.
 
Day::Ptr getDayById (std::int32_t dayId) const noexcept
 Returns day for specified day identifier.
 
Day::Ptr getDayByYearMonthDay (std::int32_t yearMonthDay) const noexcept
 Returns day for specified year, month and day numbers.
 
Session::Ptr getNearestSessionByTime (std::int64_t time, const SessionFilter &filter) const noexcept
 Returns session that is nearest to the specified time and that is accepted by specified filter.
 
Session::Ptr findNearestSessionByTime (std::int64_t time, const SessionFilter &filter) const noexcept
 Returns session that is nearest to the specified time and that is accepted by specified filter.
 
std::string getName () const noexcept
 Returns name of this schedule.
 
std::string getTimeZoneDisplayName () const noexcept
 Returns time zone display name in which this schedule is defined.
 
std::string getTimeZoneId () const noexcept
 Returns time zone id in which this schedule is defined.
 

Static Public Member Functions

static Schedule::Ptr getInstance (std::shared_ptr< InstrumentProfile > profile)
 Returns default schedule instance for specified instrument profile.
 
static Schedule::Ptr getInstance (const std::string &scheduleDefinition)
 Returns default schedule instance for specified schedule definition.
 
static Schedule::Ptr getInstance (std::shared_ptr< InstrumentProfile > profile, const std::string &venue)
 Returns schedule instance for specified instrument profile and trading venue.
 
static std::vector< std::string > getTradingVenues (std::shared_ptr< InstrumentProfile > profile)
 Returns trading venues for specified instrument profile.
 
static void downloadDefaults (const std::string &downloadConfig) noexcept
 Downloads defaults using specified download config and optionally start periodic download.
 
static bool setDefaults (const std::vector< char > &data) noexcept
 Sets shared defaults that are used by individual schedule instances.
 

Friends

struct Day
 

Detailed Description

Schedule class provides API to retrieve and explore trading schedules of different exchanges and different classes of financial instruments.

Each instance of schedule covers separate trading schedule of some class of instruments, i.e. NYSE stock trading schedule or CME corn futures trading schedule. Each schedule splits entire time scale into separate days that are aligned to the specific trading hours of covered trading schedule.

Member Function Documentation

◆ downloadDefaults()

void Schedule::downloadDefaults ( const std::string & downloadConfig)
staticnoexcept

Downloads defaults using specified download config and optionally start periodic download.

The specified config can be one of the following:

  • "" - stop periodic download
  • URL - download once from specified URL and stop periodic download
  • URL,period - start periodic download from specified URL
  • "auto" - start periodic download from default location
Parameters
downloadConfigdownload config

◆ findNearestSessionByTime()

Session::Ptr Schedule::findNearestSessionByTime ( std::int64_t time,
const SessionFilter & filter ) const
noexcept

Returns session that is nearest to the specified time and that is accepted by specified filter.

This method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30. If no sessions acceptable by specified filter are found within one year this method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}).

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

session = schedule->findNearestSessionByTime(time, SessionFilter::TRADING);

To find nearest regular trading session use this code:

session = schedule->findNearestSessionByTime(time, SessionFilter::REGULAR);
Parameters
timeThe time to search for
filterThe filter to test sessions
Returns
The session that is nearest to the specified time and that is accepted by specified filter or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if specified time falls outside of valid date range

◆ getDayById()

Day::Ptr Schedule::getDayById ( std::int32_t dayId) const
noexcept

Returns day for specified day identifier.

This method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified day identifier falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters
dayIdThe day identifier to search for
Returns
The day for specified day identifier or Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified day identifier falls outside of valid date range
See also
Day::getDayId()

◆ getDayByTime()

Day::Ptr Schedule::getDayByTime ( std::int64_t time) const
noexcept

Returns day that contains specified time.

This method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters
timeThe time to search for
Returns
The day that contains specified time or Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified time falls outside of valid date range

◆ getDayByYearMonthDay()

Day::Ptr Schedule::getDayByYearMonthDay ( std::int32_t yearMonthDay) const
noexcept

Returns day for specified year, month and day numbers.

Year, month, and day numbers shall be packed in the following way:

YearMonthDay = year * 10000 + month * 100 + day

For example, September 28, 1977 has value 19770928.

If specified day does not exist then this method returns day with the lowest valid YearMonthDay that is greater than specified one. This method will return Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified year, month and day numbers fall outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters
yearMonthDayThe year, month and day numbers to search for
Returns
The day for specified year, month and day numbers or Day::Ptr{nullptr} (std::shared_ptr<Day>{nullptr}) if specified year, month and day numbers fall outside of valid date range
See also
Day::getYearMonthDay()

◆ getInstance() [1/3]

Schedule::Ptr Schedule::getInstance ( const std::string & scheduleDefinition)
staticnoexcept

Returns default schedule instance for specified schedule definition.

Parameters
scheduleDefinitionThe schedule definition of requested schedule
Returns
The default schedule instance for specified schedule definition

◆ getInstance() [2/3]

Schedule::Ptr Schedule::getInstance ( std::shared_ptr< InstrumentProfile > profile)
static

Returns default schedule instance for specified instrument profile.

Parameters
profileThe instrument profile those schedule is requested
Returns
The default schedule instance for specified instrument profile

◆ getInstance() [3/3]

Schedule::Ptr Schedule::getInstance ( std::shared_ptr< InstrumentProfile > profile,
const std::string & venue )
static

Returns schedule instance for specified instrument profile and trading venue.

Parameters
profileThe instrument profile those schedule is requested
venueThe trading venue those schedule is requested
Returns
The schedule instance for specified instrument profile and trading venue

◆ getName()

std::string Schedule::getName ( ) const
noexcept

Returns name of this schedule.

Returns
The name of this schedule

◆ getNearestSessionByTime()

Session::Ptr Schedule::getNearestSessionByTime ( std::int64_t time,
const SessionFilter & filter ) const
noexcept

Returns session that is nearest to the specified time and that is accepted by specified filter.

This method will return Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30 or if no sessions acceptable by specified filter are found within one year this method

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

session = schedule->getNearestSessionByTime(time, SessionFilter::TRADING);

To find nearest regular trading session use this code:

session = schedule->getNearestSessionByTime(time, SessionFilter::REGULAR);
Parameters
timeThe time to search for
filterthe filter to test sessions
Returns
session that is nearest to the specified time and that is accepted by specified filter or Session::Ptr{nullptr} (std::shared_ptr<Session>{nullptr}) if specified time falls outside of valid date range or if no such day was found within one year

◆ getSessionByTime()

Session::Ptr Schedule::getSessionByTime ( std::int64_t time) const
noexcept

Returns session that contains specified time.

This method will return Session::Ptr{nullptr} if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters
timethe time to search for
Returns
session that contains specified time or Session::Ptr{nullptr} if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30.

◆ getTimeZoneDisplayName()

std::string Schedule::getTimeZoneDisplayName ( ) const
noexcept

Returns time zone display name in which this schedule is defined.

Returns
time zone display name in which this schedule is defined

◆ getTimeZoneId()

std::string Schedule::getTimeZoneId ( ) const
noexcept

Returns time zone id in which this schedule is defined.

Returns
time zone id in which this schedule is defined

◆ getTradingVenues()

std::vector< std::string > Schedule::getTradingVenues ( std::shared_ptr< InstrumentProfile > profile)
staticnoexcept

Returns trading venues for specified instrument profile.

Parameters
profileThe instrument profile those trading venues are requested
Returns
trading venues for specified instrument profile

◆ setDefaults()

bool Schedule::setDefaults ( const std::vector< char > & data)
staticnoexcept

Sets shared defaults that are used by individual schedule instances.

Parameters
dataThe content of default data
Returns
true if OK