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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
shell: bash

- name: Test (release)
timeout-minutes: 2
timeout-minutes: 3
if: ${{ github.ref == 'refs/heads/main' }}
run: scripts/test.sh --release
shell: bash

- name: Test
timeout-minutes: 2
timeout-minutes: 3
if: ${{ github.ref != 'refs/heads/main' }}
run: scripts/test.sh
shell: bash
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.50.0 - 2025-03-18

#### Enhancements
- Added new venues, datasets, and publishers for ICE Futures US, ICE Futures Europe (Financial products), Eurex, and European Energy Exchange (EEX)
- Added export of the following enums from `databento_dbn` to the root `databento` package:
- `Action`
- `InstrumentClass`
- `MatchAlgorithm`
- `RType`
- `SecurityUpdateAction`
- `Side`
- `StatUpdateAction`
- `TriState`
- `UserDefinedInstrument`
- `VersionUpgradePolicy`
- Added export of the following constants from `databento_dbn` to the root `databento` package:
- `DBN_VERSION`
- `FIXED_PRICE_SCALE`
- `UNDEF_ORDER_SIZE`
- `UNDEF_PRICE`
- `UNDEF_STAT_QUANTITY`
- `UNDEF_TIMESTAMP`
- Added export of `BidAskPair` and `ConsolidatedBidAskPair` from `databento_dbn` to the root `databento` package
- Upgraded `databento-dbn` to 0.29.0
- Added `COMMODITY_SPOT` `InstrumentClass` variant
- Improved handling of `datetime` and `date` objects in `start` and `end` parameters

## 0.49.0 - 2025-03-04

#### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The library is fully compatible with the latest distribution of Anaconda 3.9 and
The minimum dependencies as found in the `pyproject.toml` are also listed below:
- python = "^3.9"
- aiohttp = "^3.8.3"
- databento-dbn = "0.27.0"
- databento-dbn = "0.29.0"
- numpy= ">=1.23.5"
- pandas = ">=1.5.3"
- pip-system-certs = ">=4.0" (Windows only)
Expand Down
36 changes: 36 additions & 0 deletions databento/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import logging
import warnings

from databento_dbn import DBN_VERSION
from databento_dbn import FIXED_PRICE_SCALE
from databento_dbn import UNDEF_ORDER_SIZE
from databento_dbn import UNDEF_PRICE
from databento_dbn import UNDEF_STAT_QUANTITY
from databento_dbn import UNDEF_TIMESTAMP
from databento_dbn import Action
from databento_dbn import BidAskPair
from databento_dbn import CMBP1Msg
from databento_dbn import Compression
from databento_dbn import ConsolidatedBidAskPair
from databento_dbn import Encoding
from databento_dbn import ErrorMsg
from databento_dbn import ImbalanceMsg
from databento_dbn import InstrumentClass
from databento_dbn import InstrumentDefMsg
from databento_dbn import MatchAlgorithm
from databento_dbn import MBOMsg
from databento_dbn import MBP1Msg
from databento_dbn import MBP10Msg
from databento_dbn import Metadata
from databento_dbn import OHLCVMsg
from databento_dbn import RType
from databento_dbn import Schema
from databento_dbn import SecurityUpdateAction
from databento_dbn import Side
from databento_dbn import StatMsg
from databento_dbn import StatType
from databento_dbn import StatUpdateAction
from databento_dbn import StatusAction
from databento_dbn import StatusMsg
from databento_dbn import StatusReason
Expand All @@ -23,6 +38,9 @@
from databento_dbn import SystemMsg
from databento_dbn import TradeMsg
from databento_dbn import TradingEvent
from databento_dbn import TriState
from databento_dbn import UserDefinedInstrument
from databento_dbn import VersionUpgradePolicy
from databento_dbn.v2 import BBO1MMsg
from databento_dbn.v2 import BBO1SMsg
from databento_dbn.v2 import CBBO1MMsg
Expand Down Expand Up @@ -60,16 +78,25 @@

