diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fa41e2..2d1e7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.61.0 - 2025-08-12 + +#### Breaking changes +- Modified the `states` parameter in `batch.list_jobs()` + +#### Enhancements +- Added `JobState` enum +- Added export of `SystemCode` and `ErrorCode` from `databento_dbn` to the root `databento` package +- Added `F_PUBLISHER_SPECIFIC` flag to `RecordFlags` enum + +#### Bug fixes +- Bumped the minimum version requirement for `requests` to 0.27.0 + ## 0.60.0 - 2025-08-05 #### Enhancements @@ -50,8 +63,8 @@ Python - "ICE Futures Europe (Financials)" renamed to "ICE Europe Financials" - "ICE Futures Europe (Commodities)" renamed to "ICE Europe Commodities" - Upgraded `databento-dbn` to 0.36.1 - - Fixed setting of ts_out property of DbnFsm based on decoded metadata. This -was preventing ts_out from being correctly decoded in the Python DBNDecoder + - Fixed setting of `ts_out` property of DbnFsm based on decoded metadata. This +was preventing `ts_out` from being correctly decoded in the Python DBNDecoder - Fixed decoding of `ts_out` with first records in DBNDecoder #### Bug fixes diff --git a/databento/__init__.py b/databento/__init__.py index dbb287f..0b267c3 100644 --- a/databento/__init__.py +++ b/databento/__init__.py @@ -13,6 +13,7 @@ from databento_dbn import Compression from databento_dbn import ConsolidatedBidAskPair from databento_dbn import Encoding +from databento_dbn import ErrorCode from databento_dbn import ErrorMsg from databento_dbn import ImbalanceMsg from databento_dbn import InstrumentClass @@ -35,6 +36,7 @@ from databento_dbn import StatusReason from databento_dbn import SType from databento_dbn import SymbolMappingMsg +from databento_dbn import SystemCode from databento_dbn import SystemMsg from databento_dbn import TradeMsg from databento_dbn import TradingEvent @@ -55,6 +57,7 @@ from databento.common.enums import Delivery from databento.common.enums import FeedMode from databento.common.enums import HistoricalGateway +from databento.common.enums import JobState from databento.common.enums import Packaging from databento.common.enums import ReconnectPolicy from databento.common.enums import RecordFlags @@ -102,6 +105,7 @@ "Dataset", "Delivery", "Encoding", + "ErrorCode", "ErrorMsg", "FeedMode", "Historical", @@ -110,6 +114,7 @@ "InstrumentClass", "InstrumentDefMsg", "InstrumentMap", + "JobState", "Live", "MBOMsg", "MBP1Msg", @@ -137,6 +142,7 @@ "StatusReason", "SymbolMappingMsg", "SymbologyResolution", + "SystemCode", "SystemMsg", "TBBOMsg", "TBBOMsg", diff --git a/databento/common/enums.py b/databento/common/enums.py index 7fd5bd7..a8be618 100644 --- a/databento/common/enums.py +++ b/databento/common/enums.py @@ -28,7 +28,7 @@ def coercible(enum_type: type[M]) -> type[M]: Parameters ---------- enum_type : EnumMeta - The deocrated Enum type. + The decorated Enum type. Returns ------- @@ -167,7 +167,7 @@ class RollRule(StringyMixin, str, Enum): """ VOLUME = "volume" - OPEN_INTEREST = "open_interst" + OPEN_INTEREST = "open_interest" CALENDAR = "calendar" @@ -207,6 +207,8 @@ class RecordFlags(StringyMixin, IntFlag): # type: ignore The `ts_recv` value is inaccurate (clock issues or reordering). F_MAYBE_BAD_BOOK Indicates an unrecoverable gap was detected in the channel. + F_PUBLISHER_SPECIFIC + Indicates a publisher-specific event. Other bits are reserved and have no current meaning. @@ -218,6 +220,7 @@ class RecordFlags(StringyMixin, IntFlag): # type: ignore F_MBP = 16 F_BAD_TS_RECV = 8 F_MAYBE_BAD_BOOK = 4 + F_PUBLISHER_SPECIFIC = 2 @unique @@ -241,3 +244,16 @@ class PriceType(StringyMixin, str, Enum): FIXED = "fixed" FLOAT = "float" DECIMAL = "decimal" + + +@unique +@coercible +class JobState(StringyMixin, str, Enum): + """ + Represents the different states for batch jobs. + """ + + QUEUED = "queued" + PROCESSING = "processing" + DONE = "done" + EXPIRED = "expired" diff --git a/databento/common/parsing.py b/databento/common/parsing.py index 7a9d918..0c3caf8 100644 --- a/databento/common/parsing.py +++ b/databento/common/parsing.py @@ -17,6 +17,8 @@ from databento_dbn import SType from databento.common.constants import ALL_SYMBOLS +from databento.common.enums import JobState +from databento.common.validation import validate_enum from databento.common.validation import validate_smart_symbol @@ -64,6 +66,31 @@ def optional_values_list_to_string( return values_list_to_string(values) +def optional_states_list_to_string( + states: Iterable[JobState | str] | JobState | str | None, +) -> str | None: + """ + Concatenate a states string or iterable of string states (if not None). + + Parameters + ---------- + states : Iterable[JobState | str] | JobState | str | None + The states to concatenate. + + Returns + ------- + str or `None` + + """ + if states is None: + return None + elif isinstance(states, (JobState, str)): + return str(states) + else: + states_list = [validate_enum(state, JobState, "state").value for state in states] + return ",".join(states_list) + + def optional_string_to_list( value: Iterable[str] | str | None, ) -> Iterable[str] | list[str] | None: diff --git a/databento/historical/api/batch.py b/databento/historical/api/batch.py index 70f9dc9..a74ed8d 100644 --- a/databento/historical/api/batch.py +++ b/databento/historical/api/batch.py @@ -29,6 +29,7 @@ from databento.common import API_VERSION from databento.common.constants import HTTP_STREAMING_READ_SIZE from databento.common.enums import Delivery +from databento.common.enums import JobState from databento.common.enums import SplitDuration from databento.common.error import BentoError from databento.common.error import BentoHttpError @@ -37,7 +38,7 @@ from databento.common.http import check_http_error from databento.common.parsing import datetime_to_string from databento.common.parsing import optional_datetime_to_string -from databento.common.parsing import optional_values_list_to_string +from databento.common.parsing import optional_states_list_to_string from databento.common.parsing import symbols_list_to_list from databento.common.publishers import Dataset from databento.common.validation import validate_enum @@ -185,7 +186,7 @@ def submit_job( def list_jobs( self, - states: Iterable[str] | str = "received,queued,processing,done", + states: Iterable[JobState | str] | JobState | str | None = "queued,processing,done", since: pd.Timestamp | datetime | date | str | int | None = None, ) -> list[dict[str, Any]]: """ @@ -197,8 +198,9 @@ def list_jobs( Parameters ---------- - states : Iterable[str] or str, optional {'received', 'queued', 'processing', 'done', 'expired'} # noqa + states : Iterable[JobState | str] or JobState or str, optional {'queued', 'processing', 'done', 'expired'} # noqa The filter for jobs states as an iterable of comma separated values. + Defaults to all except 'expired'. since : pd.Timestamp, datetime, date, str, or int, optional The filter for timestamp submitted (will not include jobs prior to this). @@ -209,7 +211,7 @@ def list_jobs( """ params: list[tuple[str, str | None]] = [ - ("states", optional_values_list_to_string(states)), + ("states", optional_states_list_to_string(states)), ("since", optional_datetime_to_string(since)), ] diff --git a/databento/version.py b/databento/version.py index 5684ec7..a076e5d 100644 --- a/databento/version.py +++ b/databento/version.py @@ -1 +1 @@ -__version__ = "0.60.0" +__version__ = "0.61.0" diff --git a/pyproject.toml b/pyproject.toml index 91c03f2..1443d76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "databento" -version = "0.60.0" +version = "0.61.0" description = "Official Python client library for Databento" authors = [ "Databento ", @@ -40,7 +40,7 @@ numpy = [ pandas = ">=1.5.3" pip-system-certs = {version=">=4.0", markers="platform_system == 'Windows'"} pyarrow = ">=13.0.0" -requests = ">=2.25.1" +requests = ">=2.27.0" zstandard = ">=0.21.0" [tool.poetry.group.dev.dependencies] diff --git a/tests/test_historical_batch.py b/tests/test_historical_batch.py index 6ed1faf..f0d89ab 100644 --- a/tests/test_historical_batch.py +++ b/tests/test_historical_batch.py @@ -125,7 +125,7 @@ def test_batch_list_jobs_sends_expected_request( assert call["headers"]["accept"] == "application/json" assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/")) assert call["params"] == [ - ("states", "received,queued,processing,done"), + ("states", "queued,processing,done"), ("since", "2022-01-01"), ] assert call["timeout"] == (100, 100)