Skip to content

Commit 84a307e

Browse files
authored
VER: Release 0.36.0
2 parents 1cf6409 + 6da3df6 commit 84a307e

File tree

93 files changed

+956
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+956
-680
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ build
22
CMakeSettings.json
33
vcpkg_installed
44
.vs
5+
.cache
56
!*.zst

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Changelog
22

3+
## 0.36.0 - 2025-05-27
4+
5+
This version marks the release of DBN version 3 (DBNv3), which is the new default.
6+
API methods and `DbnDecoder` support decoding all versions of DBN, but now default to
7+
upgrading data to version 3.
8+
9+
### Enhancements
10+
- Added `UpgradeToV3` variant to `VersionUpgradePolicy` enum
11+
- Version 1 and 2 structs can be converted to version 3 structs with templated `Upgrade`
12+
method
13+
- Metadata will now always be encoded with a length divisible by 8 bytes for better
14+
alignment
15+
- Added `is_last` field to live subscription requests which will be used to improve the
16+
handling of split subscription requests
17+
18+
### Breaking changes
19+
- Release of DBN version 3:
20+
- Definition schema:
21+
- Updated `InstrumentDefMsg` with new `leg_` fields to support multi-leg strategy
22+
definitions.
23+
- Expanded `raw_instrument_id` to 64 bits to support more venues. Like other 64-bit
24+
integer fields, its value will now be quoted in JSON
25+
- Removed `trading_reference_date`, `trading_reference_price`, and
26+
`settl_price_type` fields which will be normalized in the statistics schema
27+
- Removed `md_security_trading_status` better served by the status schema
28+
- Updated `asset` to 11 bytes and `kAssetCstrLen` to match
29+
- Statistics schema:
30+
- Updated `StatMsg` has an expanded 64-bit `quantity` field. `kUndefStatQuantity`
31+
has been updated to match
32+
- The previous `StatMsg` has been moved to `v2::StatMsg` or `StatMsgV2`
33+
34+
### Bug fixes
35+
- Fixed "Zstd error decompressing: Operation made no progress over multiple calls, due
36+
to output buffer being full" error with `TimeseriesGetRange`
37+
- Fixed missing implementation of `HistoricalBuilder::SetLogReceiver`
38+
339
## 0.35.1 - 2025-05-20
440

541
### Bug fixes

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24..4.0)
66

77
project(
88
databento
9-
VERSION 0.35.1
9+
VERSION 0.36.0
1010
LANGUAGES CXX
1111
DESCRIPTION "Official Databento client library"
1212
)

cmake/SourcesAndHeaders.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ set(sources
7171
src/symbol_map.cpp
7272
src/symbology.cpp
7373
src/v1.cpp
74-
src/v3.cpp
74+
src/v2.cpp
7575
)

examples/historical/timeseries_get_range.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
1-
#include <chrono>
2-
#include <ctime>
3-
#include <iomanip>
41
#include <iostream> // setw
5-
#ifdef _WIN32
6-
// _mkgmtime is equivalent to timegm
7-
#define timegm _mkgmtime
8-
#endif
92

103
#include "databento/constants.hpp"
11-
#include "databento/datetime.hpp"
124
#include "databento/enums.hpp"
135
#include "databento/historical.hpp"
146