__all__ = [
"API_VERSION",
"DBN_VERSION",
"FIXED_PRICE_SCALE",
"UNDEF_ORDER_SIZE",
"UNDEF_PRICE",
"UNDEF_STAT_QUANTITY",
"UNDEF_TIMESTAMP",
"Action",
"BBO1MMsg",
"BBO1SMsg",
"BentoClientError",
"BentoError",
"BentoHttpError",
"BentoServerError",
"BidAskPair",
"CBBO1MMsg",
"CBBO1SMsg",
"CMBP1Msg",
"Compression",
"ConsolidatedBidAskPair",
"DBNRecord",
"DBNStore",
"Dataset",
Expand All @@ -80,25 +107,31 @@
"Historical",
"HistoricalGateway",
"ImbalanceMsg",
"InstrumentClass",
"InstrumentDefMsg",
"InstrumentMap",
"Live",
"MBOMsg",
"MBP1Msg",
"MBP10Msg",
"MatchAlgorithm",
"Metadata",
"OHLCVMsg",
"Packaging",
"Publisher",
"RType",
"ReconnectPolicy",
"RecordFlags",
"Reference",
"RollRule",
"SType",
"Schema",
"SecurityUpdateAction",
"Side",
"SplitDuration",
"StatMsg",
"StatType",
"StatUpdateAction",
"StatusAction",
"StatusMsg",
"StatusReason",
Expand All @@ -110,7 +143,10 @@
"TCBBOMsg",
"TradeMsg",
"TradingEvent",
"TriState",
"UserDefinedInstrument",
"Venue",
"VersionUpgradePolicy",
]

# Setup logging
Expand Down
45 changes: 25 additions & 20 deletions databento/common/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from collections.abc import Iterable
from datetime import date
from datetime import datetime
from functools import partial
from functools import singledispatch
from io import BytesIO
Expand Down Expand Up @@ -222,13 +223,13 @@ def optional_date_to_string(value: date | str | None) -> str | None:
return datetime_to_date_string(value)


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

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

Returns
Expand All @@ -240,6 +241,10 @@ def datetime_to_string(value: pd.Timestamp | date | str | int) -> str:
return value
elif isinstance(value, int):
return str(value)
elif isinstance(value, date):
return value.isoformat()
elif isinstance(value, datetime):
return value.isoformat()
else:
return pd.to_datetime(value).isoformat()

Expand All @@ -250,7 +255,7 @@ def datetime_to_date_string(value: pd.Timestamp | date | str | int) -> str:

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

Returns
Expand All @@ -262,19 +267,21 @@ def datetime_to_date_string(value: pd.Timestamp | date | str | int) -> str:
return value
elif isinstance(value, int):
return str(value)
elif isinstance(value, date):
return value.isoformat()
else:
return pd.to_datetime(value).date().isoformat()


def optional_datetime_to_string(
value: pd.Timestamp | date | str | int | None,
value: pd.Timestamp | datetime | date | str | int | None,
) -> str | None:
"""
Return a valid datetime string from the given value (if not None).

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

Returns
Expand All @@ -296,7 +303,7 @@ def datetime_to_unix_nanoseconds(

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

Returns
Expand All @@ -306,22 +313,20 @@ def datetime_to_unix_nanoseconds(
"""
if isinstance(value, int):
return value # no checking on integer values

if isinstance(value, date):
elif isinstance(value, date):
return pd.to_datetime(value, utc=True).value

if isinstance(value, pd.Timestamp):
elif isinstance(value, pd.Timestamp):
return value.value
else:
try:
nanoseconds = pd.to_datetime(value, utc=True).value
except Exception: # different versions of pandas raise different exceptions
nanoseconds = pd.to_datetime(
int(value),
utc=True,
).value

try:
nanoseconds = pd.to_datetime(value, utc=True).value
except Exception: # different versions of pandas raise different exceptions
nanoseconds = pd.to_datetime(
int(value),
utc=True,
).value

return nanoseconds
return nanoseconds


def optional_datetime_to_unix_nanoseconds(
Expand All @@ -333,7 +338,7 @@ def optional_datetime_to_unix_nanoseconds(

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

Returns
Expand Down
Loading
Loading