103 std::size_t high =
days_.size();
105 const std::size_t middle = low + (high - low) / 2;
106 if (
days_[middle].date_ < date) {
112 if (low <
days_.size() &&
days_[low].date_ == date) {
113 return days_[low].open_;
115 for (
const auto& day :
days_) {
116 if (day.date_ == date) {
131 for (
const auto& day :
days_) {
132 if (day.open_ && date < day.date_) {
147 std::optional<Date> found;
148 for (
const auto& day :
days_) {
149 if (!(day.date_ < date)) {
164 std::optional<std::pair<Date, Date>>
covered()
const {
168 return std::make_pair(
days_.front().date_,
days_.back().date_);
The library: broker-neutral types (core), and the modules below.
Country
A country (market) the library supports.
A calendar date with no time of day or time zone.
One session's bounds, as instants.
std::chrono::system_clock::time_point opens_at_
When the session opens (inclusive).
std::chrono::system_clock::time_point closes_at_
When the session closes (exclusive).
The trading days a broker reported for one market, ascending by date.
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::size_t unreadable_days_
How many rows from the broker had a date that could not be read.
std::chrono::system_clock::time_point received_at_
When the calendar was received, on this machine's clock.
std::vector< TradingDay > days_
The days the broker reported, ascending. A date outside them is uncovered, not closed.
std::optional< Date > previous_trading_day(const Date &date) const
Finds the last trading day before a date.
Country country_
The market this calendar is for.
std::optional< std::pair< Date, Date > > covered() const
Returns the first and last dates the calendar covers.
One calendar date and whether the market opens on it.
Date date_
The market's local calendar date, as the broker reports it.
bool open_
Whether the market opens on date_.
std::optional< SessionHours > extended_
From the start of the first session the broker states for the day to the end of the last,...
std::optional< SessionHours > regular_
The exchange's regular session on an open day, where the adapter fills it.