![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
The trading days a broker reported for one market, ascending by date. More...
#include <algotradelib/src/core/calendar.hpp>
Public Member Functions | |
| std::optional< bool > | is_trading_day (const Date &date) const |
| Looks up whether the market opens on a date. | |
| std::optional< Date > | next_trading_day (const Date &date) const |
| Finds the first trading day after a date. | |
| std::optional< Date > | previous_trading_day (const Date &date) const |
| Finds the last trading day before a date. | |
| std::optional< std::pair< Date, Date > > | covered () const |
| Returns the first and last dates the calendar covers. | |
Public Attributes | |
| Country | country_ {Country::KR} |
| The market this calendar is for. | |
| std::vector< TradingDay > | days_ |
| The days the broker reported, ascending. A date outside them is uncovered, not closed. | |
| std::chrono::system_clock::time_point | received_at_ |
| When the calendar was received, on this machine's clock. | |
| std::size_t | unreadable_days_ {0} |
| How many rows from the broker had a date that could not be read. | |
The trading days a broker reported for one market, ascending by date.
A calendar covers a finite set of dates. is_trading_day tells "closed" apart from "not covered": a date the broker did not report, or one whose row could not be read, has no answer rather than a guessed one. The searches return reported days only, and do not say whether unreported dates are open.
Keep days_ ascending if you fill it yourself.
An adapter that declares BrokerCaps::has_calendar_sessions also fills each open day's session hours (TradingDay::regular_ and extended_), from which a live loop takes the market phase (strategy::stated_session_phase). is_trading_day and the searches ignore the hours.
Definition at line 72 of file calendar.hpp.
Returns the first and last dates the calendar covers.
Definition at line 164 of file calendar.hpp.
|
inline |
Looks up whether the market opens on a date.
| date | The date to look up. |
Definition at line 97 of file calendar.hpp.
|
inline |
Finds the first trading day after a date.
| date | The date to search from; it is not itself a candidate. |
Definition at line 130 of file calendar.hpp.
|
inline |
Finds the last trading day before a date.
| date | The date to search from; it is not itself a candidate. |
Definition at line 146 of file calendar.hpp.
| Country algotradelib::TradingCalendar::country_ {Country::KR} |
The market this calendar is for.
Definition at line 74 of file calendar.hpp.
Referenced by algotradelib::kis::KisClient::adopt_calendar(), algotradelib::alpaca::AlpacaBlockingClient::calendar(), and main().
| std::vector<TradingDay> algotradelib::TradingCalendar::days_ |
The days the broker reported, ascending. A date outside them is uncovered, not closed.
Definition at line 76 of file calendar.hpp.
Referenced by algotradelib::kis::KisClient::adopt_calendar(), algotradelib::alpaca::AlpacaBlockingClient::calendar(), covered(), is_trading_day(), main(), next_trading_day(), previous_trading_day(), and algotradelib::strategy::stated_session_phase().
| std::chrono::system_clock::time_point algotradelib::TradingCalendar::received_at_ |
When the calendar was received, on this machine's clock.
Definition at line 78 of file calendar.hpp.
Referenced by algotradelib::alpaca::AlpacaBlockingClient::calendar(), main(), and algotradelib::network::FileCalendarCache::publish().
| std::size_t algotradelib::TradingCalendar::unreadable_days_ {0} |
How many rows from the broker had a date that could not be read.
Each such row is dropped, and the day it described is uncovered: is_trading_day returns nothing for it.
Definition at line 88 of file calendar.hpp.
Referenced by algotradelib::alpaca::AlpacaBlockingClient::calendar(), and algotradelib::strategy::stated_session_phase().