Table of Contents

Struct Mbp1Msg

Namespace
DatabentoDotNet.Dbn
Assembly
DatabentoDotNet.Dbn.dll

Market-by-price with a book depth of 1. The record of the Mbp1 and Tbbo schemas.

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

Examples

if (record.TryGet(out Mbp1Msg quote))
{
    // Levels is an inline array of one, part of the record's own bytes rather than a reference
    // to somewhere else — which is what lets the whole record be reinterpreted in place.
    BidAskPair top = quote.Levels[0];

    decimal bid = (decimal)top.BidPx / DbnConstants.FixedPriceScale;
    decimal ask = (decimal)top.AskPx / DbnConstants.FixedPriceScale;

    // A side with no orders carries UndefPrice, not zero. Dividing it gives a number in the
    // billions that looks like a price.
    if (top.BidPx != DbnConstants.UndefPrice && top.AskPx != DbnConstants.UndefPrice)
    {
        Console.WriteLine(
            $"{DbnTime.ToInstant(quote.IndexTs)} {bid} x {top.BidSz} / {ask} x {top.AskSz}");
    }
}

Remarks

Upstream aliases this struct as TbboMsg for the TBBO schema; the two are the same type, not two layouts. Its first 48 bytes are byte-identical to TradeMsg. Field order is transcribed from the #[repr(C)] Rust declaration, not from its encode_order attributes.

Fields

Depth

The book level where the update event occurred.

public readonly byte Depth

Field Value

byte

Flags

A bit field indicating event end, message characteristics, and data quality.

public readonly FlagSet Flags

Field Value

FlagSet

Header

The common header.

public readonly RecordHeader Header

Field Value

RecordHeader

Levels

The top of the order book.

public readonly BidAskPairArray1 Levels

Field Value

BidAskPairArray1

Price

The order price, where every 1 unit corresponds to 1e-9.

public readonly long Price

Field Value

long

RawAction

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

public readonly byte RawAction

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

Sequence

The message sequence number assigned at the venue.

public readonly uint Sequence

Field Value

uint

Size

The order quantity.

public readonly uint Size

Field Value

uint

TsInDelta

The matching-engine-sending timestamp, in nanoseconds before TsRecv.

public readonly int TsInDelta

Field Value

int

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

Properties

Action

The event action. Undefined wire bytes cast through to an unnamed value rather than throwing; see RawAction.

public Action Action { get; }

Property Value

Action

ActionChar

The event action as its raw ASCII character.

public char ActionChar { 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 side that initiates the event. Undefined wire bytes cast through to an unnamed value rather than throwing; see RawSide.

public Side Side { get; }

Property Value

Side

SideChar

The side that initiates the event, as its raw ASCII character.

public char SideChar { 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 Mbp1Msg 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>.