Helpers
Metadata
The contents of the header of a DBN stream.
Fields
| Field | Type | Description |
|---|---|---|
version | std::uint8_t | The DBN schema version. |
dataset | std::string | The dataset code. |
schema | std::optional<Schema> | The data record schema. Will be nullopt for live data which can mix schemas. |
start | UnixNanos | The timestamp of the start of request time range (inclusive) expressed as the number nanoseconds since the UNIX epoch. |
end | UnixNanos | The timestamp of the end of request time range (exclusive) expressed as the number nanoseconds since the UNIX epoch. |
limit | std::uint64_t | The maximum number of records to return. |
stype_in | std::optional<SType> | |
stype_out | SType | The symbology type of output symbols. |
ts_out | bool | Whether the stream contains live data with the send timestamps appended to every record. |
symbol_cstr_len | std::size_t | The length of fixed-length symbol strings. |
symbols | std::vector<std::string> | The product symbols from the original request. |
partial | std::vector<std::string> | The symbols that did not resolve for at least one day in the query time range. |
not_found | std::vector<std::string> | The symbols that did not resolve for any day in the query time range. |
mappings | std::vector<SymbolMapping> | The symbol mappings for historical data. |
struct MappingInterval {
date::year_month_day start_date;
date::year_month_day end_date;
std::string symbol;
};
struct SymbolMapping {
std::string raw_symbol;
std::vector<MappingInterval> intervals;
};
struct Metadata {
std::uint8_t version;
std::string dataset;
std::optional<Schema> schema;
UnixNanos start;
UnixNanos end;
std::uint64_t limit;
std::optional<SType> stype_in;
SType stype_out;
bool ts_out;
std::size_t symbol_cstr_len;
std::vector<std::string> symbols;
std::vector<std::string> partial;
std::vector<std::string> not_found;
std::vector<SymbolMapping> mappings;
} Metadata::CreateSymbolMap
Create a symbology map from instrument ID and date to text symbol from the mappings in the metadata.
Useful for multi-day requests.
Returns
A TsSymbolMap with the symbol mappings for the query range indexed by instrument ID and date.
TsSymbolMap CreateSymbolMap() const; Metadata::CreateSymbolMapForDate
Create a symbology mapping from the mappings in the metadata for the specified date.
Useful for requests that span a single day.
For multi-day requests, it's better to use Metadata::CreateSymbolMap.
Parameters
| Parameter | Type | Description |
|---|---|---|
date | date::year_month_day | The date to create the symbol map for. |
Returns
A PitSymbolMap with the symbol mappings for the query range indexed by instrument ID.
PitSymbolMap CreateSymbolMapForDate(
date::year_month_day date) const; PitSymbolMap
A point-in-time symbol map. Useful for working with real-time symbology or a historical request over a single day and other situations where the symbol mappings are known to not change. These objects can be obtained from Metadata::CreateSymbolMapForDate for historical data.
PitSymbolMap();
PitSymbolMap(const Metadata& metadata, date::year_month_day date); PitSymbolMap::At
Get the symbol mapping for a record.
Parameters
| Parameter | Type | Description |
|---|---|---|
rec | R | The record to fetch a symbol mapping for. |
Returns
const std::string&
The corresponding text symbol for the record's instrument ID.
Raises an exception if no mapping is found.
template <typename R>
const std::string& At(const R& rec) const; PitSymbolMap::OnRecord
Update the symbol map with the contents of the record.
Only SymbolMappingMsg records affect the map; all other record types will be ignored.
Parameters
| Parameter | Type | Description |
|---|---|---|
rec | Record | The record to update the map from. |
void OnRecord(const Record& rec); PitSymbolMap::OnSymbolMapping
Update the symbol map with the contents of the record, either a SymbolMappingMsg or a SymbolMappingMsgV1.
Parameters
| Parameter | Type | Description |
|---|---|---|
symbol_mapping | SymbolMappingMsgV1 or SymbolMappingMsg | The record to update the map from. |
void OnSymbolMapping(const SymbolMappingMsgV1& symbol_mapping);
void OnSymbolMapping(const SymbolMappingMsg& symbol_mapping); ILogReceiver
The ILogReceiver is an interface for objects that accept log messages from the databento client library.
Two implementations are provided, but the interface can be extended for additional configuration.
Implementations
- ConsoleLogReceiver: a log receiver that forwards messages to a std::ostream,
like
std::clog,std::cerr, andstd::cout - NullLogReceiver: a log receiver that ignores all log messages
ILogReceiver::Receive
Receive a log message from the databento client library.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | LogLevel | The severity of the log event. |
msg | std::string | The message describing the event. |
Returns
void
void Receive(LogLevel level, const std::string& msg); ILogReceiver::Default
Get the default ILogReceiver implementation.
Returns
ILogReceiver*
Returns a pointer to the default log receiver, a ConsoleLogReceiver which logs info-level messages and above to std::clog.
static ILogReceiver* Default(); ConsoleLogReceiver
The ConsoleLogReceiver implements the ILogReceiver interface forwarding messages to the console, one of the following std::ostream objects.
Parameters
| Parameter | Type | Description |
|---|---|---|
min_level | LogLevel | The minimum severity required to be forwarded to stream. Defaults to Info, meaning Debug messages will be ignored. |
stream | std::ostream& | The output stream to forward messages to. Defaults to std::clog which writes to standard error. |
ConsoleLogReceiver();
ConsoleLogReceiver(LogLevel min_level);
ConsoleLogReceiver(std::ostream& stream);
ConsoleLogReceiver(LogLevel min_level, std::ostream& stream); ConsoleLogReceiver::Receive
Receive a log message from the databento client library.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | LogLevel | The severity of the log event. |
msg | std::string | The message describing the event. |
Returns
void
void Receive(LogLevel level, const std::string& msg);