1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-License-Identifier: MIT-0
//! Bar boundaries that respect the trading calendar.
//!
//! Minute/hour bars step from `max(instant, session_open)` and clamp to the
//! enclosing half-open session close, so they never claim closed time. A
//! day's last bar therefore ends at the close itself, not at a later reopen.
//! [`CalendarResolution::Seconds`] is the
//! one unclamped variant: it is a pure checked offset.
//!
//! Daily, weekly, and monthly bars derive their boundaries from session
//! closes. Their starts can consequently fall on the preceding civil day,
//! month, or year; for example, a CME trading day closing Monday can open
//! Sunday evening. Probe an end-exclusive provider close marker at
//! `close - 1ns`, not at `close`.
//!
//! Every boundary is optional. `None` means no advancing bar exists: the
//! selected session kind has no rule in the bounded horizon, the interval is
//! zero, or Chrono has no later representable instant. The same private engine
//! serves fixed [`MarketHours`] values and date-aware
//! [`ExchangeCalendar`](crate::ExchangeCalendar) values.
use ;
use answered;
use ;
use ;
/// Returns the session-aware bar close after `instant` for `resolution` and
/// `kind`, or `None` when no advancing bar exists.
///
/// - `Seconds`: a pure checked `instant + interval` offset.
/// - `Minutes`/`Hours`: starts at `max(instant, session_open)` and clamps to
/// the enclosing session close; a closed instant anchors at the next open.
/// - `Daily`: the next venue-local trading-day close when the profile has one.
/// - `Weekly`: the last trading-day close in the target ISO week when the
/// profile has a true weekend close.
/// - `Monthly`: the last close in the target venue-local calendar month when
/// the profile has daily closes.
///
/// A returned close is strictly after `instant`. Zero intraday intervals, a
/// sessionless profile, or a calendar resolution whose corresponding
/// `has_daily_close` / `has_weekend_close` flag is false returns `None`.
/// Returns [`candle_end_with`] over regular and extended sessions.
/// Returns the bar open paired with [`candle_end_with`] for `kind`.
///
/// Seconds bars start at `instant`; minute/hour bars start at
/// `max(instant, session_open)`; calendar bars start at the first session open
/// in their daily, ISO-weekly, or venue-local monthly period. `None` exactly
/// mirrors the paired end query.
/// Returns [`candle_start_with`] over regular and extended sessions.
///
/// Calendar starts may precede the civil period named by their close because
/// overnight sessions belong to their opening day.
/// Returns the next trading-day close after `instant`.
///
/// This is an alias for [`candle_end`] with
/// [`CalendarResolution::Daily`].