Table of Contents

Struct OhlcvMsg

Namespace
DatabentoDotNet.Dbn
Assembly
DatabentoDotNet.Dbn.dll

Open, high, low, close and volume for one bar. The record of the OHLCV schemas at every cadence.

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

Examples

if (record.TryGet(out OhlcvMsg bar))
{
    // A bar indexes on ts_event — the start of its interval — where a trade indexes on ts_recv.
    // IndexTs is the field that already knows which, per schema.
    Instant opened = DbnTime.ToInstant(bar.IndexTs);

    decimal open = (decimal)bar.Open / DbnConstants.FixedPriceScale;
    decimal high = (decimal)bar.High / DbnConstants.FixedPriceScale;
    decimal low = (decimal)bar.Low / DbnConstants.FixedPriceScale;
    decimal close = (decimal)bar.Close / DbnConstants.FixedPriceScale;

    Console.WriteLine($"{opened} O {open} H {high} L {low} C {close} V {bar.Volume}");
}

Remarks

The cadence is carried by the rtype, not by the layout: one struct serves Ohlcv1S, Ohlcv1M, Ohlcv1H, Ohlcv1D, OhlcvEod and the deprecated OhlcvDeprecated. It has no ts_recv, so its index timestamp is TsEvent.

Fields

Close

The close price for the bar, where every 1 unit corresponds to 1e-9.

public readonly long Close

Field Value

long

Header

The common header.

public readonly RecordHeader Header

Field Value

RecordHeader

High

The high price for the bar, where every 1 unit corresponds to 1e-9.

public readonly long High

Field Value

long

Low

The low price for the bar, where every 1 unit corresponds to 1e-9.

public readonly long Low

Field Value

long

Open

The open price for the bar, where every 1 unit corresponds to 1e-9.

public readonly long Open

Field Value

long

Volume

The total volume traded during the bar.

public readonly ulong Volume

Field Value

ulong

Properties

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.

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 OhlcvMsg 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>.