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§
- Lifecycle
Runner - Wraps an
Indicator + ClonesoBarLifecycle::Open/BarLifecycle::Updateevents can be replayed any number of times without permanently mutating state, and onlyBarLifecycle::Confirmed/BarLifecycle::Correctioncommit a new checkpoint.
Enums§
- BarLifecycle
- A bar-lifecycle event for a single timestamp.