Skip to content

VER: Release 0.34.0 #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2025
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.34.0 - 2025-04-22

### Enhancements
- Added `SystemCode` and `ErrorCode` enums to indicate types of system and error
messages
- Converting a `v1::SystemMsg` to a `v2::SystemMsg` now sets to `code` to the heartbeat
value
- Introduced `kAssetCstrLen` constant containing the size of `asset` field in
`InstrumentDefMsg`

### Breaking changes
- Increased the size of `asset` field in `v3::InstrumentDefMsg` from 7 to 11. The
`v3::InstrumentDefMsg` message size remains 520 bytes.
- Set minimum CMake version to 3.24
- Changed type of `code` field in `SystemMsg` to `SystemCode`
- Changed type of `code` field in `ErrorMsg` to `ErrorCode`

### Bug fixes
- Changed `TriState` to a regular enum to handle unexpected values
- Fixed `ccache` support
- Changed to explicitly only support being built as a static library

## 0.33.0 - 2025-04-15

### Enhancements
Expand Down
65 changes: 24 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24..4.0)

#
# Project details
#

project("databento" VERSION 0.33.0 LANGUAGES CXX)
project(
databento
VERSION 0.34.0
LANGUAGES CXX
DESCRIPTION "Official Databento client library"
)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)

#
Expand Down Expand Up @@ -83,6 +88,7 @@ endif()

