Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Changelog

## 0.38.2 - 2025-07-01

### Enhancements
- Added `LogPlatformInfo()` function which logs the client version, compiler, and
operating system info to aid troubleshooting
- Added compiler and operating system info to the user agent to aid troubleshooting
- Standardized `client` info sent by live clients to match historical
- Added methods to the client builders to extend the user agents with a custom string

### Bug fixes
- Fixed missing implementation for `LiveBuilder::SetBufferSize()`
- Fixed checking of warnings from server in Historical API in `TimeseriesGetRange()` and
`TimeseriesGetRangeToFile()`

## 0.38.1 - 2025-06-25

### Enhancements
- Added `range_by_schema` field to `DatasetRange` struct
- Changed historical `TimeseriesGetRange` and `TimeseriesGetRangeToFile` methods to use
a `POST` request to allow for requesting supported maximum of 2000 symbols
- Changed historical `TimeseriesGetRange()` and `TimeseriesGetRangeToFile()` methods to
use a `POST` request to allow for requesting supported maximum of 2000 symbols
- Added logging around `Historical::BatchDownload`
- Changed the following Venue, Publisher, and Dataset descriptions:
- "ICE Futures Europe (Financials)" renamed to "ICE Europe Financials"
Expand Down
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24..4.0)

project(
databento
VERSION 0.38.1
VERSION 0.38.2
LANGUAGES CXX
DESCRIPTION "Official Databento client library"
)
Expand Down Expand Up @@ -60,14 +60,19 @@ if(IS_BIG_ENDIAN)
endif()

#
# Add version header
# Add templated headers
#

configure_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/version.hpp.in
include/${PROJECT_NAME}/version.hpp
@ONLY
)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/system.hpp.in
include/${PROJECT_NAME}/system.hpp
@ONLY
)

