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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.55.1 - 2025-06-02

#### Bug fixes
- Fixed decoding of DBN versions 1 and 2 statistics in `DBNStore.to_df()`

## 0.55.0 - 2025-05-29

#### Enhancements
Expand Down
63 changes: 43 additions & 20 deletions databento/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from databento_dbn import CMBP1Msg
from databento_dbn import ImbalanceMsg
from databento_dbn import InstrumentDefMsg
from databento_dbn import InstrumentDefMsgV1
from databento_dbn import MBOMsg
from databento_dbn import MBP1Msg
from databento_dbn import MBP10Msg
Expand All @@ -15,6 +14,8 @@
from databento_dbn import StatMsg
from databento_dbn import StatusMsg
from databento_dbn import TradeMsg
from databento_dbn import v1
from databento_dbn import v2

from databento.common.types import DBNRecord

Expand Down Expand Up @@ -51,26 +52,48 @@
Schema.BBO_1M: BBOMsg,
}

SCHEMA_STRUCT_MAP_V2: Final[dict[Schema, type[DBNRecord]]] = {
Schema.DEFINITION: v2.InstrumentDefMsg,
Schema.IMBALANCE: v2.ImbalanceMsg,
Schema.MBO: v2.MBOMsg,
Schema.MBP_1: v2.MBP1Msg,
Schema.MBP_10: v2.MBP10Msg,
Schema.OHLCV_1S: v2.OHLCVMsg,
Schema.OHLCV_1M: v2.OHLCVMsg,
Schema.OHLCV_1H: v2.OHLCVMsg,
Schema.OHLCV_1D: v2.OHLCVMsg,
Schema.STATISTICS: v2.StatMsg,
Schema.STATUS: v2.StatusMsg,
Schema.TBBO: v2.MBP1Msg,
Schema.TRADES: v2.TradeMsg,
Schema.CMBP_1: v2.CMBP1Msg,
Schema.CBBO_1S: v2.CBBOMsg,
Schema.CBBO_1M: v2.CBBOMsg,
Schema.TCBBO: v2.CBBOMsg,
Schema.BBO_1S: v2.BBOMsg,
Schema.BBO_1M: v2.BBOMsg,
}

SCHEMA_STRUCT_MAP_V1: Final[dict[Schema, type[DBNRecord]]] = {
Schema.DEFINITION: InstrumentDefMsgV1,
Schema.IMBALANCE: ImbalanceMsg,
Schema.MBO: MBOMsg,
Schema.MBP_1: MBP1Msg,
Schema.MBP_10: MBP10Msg,
Schema.OHLCV_1S: OHLCVMsg,
Schema.OHLCV_1M: OHLCVMsg,
Schema.OHLCV_1H: OHLCVMsg,
Schema.OHLCV_1D: OHLCVMsg,
Schema.STATISTICS: StatMsg,
Schema.STATUS: StatusMsg,
Schema.TBBO: MBP1Msg,
Schema.TRADES: TradeMsg,
Schema.CMBP_1: CMBP1Msg,
Schema.CBBO_1S: CBBOMsg,
Schema.CBBO_1M: CBBOMsg,
Schema.TCBBO: CBBOMsg,
Schema.BBO_1S: BBOMsg,
Schema.BBO_1M: BBOMsg,
Schema.DEFINITION: v1.InstrumentDefMsg,
Schema.IMBALANCE: v1.ImbalanceMsg,
Schema.MBO: v1.MBOMsg,
Schema.MBP_1: v1.MBP1Msg,
Schema.MBP_10: v1.MBP10Msg,
Schema.OHLCV_1S: v1.OHLCVMsg,
Schema.OHLCV_1M: v1.OHLCVMsg,
Schema.OHLCV_1H: v1.OHLCVMsg,
Schema.OHLCV_1D: v1.OHLCVMsg,
Schema.STATISTICS: v1.StatMsg,
Schema.STATUS: v1.StatusMsg,
Schema.TBBO: v1.MBP1Msg,
Schema.TRADES: v1.TradeMsg,
Schema.CMBP_1: v1.CMBP1Msg,
Schema.CBBO_1S: v1.CBBOMsg,
Schema.CBBO_1M: v1.CBBOMsg,
Schema.TCBBO: v1.CBBOMsg,
Schema.BBO_1S: v1.BBOMsg,
Schema.BBO_1M: v1.BBOMsg,
}


Expand Down
6 changes: 5 additions & 1 deletion databento/common/dbnstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from databento_dbn import Encoding
from databento_dbn import InstrumentDefMsg
from databento_dbn import InstrumentDefMsgV1
from databento_dbn import InstrumentDefMsgV2
from databento_dbn import Metadata
from databento_dbn import RType
from databento_dbn import Schema
Expand All @@ -47,6 +48,7 @@
from databento.common.constants import DEFINITION_TYPE_MAX_MAP
from databento.common.constants import SCHEMA_STRUCT_MAP
from databento.common.constants import SCHEMA_STRUCT_MAP_V1
from databento.common.constants import SCHEMA_STRUCT_MAP_V2
from databento.common.enums import PriceType
from databento.common.error import BentoError
from databento.common.error import BentoWarning
Expand Down Expand Up @@ -1314,6 +1316,8 @@ def _schema_struct_map(self) -> dict[Schema, type[DBNRecord]]:
"""
if self.metadata.version == 1:
return SCHEMA_STRUCT_MAP_V1
if self.metadata.version == 2:
return SCHEMA_STRUCT_MAP_V2
return SCHEMA_STRUCT_MAP


Expand Down Expand Up @@ -1456,7 +1460,7 @@ def __next__(self) -> pd.DataFrame:
columns=self._struct_type._ordered_fields,
)

if self._struct_type in (InstrumentDefMsg, InstrumentDefMsgV1):
if self._struct_type in (InstrumentDefMsg, InstrumentDefMsgV1, InstrumentDefMsgV2):
self._format_definition_fields(df)

self._format_hidden_fields(df)
Expand Down
2 changes: 1 addition & 1 deletion databento/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.55.0"
__version__ = "0.55.1"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "databento"
version = "0.55.0"
version = "0.55.1"
description = "Official Python client library for Databento"
authors = [
"Databento <support@databento.com>",
Expand Down
Loading