add_library(
${PROJECT_NAME}
STATIC
${headers}
${sources}
)
Expand All @@ -101,6 +107,7 @@ message(STATUS "Added all header and implementation files.")
#

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
include(cmake/CompilerWarnings.cmake)
set_target_warnings(${PROJECT_NAME})
include(cmake/Sanitizers.cmake)
Expand Down Expand Up @@ -143,19 +150,11 @@ else()
set(json_version 3.11.3)
# Required to correctly install nlohmann_json
set(JSON_Install ON)
if(CMAKE_VERSION VERSION_LESS 3.24)
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v${json_version}/json.tar.xz
)
else()
# DOWNLOAD_EXTRACT_TIMESTAMP added in 3.24
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v${json_version}/json.tar.xz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
endif()
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v${json_version}/json.tar.xz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(json)
# Ignore compiler warnings in headers
add_system_include_property(nlohmann_json)
Expand All @@ -175,19 +174,11 @@ if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_HTTPLIB)
endif()
else()
set(httplib_version 0.20.0)
if(CMAKE_VERSION VERSION_LESS 3.24)
FetchContent_Declare(
httplib
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
)
else()
# DOWNLOAD_EXTRACT_TIMESTAMP added in 3.24
FetchContent_Declare(
httplib
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
endif()
FetchContent_Declare(
httplib
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(httplib)
# Ignore compiler warnings in headers
add_system_include_property(httplib)
Expand All @@ -207,19 +198,11 @@ if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_DATE)
endif()
else()
set(date_version 3.0.3)
if(CMAKE_VERSION VERSION_LESS 3.24)
FetchContent_Declare(
date_src
URL https://github.com/HowardHinnant/date/archive/refs/tags/v${date_version}.tar.gz
)
else()
# DOWNLOAD_EXTRACT_TIMESTAMP added in 3.24
FetchContent_Declare(
date_src
URL https://github.com/HowardHinnant/date/archive/refs/tags/v${date_version}.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
endif()
FetchContent_Declare(
date_src
URL https://github.com/HowardHinnant/date/archive/refs/tags/v${date_version}.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(date_src)
# Ignore compiler warnings in headers
add_system_include_property(date)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The client supports both streaming real-time and historical market data through

## Usage

The minimum C++ standard is C++17 and the minimum CMake version is 3.14.
The minimum C++ standard is C++17 and the minimum CMake version is 3.24.

### Integration

Expand All @@ -18,7 +18,7 @@ Your `CMakeLists.txt` should look something like the following:

```cmake
# CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24)

project(databento_example)
include(FetchContent)
Expand Down
3 changes: 1 addition & 2 deletions cmake/StandardSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "Found and enabled ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24)

project(
${CMAKE_PROJECT_NAME}Examples
Expand Down
2 changes: 1 addition & 1 deletion examples/historical/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24)

add_example_target(batch batch.cpp)
add_example_target(metadata metadata.cpp)
Expand Down
2 changes: 1 addition & 1 deletion examples/live/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24)

add_example_target(live-readme readme.cpp)
add_example_target(simple simple.cpp)
Expand Down
2 changes: 2 additions & 0 deletions include/databento/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ static constexpr auto kUndefTimestamp =
static constexpr auto kDbnVersion = 2;
// The length of fixed-length symbol strings.
static constexpr auto kSymbolCstrLen = 71;
// The length of fixed-length asset string.
static constexpr auto kAssetCstrLen = 7;
// The multiplier for converting the `length` field in `RecordHeader` to bytes.
static constexpr std::size_t kRecordHeaderLengthMultiplier = 4;

Expand Down
47 changes: 46 additions & 1 deletion include/databento/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,55 @@ using trading_event::TradingEvent;

// An enum for representing unknown, true, or false values. Equivalent to a
// std::optional<bool>.
enum class TriState : char {
namespace tri_state {
enum TriState : char {
// The value is not applicable or not known.
NotAvailable = '~',
// False
No = 'N',
// True
Yes = 'Y',
};
} // namespace tri_state
using tri_state::TriState;

namespace error_code {
enum ErrorCode : std::uint8_t {
// The authentication step failed.
AuthFailed = 1,
// The user account or API key were deactivated.
ApiKeyDeactivated = 2,
// The user has exceeded their open connection limit
ConnectionLimitExceeded = 3,
// One or more symbols failed to resolve.
SymbolResolutionFailed = 4,
// There was an issue with a subscription request (other than symbol
// resolution).
InvalidSubscription = 5,
// An error occurred in the gateway.
InternalError = 6,

Unset = 255,
};
} // namespace error_code
using error_code::ErrorCode;

namespace system_code {
enum SystemCode : std::uint8_t {
// A message sent in the absence of other records to indicate the connection
// remains open.
Heartbeat = 0,
// An acknowledgement of a subscription request.
SubscriptionAck = 1,
// The gateway has detected this session is falling behind real-time.
SlowReaderWarning = 2,
// Indicates a replay subscription has caught up with real-time data.
ReplayCompleted = 3,

Unset = 255,
};
} // namespace system_code
using system_code::SystemCode;

// Convert a HistoricalGateway to a URL.
const char* UrlFromGateway(HistoricalGateway gateway);
Expand Down Expand Up @@ -474,6 +515,8 @@ const char* ToString(StatusReason status_reason);
const char* ToString(TradingEvent trading_event);
const char* ToString(TriState tri_state);
const char* ToString(VersionUpgradePolicy upgrade_policy);
const char* ToString(ErrorCode error_code);
const char* ToString(SystemCode system_code);

std::ostream& operator<<(std::ostream& out, Schema schema);
std::ostream& operator<<(std::ostream& out, Encoding encoding);
Expand Down Expand Up @@ -501,6 +544,8 @@ std::ostream& operator<<(std::ostream& out, TradingEvent trading_event);
std::ostream& operator<<(std::ostream& out, TriState tri_state);
std::ostream& operator<<(std::ostream& out,
VersionUpgradePolicy upgrade_policy);
std::ostream& operator<<(std::ostream& out, ErrorCode error_code);
std::ostream& operator<<(std::ostream& out, SystemCode system_code);

template <>
Schema FromString(const std::string& str);
Expand Down
14 changes: 10 additions & 4 deletions include/databento/record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstddef>
#include <cstdint>
#include <cstring> // strncmp
#include <limits>
#include <string>
#include <tuple> // tie
#include <type_traits>
Expand Down Expand Up @@ -433,7 +434,7 @@ struct InstrumentDefMsg {
std::array<char, kSymbolCstrLen> raw_symbol;
std::array<char, 21> group;
std::array<char, 5> exchange;
std::array<char, 7> asset;
std::array<char, kAssetCstrLen> asset;
std::array<char, 7> cfi;
std::array<char, 7> security_type;
std::array<char, 31> unit_of_measure;
Expand Down Expand Up @@ -528,7 +529,7 @@ struct ErrorMsg {

RecordHeader hd;
std::array<char, 302> err;
std::uint8_t code;
ErrorCode code;
std::uint8_t is_last;
};
static_assert(sizeof(ErrorMsg) == 320, "ErrorMsg size must match Rust");
Expand Down Expand Up @@ -560,12 +561,17 @@ struct SystemMsg {
UnixNanos IndexTs() const { return hd.ts_event; }
const char* Msg() const { return msg.data(); }
bool IsHeartbeat() const {
return std::strncmp(msg.data(), "Heartbeat", 9) == 0;
// Check if code is unset
if (static_cast<std::uint8_t>(code) ==
std::numeric_limits<std::uint8_t>::max()) {
return std::strncmp(msg.data(), "Heartbeat", 9) == 0;
}
return code == SystemCode::Heartbeat;
}

RecordHeader hd;
std::array<char, 303> msg;
std::uint8_t code;
SystemCode code;
};
static_assert(sizeof(SystemMsg) == 320, "SystemMsg size must match Rust");
static_assert(alignof(SystemMsg) == 8, "Must have 8-byte alignment");
Expand Down
6 changes: 4 additions & 2 deletions include/databento/v1.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "databento/datetime.hpp" // UnixNanos
#include "databento/constants.hpp" // kSymbolCstrLen
#include "databento/datetime.hpp" // UnixNanos
#include "databento/enums.hpp"
#include "databento/record.hpp"
#include "databento/v2.hpp"
Expand All @@ -13,6 +14,7 @@ struct InstrumentDefMsg;

namespace v1 {
static constexpr std::size_t kSymbolCstrLen = 22;
static constexpr std::size_t kAssetCstrLen = databento::kAssetCstrLen;

using MboMsg = databento::MboMsg;
using TradeMsg = databento::TradeMsg;
Expand Down Expand Up @@ -92,7 +94,7 @@ struct InstrumentDefMsg {
std::array<char, kSymbolCstrLen> raw_symbol;
std::array<char, 21> group;
std::array<char, 5> exchange;
std::array<char, 7> asset;
std::array<char, kAssetCstrLen> asset;
std::array<char, 7> cfi;
std::array<char, 7> security_type;
std::array<char, 31> unit_of_measure;
Expand Down
1 change: 1 addition & 0 deletions include/databento/v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace databento::v2 {
static constexpr std::size_t kSymbolCstrLen = databento::kSymbolCstrLen;
static constexpr std::size_t kAssetCstrLen = databento::kAssetCstrLen;

using MboMsg = databento::MboMsg;
using TradeMsg = databento::TradeMsg;
Expand Down
5 changes: 3 additions & 2 deletions include/databento/v3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace databento::v3 {
static constexpr std::size_t kSymbolCstrLen = databento::kSymbolCstrLen;
static constexpr std::size_t kAssetCstrLen = 11;

using MboMsg = databento::MboMsg;
using TradeMsg = databento::TradeMsg;
Expand Down Expand Up @@ -100,7 +101,7 @@ struct InstrumentDefMsg {
std::array<char, kSymbolCstrLen> raw_symbol;
std::array<char, 21> group;
std::array<char, 5> exchange;
std::array<char, 7> asset;
std::array<char, kAssetCstrLen> asset;
std::array<char, 7> cfi;
std::array<char, 7> security_type;
std::array<char, 31> unit_of_measure;
Expand All @@ -124,7 +125,7 @@ struct InstrumentDefMsg {
InstrumentClass leg_instrument_class;
Side leg_side;
// padding for alignment
std::array<char, 21> reserved;
std::array<char, 17> reserved;
};
static_assert(sizeof(InstrumentDefMsg) == 520,
"InstrumentDefMsg size must match Rust");
Expand Down
2 changes: 1 addition & 1 deletion pkg/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Databento <[email protected]>
_pkgname=databento-cpp
pkgname=databento-cpp-git
pkgver=0.33.0
pkgver=0.34.0
pkgrel=1
pkgdesc="Official C++ client for Databento"
arch=('any')
Expand Down
Loading
Loading