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
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
Expand All @@ -32,7 +32,7 @@ jobs:
sed -n '/^## /{n; :a; /^## /q; p; n; ba}' CHANGELOG.md >> NOTES.md

- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
append_body: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: build - Python ${{ matrix.python-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# Changelog

## 0.65.0 - 2025-11-11

#### Deprecations
- Deprecated `mode` parameter in `metadata.get_cost`, which will be removed in a future release

#### Enhancements
- Added export of `CBBOMsg` and `BBOMsg` from `databento_dbn` to the root `databento` package
- Upgraded `databento-dbn` to 0.43.0
- Added export of `F_PUBLISHER_SPECIFIC` constant to Python
- Added explicit `Unset` variant for `SystemCode` and `ErrorCode`
- Changed Python getters for enum fields to return the underlying type when no known variant can be found. As a result, these getters no longer raise an exception

#### Breaking changes
- Removed support for Python 3.9 due to end of life

## 0.64.0 - 2025-09-30

#### Enhancements
- Upgraded `databento-dbn` to 0.42.0
- Added `ts_index` and `pretty_ts_index` properties for records in Python which provides the timestamp that is most appropriate for indexing
- Fixed type stub for `channel_id` to allow None

#### Enhancements
- Reduced the log level of `SystemMsg` records in the `Live` client to debug
- Increased the log level of `SystemMsg` records with the code `SystemCode.SLOW_READER_WARNING` to warning

#### Bug fixes
- Fixed type hint for `start` parameter in `Live.subscribe()`

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ You can find our full client API reference on the [Historical Reference](https:/
[Examples](https://databento.com/docs/examples?historical=python&live=python) section for various tutorials and code samples.

## Requirements
The library is fully compatible with the latest distribution of Anaconda 3.9 and above.
The library is fully compatible with distributions of Anaconda 2023.x and above.
The minimum dependencies as found in the `pyproject.toml` are also listed below:
- python = "^3.9"
- python = "^3.10"
- aiohttp = "^3.8.3"
- databento-dbn = "~0.42.0"
- databento-dbn = "~0.43.0"
- numpy = ">=1.23.5"
- pandas = ">=1.5.3"
- pip-system-certs = ">=4.0" (Windows only)
Expand Down
4 changes: 4 additions & 0 deletions databento/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from databento_dbn import UNDEF_STAT_QUANTITY
from databento_dbn import UNDEF_TIMESTAMP
from databento_dbn import Action
from databento_dbn import BBOMsg
from databento_dbn import BidAskPair
from databento_dbn import CBBOMsg
from databento_dbn import CMBP1Msg
from databento_dbn import Compression
from databento_dbn import ConsolidatedBidAskPair
Expand Down Expand Up @@ -90,13 +92,15 @@
"Action",
"BBO1MMsg",
"BBO1SMsg",
"BBOMsg",
"BentoClientError",
"BentoError",
"BentoHttpError",
"BentoServerError",
"BidAskPair",
"CBBO1MMsg",
"CBBO1SMsg",
"CBBOMsg",
"CMBP1Msg",
"Compression",
"ConsolidatedBidAskPair",
Expand Down
2 changes: 1 addition & 1 deletion databento/common/dbnstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import warnings
import zoneinfo
from collections.abc import Callable
from collections.abc import Generator
from collections.abc import Iterator
from collections.abc import Mapping
Expand All @@ -18,7 +19,6 @@
from typing import TYPE_CHECKING
from typing import Any
from typing import BinaryIO
from typing import Callable
from typing import Final
from typing import Literal
from typing import Protocol
Expand Down
2 changes: 1 addition & 1 deletion databento/common/enums.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

from collections.abc import Callable
from enum import Enum
from enum import Flag
from enum import IntFlag
from enum import unique
from typing import Callable
from typing import TypeVar


Expand Down
31 changes: 4 additions & 27 deletions databento/common/parsing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import warnings
from collections.abc import Iterable
from datetime import date
from datetime import datetime
Expand Down Expand Up @@ -277,13 +276,13 @@ def datetime_to_string(value: pd.Timestamp | datetime | date | str | int) -> str
return pd.to_datetime(value).isoformat()


def date_to_string(value: pd.Timestamp | date | str | int) -> str:
def date_to_string(value: date | str) -> str:
"""
Return a valid date string from the given value.

Parameters
----------
value : pd.Timestamp, date, str, or int
value : date or str
The value to parse.

Returns
Expand All @@ -293,32 +292,10 @@ def date_to_string(value: pd.Timestamp | date | str | int) -> str:
"""
if isinstance(value, str):
return value
elif isinstance(value, date):
elif type(value) is date:
return value.isoformat()
elif isinstance(value, int):
warnings.warn(
"Passing an int to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
"Use a date or str instead.",
DeprecationWarning,
stacklevel=2,
)
return str(value)
elif isinstance(value, pd.Timestamp):
warnings.warn(
"Passing a pandas Timestamp to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
"Use a date or str instead.",
DeprecationWarning,
stacklevel=2,
)
return pd.to_datetime(value).date().isoformat()
else:
warnings.warn(
f"Passing a {type(value)} to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
"Use a date or str instead.",
DeprecationWarning,
stacklevel=2,
)
return pd.to_datetime(value).date().isoformat()
raise TypeError(f"`{type(value)} is not supported. Only `date` and `str` are supported.")


def optional_datetime_to_string(
Expand Down
49 changes: 24 additions & 25 deletions databento/common/types.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
import datetime as dt
from typing import Callable
from collections.abc import Callable
from typing import Generic
from typing import TypedDict
from typing import TypeVar
from typing import Union

import databento_dbn
import pandas as pd


DBNRecord = Union[
databento_dbn.BBOMsg,
databento_dbn.CBBOMsg,
databento_dbn.CMBP1Msg,
databento_dbn.MBOMsg,
databento_dbn.MBP1Msg,
databento_dbn.MBP10Msg,
databento_dbn.TradeMsg,
databento_dbn.OHLCVMsg,
databento_dbn.ImbalanceMsg,
databento_dbn.InstrumentDefMsg,
databento_dbn.InstrumentDefMsgV1,
databento_dbn.InstrumentDefMsgV2,
databento_dbn.StatMsg,
databento_dbn.StatMsgV1,
databento_dbn.StatusMsg,
databento_dbn.SymbolMappingMsg,
databento_dbn.SymbolMappingMsgV1,
databento_dbn.SystemMsg,
databento_dbn.SystemMsgV1,
databento_dbn.ErrorMsg,
databento_dbn.ErrorMsgV1,
]
DBNRecord = (
databento_dbn.BBOMsg
| databento_dbn.CBBOMsg
| databento_dbn.CMBP1Msg
| databento_dbn.MBOMsg
| databento_dbn.MBP1Msg
| databento_dbn.MBP10Msg
| databento_dbn.TradeMsg
| databento_dbn.OHLCVMsg
| databento_dbn.ImbalanceMsg
| databento_dbn.InstrumentDefMsg
| databento_dbn.InstrumentDefMsgV1
| databento_dbn.InstrumentDefMsgV2
| databento_dbn.StatMsg
| databento_dbn.StatMsgV1
| databento_dbn.StatusMsg
| databento_dbn.SymbolMappingMsg
| databento_dbn.SymbolMappingMsgV1
| databento_dbn.SystemMsg
| databento_dbn.SystemMsgV1
| databento_dbn.ErrorMsg
| databento_dbn.ErrorMsgV1
)

RecordCallback = Callable[[DBNRecord], None]
ExceptionCallback = Callable[[Exception], None]
Expand Down
16 changes: 12 additions & 4 deletions databento/historical/api/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from collections.abc import Iterable
from datetime import date
from datetime import datetime
Expand All @@ -19,6 +20,7 @@
from databento.common.parsing import optional_datetime_to_string
from databento.common.parsing import optional_symbols_list_to_list
from databento.common.publishers import Dataset
from databento.common.types import Default
from databento.common.validation import validate_enum
from databento.common.validation import validate_semantic_string

Expand Down Expand Up @@ -399,7 +401,7 @@ def get_cost(
dataset: Dataset | str,
start: pd.Timestamp | datetime | date | str | int,
end: pd.Timestamp | datetime | date | str | int | None = None,
mode: FeedMode | str = "historical-streaming",
mode: FeedMode | str | Default[None] = Default[None](None),
symbols: Iterable[str | int] | str | int | None = None,
schema: Schema | str = "trades",
stype_in: SType | str = "raw_symbol",
Expand All @@ -425,8 +427,8 @@ def get_cost(
Assumes UTC as timezone unless otherwise specified.
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
Defaults to the forward filled value of `start` based on the resolution provided.
mode : FeedMode or str {'live', 'historical-streaming', 'historical'}, default 'historical-streaming'
The data feed mode for the request.
mode : FeedMode or str {'live', 'historical-streaming', 'historical'}, default `None`
The data feed mode for the request. This parameter has been deprecated.
symbols : Iterable[str | int] or str or int, optional
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
If 'ALL_SYMBOLS' or `None` then will select **all** symbols.
Expand All @@ -443,6 +445,13 @@ def get_cost(
The cost in US dollars.

"""
if not isinstance(mode, Default):
warnings.warn(
"The `mode` parameter is deprecated and will be removed in a future release.",
DeprecationWarning,
stacklevel=2,
)

stype_in_valid = validate_enum(stype_in, SType, "stype_in")
symbols_list = optional_symbols_list_to_list(symbols, stype_in_valid)
data: dict[str, str | None] = {
Expand All @@ -453,7 +462,6 @@ def get_cost(
"schema": str(validate_enum(schema, Schema, "schema")),
"stype_in": str(stype_in_valid),
"stype_out": str(SType.INSTRUMENT_ID),
"mode": validate_enum(mode, FeedMode, "mode"),
}

if limit is not None:
Expand Down
2 changes: 1 addition & 1 deletion databento/live/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def start(
logger.info("starting live client")
if not self.is_connected():
if self.dataset == "":
raise ValueError("cannot start a live client without a subscription")
raise ValueError("must call subscribe() before starting live client")
raise ValueError("cannot start a live client after it is closed")
if self._session.is_streaming():
raise ValueError("client is already started")
Expand Down
19 changes: 15 additions & 4 deletions databento/live/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from typing import Final

import databento_dbn
from databento_dbn import DBNError
from databento_dbn import Metadata
from databento_dbn import Schema
from databento_dbn import SType
from databento_dbn import SystemCode
from databento_dbn import VersionUpgradePolicy

from databento.common import cram
Expand Down Expand Up @@ -380,10 +382,19 @@ def _process_dbn(self, data: bytes) -> None:
if record.is_heartbeat():
logger.debug("gateway heartbeat")
else:
logger.info(
"gateway message: %s",
record.msg,
)
try:
msg_code = record.code
except DBNError:
msg_code = None
if msg_code == SystemCode.SLOW_READER_WARNING:
logger.warning(
record.msg,
)
else:
logger.debug(
"gateway message: %s",
record.msg,
)
self.received_record(record)

def _process_gateway(self, data: bytes) -> None:
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.64.0"
__version__ = "0.65.0"
Loading