pub struct AlertEvent {
pub alert: IndicatorAlert,
pub timestamp: i64,
pub phase: EventPhase,
pub event_id: String,
/* private fields */
}Expand description
An IndicatorAlert enriched with timestamp, instrument, timeframe, a stable event ID, and
an explicit lifecycle phase, suitable for deduplication and cross-bar tracking.
instrument and timeframe are private (with AlertEvent::instrument/
AlertEvent::timeframe accessors) so that AlertEvent::with_instrument/
AlertEvent::with_timeframe are the only way to change them, guaranteeing event_id is
always recomputed from the complete, current identity context and can never go stale relative
to it — regardless of the order those builders are called in.
Fields§
§alert: IndicatorAlert§timestamp: i64§phase: EventPhase§event_id: StringImplementations§
Source§impl AlertEvent
impl AlertEvent
Sourcepub fn new(alert: IndicatorAlert, timestamp: i64, phase: EventPhase) -> Self
pub fn new(alert: IndicatorAlert, timestamp: i64, phase: EventPhase) -> Self
Builds an event with a deterministic ID derived from the alert kind, phase, and timestamp
(instrument/timeframe default to absent; attach them via AlertEvent::with_instrument/
AlertEvent::with_timeframe), so re-emitting the same logical event on the same bar
always yields the same ID.
pub fn instrument(&self) -> Option<&str>
pub fn timeframe(&self) -> Option<Timeframe>
Sourcepub fn with_instrument(self, instrument: impl Into<String>) -> Self
pub fn with_instrument(self, instrument: impl Into<String>) -> Self
Attaches an instrument and recomputes event_id from the complete identity context, so
two events that only differ by instrument never collide.
Sourcepub fn with_timeframe(self, timeframe: Timeframe) -> Self
pub fn with_timeframe(self, timeframe: Timeframe) -> Self
Attaches a timeframe and recomputes event_id from the complete identity context, so two
events that only differ by timeframe never collide.
Trait Implementations§
Source§impl Clone for AlertEvent
impl Clone for AlertEvent
Source§fn clone(&self) -> AlertEvent
fn clone(&self) -> AlertEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more