Market Analyzer

Reference

Market Analyzer

The surface for a custom Market Analyzer column: the column definition and its async value source, the cell-publishing sink, the per-instrument context, and the metadata attribute and descriptors that register and describe it.

Market Analyzer — TradeStrike.Pipeline.MarketAnalyzer

A column is an IColumnDefinition. For each instrument it creates an IColumnValueSource, whose StartAsync runs until disposed and pushes CellValues into the supplied IColumnValueSink. The host renders the latest value according to the column's ColumnDataType. Annotate the definition with [MarketAnalyzerColumn] for discovery.

LastPriceColumn.csusing TradeStrike.Pipeline.MarketAnalyzer;

[MarketAnalyzerColumn("Last", Category = "Price", Description = "Most recent trade price")]
public sealed class LastPriceColumn : IColumnDefinition
{
    public string Id => "last-price";
    public string Header => "Last";
    public ColumnDataType DataType => ColumnDataType.Price;

    public IColumnValueSource CreateSource(InstrumentRef instrument, IColumnContext context)
        => new Source(instrument, context);

    private sealed class Source : IColumnValueSource
    {
        // ... ctor stores instrument + context ...
        public async Task StartAsync(IColumnValueSink sink, CancellationToken cancellationToken)
        {
            sink.Publish(CellValue.Initializing);
            // subscribe to ticks, then on each update:
            sink.Publish(CellValue.Ready(price));
        }

        public ValueTask DisposeAsync() => ValueTask.CompletedTask;
    }
}
Type Members
IColumnDefinition string Id, string Header, ColumnDataType DataType, IColumnValueSource CreateSource(InstrumentRef instrument, IColumnContext context).
IColumnValueSource : IAsyncDisposable Task StartAsync(IColumnValueSink sink, CancellationToken cancellationToken).
IColumnValueSink void Publish(CellValue value).
CellValue readonly record struct: CellState State, object? RawValue, string? ErrorMessage; static Ready(object?), Initializing, Error(string).
CellState enum (byte): Initializing = 0, Ready = 1, Error = 2.
IColumnContext IMarketAnalyzerClock Clock, IDataProvider? ResolveDataProvider(InstrumentRef), TimeZoneInfo SessionTimeZone, ISessionResolver SessionResolver, object? GetService(Type), string ResolveBackfillSymbol(InstrumentRef).
ColumnContextExtensions static: T? GetService<T>(this IColumnContext) where T : class.
IMarketAnalyzerClock DateTime UtcNow { get; }.
ISessionResolver DateTime GetSessionStartUtc(InstrumentRef instrument, DateTime momentUtc).
ColumnDataType enum: Text, Integer, Number, Price, Percent, Timestamp, Boolean, ConditionStatus, Sparkline.
InstrumentRef readonly record struct: string SymbolId, string? ProviderKey; static Validated(string symbolId, string? providerKey = null).
ColumnDescriptor record: Id, DisplayName, Category, Description, ColumnDataType DataType, bool HasSettings, bool IsEditable.
IColumnDefinitionCatalog IColumnDefinition? Resolve(string columnId), IReadOnlyList<string> KnownIds, ColumnDescriptor? Describe(string columnId).
MarketAnalyzerColumnAttribute MarketAnalyzerColumnAttribute(string displayName); DisplayName, init Category, Description.
ColumnParameterAttribute init DisplayName, Description, double MinValue, double MaxValue.
IInstrumentDescriptionSource string? GetDescription(string nativeSymbol) — optional service resolved via IColumnContext.GetService (file IInstrumentInfoSources.cs).