Skip to content
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

VER: Release 0.26.0 #73

Merged
merged 6 commits into from
Jan 7, 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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.26.0 - 2025-01-07

### Enhancements
- Added `v3` namespace in preparation for future DBN version 3 release. DBN version 2
remains the current and default version
- Added `v3::InstrumentDefMsg` record with new fields to support normalizing multi-leg
strategy definitions
- Removal of statistics-schema related fields `trading_reference_price`,
`trading_reference_date`, and `settl_price_type`
- Removal of the status-schema related field `md_security_trading_status`
- Added `from_instrument_def_v1_to_v3` and `from_instrument_def_v2_to_v3` conversion
functions to the C API
- Updated the value of the `MAX_RECORD_LEN` constant for the changes to
`InstrumentDefMsg` in version 3
- Added initial support for merging DBN:
- Decoding streams: `MergeDecoder` and `MergeRecordDecoder` structs
- Metadata: `MergeDecoder` struct and `Metadata::merge()` method
- In the CLI: specify more than one input file to initiate a merge
- Relaxed `DecodeRecord` trait constraint on `StreamIterDecoder`'s inner decoder
- Added `DbnMetadata` implementation for `StreamInnerDecoder` if the inner decoder
implements `DbnMetadata`
- Eliminate `unsafe` in `From` implementations for record structs from different versions

## 0.25.0 - 2024-12-17

### Breaking changes
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resolver = "2"
[workspace.package]
authors = ["Databento <[email protected]>"]
edition = "2021"
version = "0.25.0"
version = "0.26.0"
documentation = "https://databento.com/docs"
repository = "https://github.com/databento/dbn"
license = "Apache-2.0"
Expand Down
14 changes: 13 additions & 1 deletion c/src/compat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dbn::{
compat::{ErrorMsgV1, InstrumentDefMsgV1, SymbolMappingMsgV1, SystemMsgV1},
compat::{ErrorMsgV1, InstrumentDefMsgV1, InstrumentDefMsgV3, SymbolMappingMsgV1, SystemMsgV1},
ErrorMsg, InstrumentDefMsg, SymbolMappingMsg, SystemMsg,
};

Expand All @@ -15,6 +15,18 @@ pub extern "C" fn from_instrument_def_v1_to_v2(def_v1: &InstrumentDefMsgV1) -> I
InstrumentDefMsg::from(def_v1)
}

/// Converts a V1 InstrumentDefMsg to V3.
#[no_mangle]
pub extern "C" fn from_instrument_def_v1_to_v3(def_v1: &InstrumentDefMsgV1) -> InstrumentDefMsgV3 {
InstrumentDefMsgV3::from(def_v1)
}

/// Converts a V2 InstrumentDefMsg to V3.
#[no_mangle]
pub extern "C" fn from_instrument_def_v2_to_v3(def_v2: &InstrumentDefMsg) -> InstrumentDefMsgV3 {
InstrumentDefMsgV3::from(def_v2)
}

/// Converts an V1 SymbolMappingMsg to V2.
#[no_mangle]
pub extern "C" fn from_symbol_mapping_v1_to_v2(def_v1: &SymbolMappingMsgV1) -> SymbolMappingMsg {
Expand Down
56 changes: 48 additions & 8 deletions c/src/text_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ fn write_null_and_ret(mut cursor: io::Cursor<&mut [u8]>, res: dbn::Result<()>) -
mod tests {
use std::os::raw::c_char;

use dbn::{compat::InstrumentDefMsgV1, InstrumentDefMsg};
use dbn::{v1, v2, v3};

use super::*;

#[test]
fn test_serialize_def_v1() {
let mut def_v1 = InstrumentDefMsgV1 {
raw_symbol: [b'a' as c_char; dbn::compat::SYMBOL_CSTR_LEN_V1],
let mut def_v1 = v1::InstrumentDefMsg {
raw_symbol: [b'a' as c_char; v1::SYMBOL_CSTR_LEN],
..Default::default()
};
def_v1.raw_symbol[dbn::compat::SYMBOL_CSTR_LEN_V1 - 1] = 0;
def_v1.raw_symbol[v1::SYMBOL_CSTR_LEN - 1] = 0;
let mut buf = [0; 5000];
assert!(
unsafe {
Expand All @@ -301,11 +301,11 @@ mod tests {

#[test]
fn test_serialize_def_v2() {
let mut def_v2 = InstrumentDefMsg {
raw_symbol: [b'a' as c_char; dbn::compat::SYMBOL_CSTR_LEN_V2],
let mut def_v2 = v2::InstrumentDefMsg {
raw_symbol: [b'a' as c_char; v2::SYMBOL_CSTR_LEN],
..Default::default()
};
def_v2.raw_symbol[dbn::compat::SYMBOL_CSTR_LEN_V2 - 1] = 0;
def_v2.raw_symbol[v2::SYMBOL_CSTR_LEN - 1] = 0;
let mut buf = [0; 5000];
assert!(
unsafe {
Expand All @@ -325,7 +325,47 @@ mod tests {
let res = std::str::from_utf8(buf.as_slice()).unwrap();
assert!(res.contains(&format!(
"\"raw_symbol\":\"{}\",",
"a".repeat(dbn::compat::SYMBOL_CSTR_LEN_V2 - 1)
"a".repeat(v2::SYMBOL_CSTR_LEN - 1)
)));
}

#[test]
fn test_serialize_def_v3() {
let mut def_v3 = v3::InstrumentDefMsg {
raw_symbol: [b'a' as c_char; v3::SYMBOL_CSTR_LEN],
leg_raw_symbol: [b'c' as c_char; v3::SYMBOL_CSTR_LEN],
..Default::default()
};
def_v3.raw_symbol[v3::SYMBOL_CSTR_LEN - 1] = 0;
def_v3.leg_raw_symbol[v3::SYMBOL_CSTR_LEN - 1] = 0;
def_v3.leg_index = 1;
def_v3.leg_count = 4;
let mut buf = [0; 5000];
assert!(
unsafe {
s_serialize_record(
buf.as_mut_ptr().cast(),
buf.len(),
&def_v3.hd,
&SerializeRecordOptions {
encoding: TextEncoding::Json,
ts_out: false,
pretty_px: false,
pretty_ts: false,
},
)
} > 0
);
let res = std::str::from_utf8(buf.as_slice()).unwrap();
assert!(res.contains(&format!(
"\"raw_symbol\":\"{}\",",
"a".repeat(v3::SYMBOL_CSTR_LEN - 1)
)));
assert!(res.contains(&format!(
"\"leg_raw_symbol\":\"{}\",",
"c".repeat(v3::SYMBOL_CSTR_LEN - 1)
)));
assert!(res.contains("\"leg_index\":1,"));
assert!(res.contains("\"leg_count\":4,"));
}
}
4 changes: 2 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "databento-dbn"
version = "0.25.0"
version = "0.26.0"
description = "Python bindings for encoding and decoding Databento Binary Encoding (DBN)"
authors = ["Databento <[email protected]>"]
license = "Apache-2.0"
Expand All @@ -17,7 +17,7 @@ build-backend = "maturin"

[project]
name = "databento-dbn"
version = "0.25.0"
version = "0.26.0"
authors = [
{ name = "Databento", email = "[email protected]" }
]
Expand Down
Loading
Loading