Table of Contents

Struct ImbalanceMsg

Namespace
DatabentoDotNet.Dbn
Assembly
DatabentoDotNet.Dbn.dll

An auction imbalance. The record of the Imbalance schema.

public readonly struct ImbalanceMsg : IRecord<ImbalanceMsg>
Implements
Inherited Members

Examples

if (record.TryGet(out ImbalanceMsg imbalance))
{
    // Most price fields here are optional, and an absent one is UndefPrice rather than zero.
    // Scaling the sentinel produces a confidently wrong number, so the check comes first.
    string reference = imbalance.RefPrice == DbnConstants.UndefPrice
        ? "(none)"
        : ((decimal)imbalance.RefPrice / DbnConstants.FixedPriceScale).ToString();

    Console.WriteLine(
        $"{DbnTime.ToInstant(imbalance.IndexTs)} ref {reference} "
        + $"paired {imbalance.PairedQty} imbalance {imbalance.TotalImbalanceQty} {imbalance.SideChar}");

    // The auction time is a timestamp of its own, and it too can be absent — which is why the
    // crossing is TryToInstant here and ToInstant above.
    if (DbnTime.TryToInstant(imbalance.AuctionTime, out Instant auction))
    {
        Console.WriteLine($"auction at {auction}");
    }
}

Remarks

Byte-identical in every DBN version, so there is no version-specific variant of it. Field order is transcribed from the #[repr(C)] Rust declaration, not from its encode_order attributes.

Fields

AuctInterestClrPrice

The hypothetical auction-clearing price for cross orders only, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long AuctInterestClrPrice

Field Value

long

AuctionStatus

A venue-specific status code.

public readonly byte AuctionStatus

Field Value

byte

AuctionTime

The projected auction timestamp, in nanoseconds since the UNIX epoch. UndefTimestamp when unused.

public readonly ulong AuctionTime

Field Value

ulong

ContBookClrPrice

The hypothetical auction-clearing price for both cross and continuous orders, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long ContBookClrPrice

Field Value

long

FreezeStatus

A venue-specific status code.

public readonly byte FreezeStatus

Field Value

byte

Header

The common header.

public readonly RecordHeader Header

Field Value

RecordHeader

IndMatchPrice

The price at which the highest number of shares would trade, subject to auction collars, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long IndMatchPrice

Field Value

long

LowerCollar

The lower limit of the auction collar, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long LowerCollar

Field Value

long

MarketImbalanceQty

The total market-order imbalance quantity at RefPrice. UndefOrderSize when unused.

public readonly uint MarketImbalanceQty

Field Value

uint

NumExtensions

The number of times the halt period has been extended.

public readonly byte NumExtensions

Field Value

byte

PairedQty

The quantity of shares eligible to be matched at RefPrice. UndefOrderSize when unused.

public readonly uint PairedQty

Field Value

uint

RawAuctionType

The raw wire byte behind AuctionTypeChar: a venue-specific auction type code, '~' when unused. This one has no enum in the DBN spec — refer to the venue-specific documentation.

public readonly byte RawAuctionType

Field Value

byte

RawSide

The raw wire byte behind Side. Not validated on decode — pass it to TryFromSide(byte, out Side) for a checked conversion.

public readonly byte RawSide

Field Value

byte

RawSignificantImbalance

The raw wire byte behind SignificantImbalanceChar: a venue-specific code. For Nasdaq this is the raw Price Variation Indicator. No enum in the DBN spec.

public readonly byte RawSignificantImbalance

Field Value

byte

RawUnpairedSide

The raw wire byte behind UnpairedSide. Not validated on decode — pass it to TryFromSide(byte, out Side) for a checked conversion.

public readonly byte RawUnpairedSide

Field Value

byte

RefPrice

The price the imbalance shares are calculated at, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long RefPrice

Field Value

long

SsrFillingPrice

The price sell-short interest will be filled at while a short-sell restriction is in effect, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long SsrFillingPrice

Field Value

long

TotalImbalanceQty

The quantity of shares not paired at RefPrice. UndefOrderSize when unused.

public readonly uint TotalImbalanceQty

Field Value

uint

TsRecv

The capture-server-received timestamp, in nanoseconds since the UNIX epoch. This, not TsEvent, is the record's index timestamp.

public readonly ulong TsRecv

Field Value

ulong

UnpairedQty

During the closing auction, the number of unpaired shares priced at or better than RefPrice. UndefOrderSize when unused.

public readonly uint UnpairedQty

Field Value

uint

UpperCollar

The upper limit of the auction collar, where every 1 unit corresponds to 1e-9. UndefPrice when unused.

public readonly long UpperCollar

Field Value

long

Properties

AuctionTypeChar

The venue-specific auction type as its raw ASCII character.

public char AuctionTypeChar { get; }

Property Value

char

IndexTs

The record's index timestamp: the one to sort by, and the one to key a symbol map with. Nanoseconds since the UNIX epoch.

public ulong IndexTs { get; }

Property Value

ulong

Remarks

This is usually ts_recv, not TsEvent. Fourteen of the twenty-one record structs carry a ts_recv and index on it; the rest have no ts_recv at all and fall back to the header's ts_event. Port of upstream's Record::raw_index_ts (record/traits.rs:52-54), whose default body is ts_event and which the #[dbn(index_ts)] field attribute overrides per struct (record.rs, compat.rs).

The distinction is not cosmetic: ts_event and ts_recv can fall on opposite sides of UTC midnight, so resolving a symbol by the wrong one silently returns the previous day's symbol, or nothing, with no error anywhere.

This is a raw timestamp and can be UndefTimestamp. Convert it with ToUtcDate(ulong) or TryToUtcDate(ulong, out LocalDate), which check the sentinel.

Side

The market side of TotalImbalanceQty. Undefined wire bytes cast through to an unnamed value rather than throwing; see RawSide.

public Side Side { get; }

Property Value

Side

SideChar

The market side of TotalImbalanceQty, as its raw ASCII character.

public char SideChar { get; }

Property Value

char

SignificantImbalanceChar

The venue-specific significant-imbalance code as its raw ASCII character.

public char SignificantImbalanceChar { get; }

Property Value

char

UnpairedSide

The side of UnpairedQty. Undefined wire bytes cast through to an unnamed value rather than throwing; see RawUnpairedSide.

public Side UnpairedSide { get; }

Property Value

Side

UnpairedSideChar

The side of UnpairedQty, as its raw ASCII character.

public char UnpairedSideChar { get; }

Property Value

char

WireSize

The struct's exact size on the wire, in bytes, excluding any trailing ts_out.

public static int WireSize { get; }

Property Value

int

Methods

HasRType(RType)

Reports whether ImbalanceMsg is the layout for records carrying rtype.

public static bool HasRType(RType rtype)

Parameters

rtype RType

The record type read from a record header.

Returns

bool

true if rtype is one of the record types this struct decodes. This is necessary but not sufficient to identify the record — see the remarks on IRecord<TSelf>.