Table of Contents

Class Subscription

Namespace
DatabentoDotNet.Live
Assembly
DatabentoDotNet.Live.dll

One subscription request: what to stream, in which symbology, and optionally from when.

public sealed record Subscription : IEquatable<Subscription>
Inheritance
Subscription
Implements
Inherited Members

Examples

// Real time, from the live edge.
var live = new Subscription
{
    Schema = Schema.Trades,
    Symbols = Symbols.From(["AAPL", "MSFT"]),
};

// The same subscription, replaying the last hour first and then continuing live. An Instant,
// because a DateTimeOffset would truncate to 100 ns ticks and replay from a different moment
// than the one written here.
var replay = live with
{
    Start = SystemClock.Instance.GetCurrentInstant() - Duration.FromHours(1),
};

// SubscribeAsync returns the subscription it actually sent, Id filled in — and that id is what
// the gateway quotes in any error it raises about this subscription.
Subscription sent = await client.SubscribeAsync(replay);
Console.WriteLine(sent.Id);

Remarks

Port of upstream's live::Subscription. Its bon-derived builder becomes required init properties — C# 11 checks at every construction site exactly what the builder's type-state checked at build(). CLAUDE.md, "Porting rules".

Immutable, where upstream's is mutated in place. Upstream's Client::subscribe takes ownership, assigns id if absent, and pushes the mutated value onto its list; its resubscribe then clears each stored start in place. Neither is expressible on a record, so SubscribeAsync(Subscription, CancellationToken) returns the subscription it actually sent — Id filled in — and keeps that in Subscriptions. A caller who wants the assigned id has it, rather than having to read it back out of a list.

The two client-side rejections live in Validate(string), not in the init accessors. Both are relationships between two properties, and an init accessor sees only its own value and whatever has been set before it — so the same object would be rejected or accepted depending on the order the initializer happened to list its properties.

Properties

Id

The subscription's numeric id, or null to let SubscribeAsync(Subscription, CancellationToken) assign the next one.

public uint? Id { get; init; }

Property Value

uint?

Remarks

The gateway quotes this id in any error it raises about the subscription, which is the only way to tell which of several concurrent subscriptions a message is about.

Schema

The record schema to stream.

public required Schema Schema { get; init; }

Property Value

Schema

Start

Where to replay from before transitioning to live, or null for real-time data only. UnixEpoch requests everything available.

public Instant? Start { get; init; }

Property Value

Instant?

Remarks

An Instant on the surface and Unix nanoseconds on the wire — the crossing is DbnTime.ToUnixNanoseconds. A DateTimeOffset here would truncate to 100 ns ticks and replay from a different moment than the caller wrote, which is why the BCL types are banned repo-wide. CLAUDE.md, "Dates and times".

StypeIn

The symbology Symbols is expressed in. Defaults to RawSymbol, as upstream does.

public SType StypeIn { get; init; }

Property Value

SType

Symbols

The symbols to subscribe to.

public required Symbols Symbols { get; init; }

Property Value

Symbols

UseSnapshot

Whether to ask for a book snapshot before live updates. Only Mbo supports it, and it cannot be combined with Start.

public bool UseSnapshot { get; init; }

Property Value

bool