Struct HeatmapTickBatch
Zero-allocation, struct-based wrapper around a System.ReadOnlyMemory<T> of HeatmapTradeTick. Used on the live tick hot path to avoid the defensive copies and per-batch allocations System.Collections.Generic.IReadOnlyList<T> imposes — the platform rents the underlying buffer from System.Buffers.ArrayPool<T> and hands it to indicators wrapped in this struct, so a sustained tick stream produces zero per-batch garbage.
Authors typically foreach over the batch — the public struct
enumerator avoids boxing via duck typing. For performance-critical loops,
call AsSpan().
Lifetime: the underlying buffer is valid only during the synchronous
portion of the call that received it AND across awaited continuations of
the same async consumer call. Indicators MUST NOT capture the batch
(or any span / sample reference derived from it) beyond the call's
completion — the platform may immediately rent the buffer to a different
batch for a different instance. Persist data into indicator-owned storage
instead.
Added in ATAS 8.0.15.
public readonly struct HeatmapTickBatch
- Extension Methods
Constructors
HeatmapTickBatch(ReadOnlyMemory<HeatmapTradeTick>)
Wraps the given ticks without copying them.
public HeatmapTickBatch(ReadOnlyMemory<HeatmapTradeTick> memory)
Parameters
memoryReadOnlyMemory<HeatmapTradeTick>The ticks of the batch.
Properties
Empty
A batch without ticks.
public static HeatmapTickBatch Empty { get; }
Property Value
IsEmpty
True when the batch has no ticks.
public bool IsEmpty { get; }
Property Value
- bool
this[int]
Gets the tick at index.
public HeatmapTradeTick this[int index] { get; }
Parameters
indexintZero-based index of the tick.
Property Value
Exceptions
- IndexOutOfRangeException
indexis negative or not less than Length.
Length
Number of ticks in the batch.
public int Length { get; }
Property Value
- int
Methods
AsMemory()
Returns the underlying memory of the batch. Subject to the lifetime rules of the batch: copy the ticks to keep them.
public ReadOnlyMemory<HeatmapTradeTick> AsMemory()
Returns
- ReadOnlyMemory<HeatmapTradeTick>
The ticks of the batch.
AsSpan()
Returns the ticks as a span, the fastest way to read them. Subject to the lifetime rules of the batch.
public ReadOnlySpan<HeatmapTradeTick> AsSpan()
Returns
- ReadOnlySpan<HeatmapTradeTick>
The ticks of the batch.
GetEnumerator()
Returns an allocation-free enumerator over the ticks; used by foreach.
public HeatmapTickBatch.Enumerator GetEnumerator()
Returns
- HeatmapTickBatch.Enumerator
The enumerator.
Slice(int, int)
Returns a batch over a part of this one, without copying the ticks.
public HeatmapTickBatch Slice(int start, int length)
Parameters
startintIndex of the first tick of the part.
lengthintNumber of ticks in the part.
Returns
- HeatmapTickBatch
The part of the batch.
Exceptions
- ArgumentOutOfRangeException
The part does not lie within the batch.
Operators
implicit operator HeatmapTickBatch(HeatmapTradeTick[])
Convenience implicit conversion from HeatmapTradeTick[] for tests and ad-hoc callers. The platform's hot path uses the pooled-buffer constructor instead — this conversion always wraps the whole array.
public static implicit operator HeatmapTickBatch(HeatmapTradeTick[] ticks)
Parameters
ticksHeatmapTradeTick[]