LiveBlocking::Subscribe
Add a new subscription to the session.
Supports multiple subscriptions for different schemas, which enables rich data streams containing mixed record types.
Specify an optional start time for intraday replay with subscriptions made before starting the session.
Please note there is no unsubscribe method. Subscriptions end when the client disconnects in its destructor or by calling LiveBlocking::Stop.
Parameters
| Parameter | Type | Description |
|---|---|---|
symbols | std::vector<std::string> | The product symbols to subscribe to. Takes up to 2,000 symbols per request. |
schema | databento::Schema | The data record schema. Must be one of the values from MetadataListSchemas. |
stype_in | databento::SType | The symbology type of input symbols. |
start | databento::UnixNanos or std::string | The inclusive start of subscription replay. Filters on ts_event except for the CBBO and BBO schemas, which filter on ts_recv. Takes an ISO 8601 string or a UNIX timestamp in nanoseconds. Must be within the last 24 hours. Pass UnixNanos{} to request all available data. Cannot be specified after the session is started. |
API method
1 2 3 4 5 6
void Subscribe(const std::vector<std::string>& symbols,
Schema schema, SType stype_in);
void Subscribe(const std::vector<std::string>& symbols,
Schema schema, SType stype_in, UnixNanos start);
void Subscribe(const std::vector<std::string>& symbols,
Schema schema, SType stype_in, const std::string& start); Example usage
1 2 3 4 5 6 7 8 9 10 11
#include <databento/live.hpp>
using namespace databento;
auto client = LiveBlocking::Builder()
.SetKey("$YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildBlocking();
client.Subscribe({"ES.v.0"}, Schema::Trades, SType::Continuous);
client.Subscribe({"ES.v.0"}, Schema::Definition,
SType::Continuous);