BarTickFeed

class BarTickFeed(bars: Sequence<Candle>, positionSign: (symbol: String) -> Int = { 0 }) : TickFeed

A TickFeed over OHLC bars: each candle becomes four synthetic ticks — Open, then the two extremes, then Close — with the ADVERSE extreme first for whichever side is open on the symbol.

A bar has no intra-bar path, so when both a bracket's stop and target sit inside the bar's range the emission order decides which fills (the first fill cancels the OCO sibling). Emitting the adverse extreme first makes that ambiguity resolve pessimistically for the open position: a net LONG sees Low before High (the stop below is tested first), a net SHORT sees High before Low (the stop above is tested first). Flat symbols keep the Low-first default.

positionSign is consulted lazily, after the bar's Open tick has been fully processed by the single-threaded replay loop — so an entry filled on the open influences its own bar's ordering. e.g. a short entered at O=100 with SL 103 / TP 97 inside a 90..110 bar now hits 110 (stop) first.

Remaining approximation: opposing exposure on one symbol nets to a single sign, and the true intra-bar High/Low order is still unknowable from OHLC alone. Timestamps keep the same four strictly increasing slots regardless of ordering, so bars re-aggregate exactly (first=open, min=low, max=high, last=close, volume on close).

Constructors

Link copied to clipboard
constructor(bars: Sequence<Candle>, positionSign: (symbol: String) -> Int = { 0 })

Functions

Link copied to clipboard
open override fun close()

Releases underlying resources. Default no-op; live feeds override.

Link copied to clipboard
open override fun next(): Tick?

Returns the next tick, or null if the feed is exhausted.