15-
// Converts a date to Unix Epoch nanoseconds
16-
databento::UnixNanos DateToUnixNanos(int year, int month, int day) {
17-
std::tm time{};
18-
time.tm_year = year - 1900;
19-
// January is 0
20-
time.tm_mon = month - 1;
21-
time.tm_mday = day;
22-
return databento::UnixNanos{std::chrono::seconds{::timegm(&time)}};
23-
}
24-
257
int main() {
268
auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();
27-
const databento::UnixNanos start = DateToUnixNanos(2022, 10, 3);
28-
const databento::UnixNanos end = DateToUnixNanos(2022, 10, 4);
299
const auto limit = 1000;
3010
client.TimeseriesGetRange(
31-
databento::dataset::kGlbxMdp3, {start, end}, {"ESZ2"},
11+
databento::dataset::kGlbxMdp3,
12+
databento::DateTimeRange<std::string>{"2022-10-03"}, {"ESZ2"},
3213
databento::Schema::Trades, databento::SType::RawSymbol,
3314
databento::SType::InstrumentId, limit,
3415
[](databento::Metadata&& metadata) { std::cout << metadata << '\n'; },

include/databento/constants.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ static constexpr auto kUndefOrderSize =
1616
std::numeric_limits<std::uint32_t>::max();
1717
// The sentinel value for an unset statistic quantity.
1818
static constexpr auto kUndefStatQuantity =
19-
std::numeric_limits<std::int32_t>::max();
19+
std::numeric_limits<std::int64_t>::max();
2020
// The sentinel value for an unset or null timestamp.
2121
static constexpr auto kUndefTimestamp =
2222
std::numeric_limits<std::uint64_t>::max();
2323
// The current version of the DBN encoding.
24-
static constexpr auto kDbnVersion = 2;
24+
static constexpr auto kDbnVersion = 3;
2525
// The length of fixed-length symbol strings.
2626
static constexpr auto kSymbolCstrLen = 71;
2727
// The length of fixed-length asset string.
28-
static constexpr auto kAssetCstrLen = 7;
28+
static constexpr auto kAssetCstrLen = 11;
2929
// The multiplier for converting the `length` field in `RecordHeader` to bytes.
3030
static constexpr std::size_t kRecordHeaderLengthMultiplier = 4;
3131

include/databento/dbn_decoder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
namespace databento {
1717
// DBN decoder. Set upgrade_policy to control how DBN version 1 data should be
18-
// handled. Defaults to upgrading DBNv1 data to version 2 (the current version).
18+
// handled. Defaults to upgrading DBN versions 1 and 2 to version 3 (the current
19+
// version).
1920
class DbnDecoder {
2021
public:
2122
DbnDecoder(ILogReceiver* log_receiver, InFileStream file_stream);

include/databento/dbn_encoder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class DbnEncoder {
3232
void EncodeRecord(const Record& record);
3333

3434
private:
35-
static std::uint32_t CalcLength(const Metadata& metadata);
35+
static std::pair<std::uint32_t, std::uint32_t> CalcLength(
36+
const Metadata& metadata);
3637

3738
IWritable* output_;
3839
};

include/databento/detail/buffer.hpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <cstddef>
44
#include <memory>
55
#include <new>
6+
#include <ostream>
67

78
#include "databento/ireadable.hpp"
89
#include "databento/iwritable.hpp"
@@ -22,22 +23,32 @@ class Buffer : public IReadable, public IWritable {
2223
void WriteAll(const char* data, std::size_t length);
2324
void WriteAll(const std::byte* data, std::size_t length) override;
2425

25-
std::byte*& WriteBegin() { return write_pos_; }
26+
std::byte* WriteBegin() { return write_pos_; }
2627
std::byte* WriteEnd() { return end_; }
2728
const std::byte* WriteBegin() const { return write_pos_; }
2829
const std::byte* WriteEnd() const { return end_; }
30+
// Indicate how many bytes were written
31+
void Fill(std::size_t length) { write_pos_ += length; }
2932
std::size_t WriteCapacity() const {
3033
return static_cast<std::size_t>(end_ - write_pos_);
3134
}
3235

33-
/// Will throw if `length > ReadCapacity()`.
36+
// Will throw if `length > ReadCapacity()`.
3437
void ReadExact(std::byte* buffer, std::size_t length) override;
3538
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
3639

37-
std::byte*& ReadBegin() { return read_pos_; }
40+
std::byte* ReadBegin() { return read_pos_; }
3841
std::byte* ReadEnd() { return write_pos_; }
3942
const std::byte* ReadBegin() const { return read_pos_; }
4043
const std::byte* ReadEnd() const { return write_pos_; }
44+
// Indicate how mnay bytes were read
45+
void Consume(std::size_t length) {
46+
read_pos_ += length;
47+
if (static_cast<std::size_t>(read_pos_ - buf_.get()) > (Capacity() / 2)) {
48+
Shift();
49+
}
50+
}
51+
void ConsumeNoShift(std::size_t length) { read_pos_ += length; }
4152
std::size_t ReadCapacity() const {
4253
return static_cast<std::size_t>(write_pos_ - read_pos_);
4354
}
@@ -52,6 +63,8 @@ class Buffer : public IReadable, public IWritable {
5263
void Reserve(std::size_t capacity);
5364
void Shift();
5465

66+
friend std::ostream& operator<<(std::ostream& stream, const Buffer& buffer);
67+
5568
private:
5669
static constexpr std::align_val_t kAlignment{8};
5770

include/databento/enums.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ enum class StatUpdateAction : std::uint8_t {
303303
enum class VersionUpgradePolicy : std::uint8_t {
304304
AsIs = 0,
305305
UpgradeToV2 = 1,
306+
UpgradeToV3 = 2,
306307
};
307308

308309
namespace status_action {

0 commit comments

Comments
 (0)