Subscription

The parameter struct and builder for LiveClient::subscribe.

The builder can be instantiated with the associated function builder(), and the struct is created from the builder with the build() method. For every field except sent_at, there is an identically named setter method on the builder. For Option fields, there is also a maybe_ prefixed setter that accepts Option<T> directly.

To reverse a subscription, convert it to an Unsubscription with Subscription::to_unsubscription.

Fields

Parameter
Type
Description
symbols
Symbols
The symbols of the instruments to subscribe to.
schema
Schema
The data record schema.
stype_in
SType
The symbology type of input symbols. Defaults to SType::RawSymbol.
start
Option<OffsetDateTime>
The inclusive start of subscription replay. Filters on ts_event except for the CBBO and BBO schemas, which filter on ts_recv. Must be within the last 24 hours. Pass OffsetDateTime::UNIX_EPOCH to request all available data. Cannot be specified after the session is started. Defaults to None.
use_snapshot
bool
Request subscription with snapshot. Only supported with Mbo schema. Defaults to false. Conflicts with the start parameter.
id
Option<u32>
A numerical identifier for the subscription.
sent_at
OffsetDateTime
When the subscription was last sent to the gateway. Set by the client and used by LiveClient::resubscribe to replay subscriptions and unsubscriptions in order. Defaults to OffsetDateTime::UNIX_EPOCH until sent.
API method
pub struct Subscription {
    pub symbols: Symbols,
    pub schema: Schema,
    pub stype_in: SType,
    pub start: Option<OffsetDateTime>,
    pub use_snapshot: bool,
    pub id: Option<u32>,
    pub sent_at: OffsetDateTime,
}
Example usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use databento::{
    dbn::{SType, Schema},
    live::Subscription,
};

let sub = Subscription::builder()
    .symbols(vec!["AAPL", "MSFT"])
    .schema(Schema::Tbbo)
    .build();
assert_eq!(
    Subscription {
        symbols: vec!["AAPL", "MSFT"].into(),
        schema: Schema::Tbbo,
        stype_in: SType::RawSymbol,
        start: None,
        use_snapshot: false,
        id: None,
        sent_at: sub.sent_at,
    },
    sub
);