#
# Find all headers and implementation files
Expand Down Expand Up @@ -237,7 +242,7 @@ target_include_directories(
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # for generated version.hpp
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # for generated version.hpp and system.hpp
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
Expand Down Expand Up @@ -310,6 +315,7 @@ install(
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/system.hpp
${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp
DESTINATION
${INCLUDE_INSTALL_DIR}
Expand Down
6 changes: 6 additions & 0 deletions cmake/system.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define DATABENTO_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@"
#define DATABENTO_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@"
#define DATABENTO_SYSTEM_ID "@CMAKE_SYSTEM_NAME@"
#define DATABENTO_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@"
13 changes: 5 additions & 8 deletions cmake/version.hpp.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#ifndef @PROJECT_NAME_UPPERCASE@_VERSION_H_
#define @PROJECT_NAME_UPPERCASE@_VERSION_H_
#pragma once

#define @PROJECT_NAME_UPPERCASE@_VERSION "@PROJECT_VERSION@"
#define DATABENTO_VERSION "@PROJECT_VERSION@"

#define @PROJECT_NAME_UPPERCASE@_MAJOR_VERSION @PROJECT_VERSION_MAJOR@
#define @PROJECT_NAME_UPPERCASE@_MINOR_VERSION @PROJECT_VERSION_MINOR@
#define @PROJECT_NAME_UPPERCASE@_PATCH_VERSION @PROJECT_VERSION_PATCH@

#endif // @PROJECT_NAME_UPPERCASE@_VERSION_H_
#define DATABENTO_MAJOR_VERSION @PROJECT_VERSION_MAJOR@
#define DATABENTO_MINOR_VERSION @PROJECT_VERSION_MINOR@
#define DATABENTO_PATCH_VERSION @PROJECT_VERSION_PATCH@
2 changes: 1 addition & 1 deletion examples/historical/timeseries_get_range.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <iostream> // setw
#include <iostream>

#include "databento/constants.hpp"
#include "databento/enums.hpp"
Expand Down
8 changes: 8 additions & 0 deletions include/databento/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <cstdint>
#include <limits>

#include "databento/system.hpp" // DATABENTO_CXX_COMPILER_*, DATABENTO_SYSTEM_*
#include "databento/version.hpp" // DATABENTO_VERSION

namespace databento {
static constexpr auto kApiVersion = 0;
static constexpr auto kApiVersionStr = "0";
Expand All @@ -29,6 +32,11 @@ static constexpr auto kAssetCstrLen = 11;
// The multiplier for converting the `length` field in `RecordHeader` to bytes.
static constexpr std::size_t kRecordHeaderLengthMultiplier = 4;

static constexpr auto kUserAgent =
"Databento/" DATABENTO_VERSION " C++/" DATABENTO_CXX_COMPILER_ID
"/" DATABENTO_CXX_COMPILER_VERSION " " DATABENTO_SYSTEM_ID
"/" DATABENTO_SYSTEM_VERSION;

// This is not a comprehensive list of datasets, for that see the `Dataset`
// enum.
namespace dataset {
Expand Down
8 changes: 6 additions & 2 deletions include/databento/detail/dbn_buffer_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@

#include "databento/detail/buffer.hpp"
#include "databento/detail/zstd_stream.hpp"
#include "databento/enums.hpp"
#include "databento/record.hpp"
#include "databento/timeseries.hpp"

namespace databento::detail {
class DbnBufferDecoder {
public:
// The instance cannot outlive the lifetime of these references.
DbnBufferDecoder(const MetadataCallback& metadata_callback,
DbnBufferDecoder(VersionUpgradePolicy upgrade_policy,
const MetadataCallback& metadata_callback,
const RecordCallback& record_callback)
: metadata_callback_{metadata_callback},
: upgrade_policy_{upgrade_policy},
metadata_callback_{metadata_callback},
record_callback_{record_callback},
zstd_stream_{std::make_unique<Buffer>()},
zstd_buffer_{static_cast<Buffer*>(zstd_stream_.Input())} {}
Expand Down Expand Up @@ -49,6 +52,7 @@ class DbnBufferDecoder {
return stream;
}

const VersionUpgradePolicy upgrade_policy_;
const MetadataCallback& metadata_callback_;
const RecordCallback& record_callback_;
ZstdDecodeStream zstd_stream_;
Expand Down
2 changes: 1 addition & 1 deletion include/databento/detail/http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class HttpClient {

private:
static bool IsErrorStatus(int status_code);
static httplib::ResponseHandler MakeStreamResponseHandler(int& out_status);
static void CheckStatusAndStreamRes(const std::string& path, int status_code,
std::string&& err_body,
const httplib::Result& res);

httplib::ResponseHandler MakeStreamResponseHandler(int& out_status);
nlohmann::json CheckAndParseResponse(const std::string& path,
httplib::Result&& res) const;
void CheckWarnings(const httplib::Response& response) const;
Expand Down
44 changes: 38 additions & 6 deletions include/databento/historical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
#include "databento/datetime.hpp" // DateRange, DateTimeRange, UnixNanos
#include "databento/dbn_file_store.hpp"
#include "databento/detail/http_client.hpp" // HttpClient
#include "databento/enums.hpp" // BatchState, Delivery, DurationInterval, Schema, SType
#include "databento/enums.hpp" // BatchState, Delivery, DurationInterval, Schema, SType, VersionUpgradePolicy
#include "databento/metadata.hpp" // DatasetConditionDetail, DatasetRange, FieldDetail, PublisherDetail, UnitPricesForMode
#include "databento/symbology.hpp" // SymbologyResolution
#include "databento/timeseries.hpp" // KeepGoing, MetadataCallback, RecordCallback

namespace databento {
// Forward declarations
class HistoricalBuilder;
class ILogReceiver;

// A client for interfacing with Databento's historical market data API.
class Historical {
public:
// WARNING: Will be deprecated in the future in favor of the builder
Historical(ILogReceiver* log_receiver, std::string key,
HistoricalGateway gateway);
// Primarily for unit tests
Historical(ILogReceiver* log_receiver, std::string key, std::string gateway,
std::uint16_t port);

/*
* Getters
Expand Down Expand Up @@ -227,8 +227,17 @@ class Historical {
const std::filesystem::path& file_path);

private:
friend HistoricalBuilder;

using HttplibParams = std::multimap<std::string, std::string>;

Historical(ILogReceiver* log_receiver, std::string key,
HistoricalGateway gateway, VersionUpgradePolicy upgrade_policy,
std::string user_agent_ext);
Historical(ILogReceiver* log_receiver, std::string key, std::string gateway,
std::uint16_t port, VersionUpgradePolicy upgrade_policy,
std::string user_agent_ext);

BatchJob BatchSubmitJob(const HttplibParams& params);
void DownloadFile(const std::string& url,
const std::filesystem::path& output_path);
Expand All @@ -247,6 +256,8 @@ class Historical {
ILogReceiver* log_receiver_;
const std::string key_;
const std::string gateway_;
const std::string user_agent_ext_;
const VersionUpgradePolicy upgrade_policy_;
detail::HttpClient client_;
};

Expand All @@ -255,22 +266,43 @@ class HistoricalBuilder {
public:
HistoricalBuilder() = default;

/*
* Required setters
*/

// Sets `key_` based on the environment variable DATABENTO_API_KEY.
//
// NOTE: This is not thread-safe if `std::setenv` is used elsewhere in the
// program.
HistoricalBuilder& SetKeyFromEnv();
HistoricalBuilder& SetKey(std::string key);
HistoricalBuilder& SetGateway(HistoricalGateway gateway);

/*
* Optional setters
*/

// Set the version upgrade policy for when streaming DBN data from a prior
// version. Defaults to upgrading to DBNv3 (if not already).
HistoricalBuilder& SetUpgradePolicy(VersionUpgradePolicy upgrade_policy);
// Sets the receiver of the logs to be used by the client.
HistoricalBuilder& SetLogReceiver(ILogReceiver* log_receiver);
HistoricalBuilder& SetGateway(HistoricalGateway gateway);
// Overrides the gateway and port. This is an advanced method.
HistoricalBuilder& SetAddress(std::string gateway, std::uint16_t port);
// Appends to the default user agent.
HistoricalBuilder& ExtendUserAgent(std::string extension);

// Attempts to construct an instance of Historical or throws an exception if
// no key has been set.
Historical Build();

private:
ILogReceiver* log_receiver_{};
std::string key_;
HistoricalGateway gateway_{HistoricalGateway::Bo1};
std::string gateway_override_{};
std::uint16_t port_{};
std::string key_;
VersionUpgradePolicy upgrade_policy_{VersionUpgradePolicy::UpgradeToV3};
std::string user_agent_ext_;
};
} // namespace databento
13 changes: 8 additions & 5 deletions include/databento/live.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LiveBuilder {
LiveBuilder();

/*
* Required settters
* Required setters
*/

// Sets `key_` based on the environment variable DATABENTO_API_KEY.
Expand All @@ -33,13 +33,13 @@ class LiveBuilder {
LiveBuilder& SetDataset(std::string dataset);

/*
* Optional settters
* Optional setters
*/

// Whether to append the gateway send timestamp after each DBN message.
LiveBuilder& SetSendTsOut(bool send_ts_out);
// Set the version upgrade policy for when receiving DBN data from a prior
// version. Defaults to upgrading to DBNv2 (if not already).
// version. Defaults to upgrading to DBNv3 (if not already).
LiveBuilder& SetUpgradePolicy(VersionUpgradePolicy upgrade_policy);
// Sets the receiver of the logs to be used by the client.
LiveBuilder& SetLogReceiver(ILogReceiver* log_receiver);
Expand All @@ -49,13 +49,15 @@ class LiveBuilder {
LiveBuilder& SetAddress(std::string gateway, std::uint16_t port);
// Overrides the size of the buffer used for reading data from the TCP socket.
LiveBuilder& SetBufferSize(std::size_t size);
// Appends to the default user agent.
LiveBuilder& ExtendUserAgent(std::string extension);

/*
* Build a live client instance
*/

// Attempts to construct an instance of a blocking live client or throws an
// exception.
// Attempts to construct an instance of a blocking live client or throws
// an exception.
LiveBlocking BuildBlocking();
// Attempts to construct an instance of a threaded live client or throws an
// exception.
Expand All @@ -74,5 +76,6 @@ class LiveBuilder {
VersionUpgradePolicy upgrade_policy_{VersionUpgradePolicy::UpgradeToV3};
std::optional<std::chrono::seconds> heartbeat_interval_{};
std::size_t buffer_size_;
std::string user_agent_ext_;
};
} // namespace databento
19 changes: 10 additions & 9 deletions include/databento/live_blocking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ class LiveBlocking {
LiveBlocking(ILogReceiver* log_receiver, std::string key, std::string dataset,
bool send_ts_out, VersionUpgradePolicy upgrade_policy,
std::optional<std::chrono::seconds> heartbeat_interval,
std::size_t buffer_size);
std::size_t buffer_size, std::string user_agent_ext);
LiveBlocking(ILogReceiver* log_receiver, std::string key, std::string dataset,
std::string gateway, std::uint16_t port, bool send_ts_out,
VersionUpgradePolicy upgrade_policy,
std::optional<std::chrono::seconds> heartbeat_interval,
std::size_t buffer_size);
std::size_t buffer_size, std::string user_agent_ext);

std::string DetermineGateway() const;
std::uint64_t Authenticate();
Expand All @@ -118,14 +118,15 @@ class LiveBlocking {
static constexpr std::size_t kMaxStrLen = 24L * 1024;

ILogReceiver* log_receiver_;
std::string key_;
std::string dataset_;
std::string gateway_;
std::uint16_t port_;
bool send_ts_out_;
const std::string key_;
const std::string dataset_;
const std::string gateway_;
const std::string user_agent_ext_;
const std::uint16_t port_;
const bool send_ts_out_;
std::uint8_t version_{};
VersionUpgradePolicy upgrade_policy_;
std::optional<std::chrono::seconds> heartbeat_interval_;
const VersionUpgradePolicy upgrade_policy_;
const std::optional<std::chrono::seconds> heartbeat_interval_;
detail::TcpClient client_;
std::uint32_t sub_counter_{};
std::vector<LiveSubscription> subscriptions_;
Expand Down
4 changes: 2 additions & 2 deletions include/databento/live_threaded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ class LiveThreaded {
LiveThreaded(ILogReceiver* log_receiver, std::string key, std::string dataset,
bool send_ts_out, VersionUpgradePolicy upgrade_policy,
std::optional<std::chrono::seconds> heartbeat_interval,
std::size_t buffer_size);
std::size_t buffer_size, std::string user_agent_ext);
LiveThreaded(ILogReceiver* log_receiver, std::string key, std::string dataset,
std::string gateway, std::uint16_t port, bool send_ts_out,
VersionUpgradePolicy upgrade_policy,
std::optional<std::chrono::seconds> heartbeat_interval,
std::size_t buffer_size);
std::size_t buffer_size, std::string user_agent_ext);

// unique_ptr to be movable
std::unique_ptr<Impl> impl_;
Expand Down
3 changes: 3 additions & 0 deletions include/databento/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ class ConsoleLogReceiver : public ILogReceiver {

std::ostream& operator<<(std::ostream& out, LogLevel level);
const char* ToString(LogLevel level);

void LogPlatformInfo();
void LogPlatformInfo(ILogReceiver* log_receiver);
} // namespace databento
2 changes: 1 addition & 1 deletion pkg/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Databento <support@databento.com>
_pkgname=databento-cpp
pkgname=databento-cpp-git
pkgver=0.38.1
pkgver=0.38.2
pkgrel=1
pkgdesc="Official C++ client for Databento"
arch=('any')
Expand Down
Loading
Loading