openpine_vm/bar_state.rs
1use serde::{Deserialize, Serialize};
2
3/// Describes the execution phase of the current bar.
4#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
5pub enum BarState {
6 /// A fully confirmed historical bar.
7 History = 0,
8 /// The first tick of a new real-time bar.
9 RealtimeNew = 1,
10 /// An update to the current real-time bar (same timestamp).
11 RealtimeUpdate = 2,
12 /// Confirmation of a previously open real-time bar.
13 RealtimeConfirmed = 3,
14}
15
16impl BarState {
17 #[inline]
18 pub(crate) fn is_new_or_update(&self) -> bool {
19 matches!(self, BarState::RealtimeNew | BarState::RealtimeUpdate)
20 }
21}