Table of Contents

Class AdjustmentFactorsClient

Namespace
DatabentoDotNet.Reference
Assembly
DatabentoDotNet.Reference.dll

The adjustment_factors.* endpoints: the multipliers that make a price series comparable across splits, dividends and other capital events.

public sealed class AdjustmentFactorsClient
Inheritance
AdjustmentFactorsClient
Inherited Members

Examples

// The multipliers that make a price series comparable across the events that break it.
await foreach (AdjustmentFactor factor in client.AdjustmentFactors.GetRangeAsync(
    new AdjustmentFactorsGetRangeParams
    {
        Symbols = Symbols.From("AAPL"),
        DateTimeRange = ReferenceDateTimeRange.Between(
            Instant.FromUtc(2020, 1, 1, 0, 0), Instant.FromUtc(2021, 1, 1, 0, 0)),
    }))
{
    // Factor is a decimal rather than a double: it multiplies a price series, so the rounding
    // has to be the one the caller can reason about.
    Console.WriteLine($"{factor.ExDate} {factor.Event} x{factor.Factor} ({factor.Status})");
}

Remarks

Reached through AdjustmentFactors rather than constructed. Port of upstream's AdjustmentFactorsClient (adjustment.rs:15-54), which holds a mutable borrow of the outer client; this holds a reference, there being no borrow checker to satisfy.

Its one method bills. Reference data is a separate Databento product, so a 403 here is a legitimate outcome on an account entitled for historical data rather than a mysterious failure — see GetRangeAsync(AdjustmentFactorsGetRangeParams, CancellationToken).

Fields

RequestCompression

The compression every get_range request asks for. Not caller-settable.

public const string RequestCompression = "zstd"

Field Value

string

Remarks

Upstream hard-codes this (adjustment.rs:36) because the response handler requires the frame; ToFormParameters() renders it and documents why it is a constant rather than a property. Public and named so a test can assert the value on the wire against the value the library believes it sends, rather than against a string typed twice — the same reason RequestCompression is.

Methods

GetRangeAsync(AdjustmentFactorsGetRangeParams, CancellationToken)

Streams the adjustment factors matching parameters, a row at a time as they decompress.

public IAsyncEnumerable<AdjustmentFactor> GetRangeAsync(AdjustmentFactorsGetRangeParams parameters, CancellationToken cancellationToken = default)

Parameters

parameters AdjustmentFactorsGetRangeParams

Which symbols, over what range, narrowed how.

cancellationToken CancellationToken

Cancels the request and the enumeration.

Returns

IAsyncEnumerable<AdjustmentFactor>

One row per adjustment factor, in the order the server sent them.

Remarks

Port of upstream's get_range (adjustment.rs:28-53) — with one deliberate behavioural difference, below.

This costs money, and it is billed by what it returns. Reference data is a separate Databento product from historical market data: an API key entitled for one is not necessarily entitled for the other, and a 403 from this endpoint on an otherwise working key means exactly that rather than a broken credential. Unlike a batch job, a stream can be stopped part-way — break out of the await foreach and the response is disposed on the way out, which is half of why this streams.

Rows arrive in the server's order, and this method does not sort them. Upstream buffers the whole response into a Vec and then sorts it by ex_date (adjustment.rs:49-51) — it can, because it has already paid for the buffer. A stream has not: sorting is what buffering is, so an IAsyncEnumerable<T> that sorted would be a list wearing a stream's type. A caller who needs upstream's order can have it in one line — rows.OrderBy(r => r.ExDate) over the materialised sequence — and pays for the buffer where they can see it. Whether the server's own order is already ex_date order is unmeasured; #57 owns the probe. See ROADMAP.md §6 and ReadZstdJsonLinesStreamAsync<T>(HttpResponseMessage, JsonTypeInfo<T>, CancellationToken), where the argument is made in full.

Nothing is sent until the enumeration starts. Calling this method builds a query; the request goes out on the first MoveNextAsync. A caller who never enumerates never bills. The argument checks below run at the call rather than at that first step, so a mistake in them faults where it was made.

Exceptions

ArgumentNullException

parameters is null.

InvalidOperationException

parameters leaves Symbols or DateTimeRange at its type's default value.

DatabentoApiException

The API answered with a non-success status.