Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

Bar lifecycle events and rollback-safe, idempotent recomputation. Bar lifecycle events and rollback-safe, idempotent recomputation.

Indicator::on_bar takes a single incoming bar and permanently advances the indicator’s state — it has no notion of a bar that is still forming (Pine’s barstate.isconfirmed == false) versus one that has closed, and no way to reprocess a bar without double-counting it.

BarLifecycle names the four events a feed can emit for a given timestamp. LifecycleRunner wraps any Indicator + Clone and makes BarLifecycle::Update/BarLifecycle::Correction safe to call repeatedly: it always recomputes from the last confirmed checkpoint rather than mutating forward, so re-delivering the same revised bar is idempotent and never double-applies a still-forming bar’s data.

Requiring Clone is a deliberate, honest scope limit: it is the only mechanism that works generically across arbitrary indicator internals without adding a second, hand-written snapshot/restore method to every Indicator impl. Most indicator structs in this crate do not yet derive Clone; adding it is a mechanical, low-risk follow-up left to indicator authors as they adopt LifecycleRunner, not a blanket change bundled into this module.

Structs§

LifecycleRunner
Wraps an Indicator + Clone so BarLifecycle::Open/BarLifecycle::Update events can be replayed any number of times without permanently mutating state, and only BarLifecycle::Confirmed/BarLifecycle::Correction commit a new checkpoint.

Enums§

BarLifecycle
A bar-lifecycle event for a single timestamp.