Skip to content

Commit b41eedd

Browse files
authored
VER: Release 0.64.0
See release notes.
2 parents c3557f6 + b4bf11a commit b41eedd

15 files changed

+106
-58
lines changed

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.64.0 - 2025-09-30
4+
5+
#### Enhancements
6+
- Upgraded `databento-dbn` to 0.42.0
7+
- Added `ts_index` and `pretty_ts_index` properties for records in Python which provides the timestamp that is most appropriate for indexing
8+
- Fixed type stub for `channel_id` to allow None
9+
10+
#### Bug fixes
11+
- Fixed type hint for `start` parameter in `Live.subscribe()`
12+
313
## 0.63.0 - 2025-09-02
414

515
#### Enhancements
@@ -18,7 +28,7 @@ This release delivers a number of breaking changes to the Python interface for D
1828
- Removed `hd` property from records in Python. Header fields are accessible
1929
directly from the record
2030
- Removed ability to directly instantiate most enums from an `int` in Python and coercion
21-
from `int` in `__eq__`. They can still be instantitated with the `from_int` class method.
31+
from `int` in `__eq__`. They can still be instantiated with the `from_int` class method.
2232
Write `Side.from_int(66)` instead of `Side(66)` and `Side.BID == Side.from_int(66)`
2333
instead of `Side.BID == 66`. Affected enums:
2434
- `Side`
@@ -215,7 +225,7 @@ was preventing `ts_out` from being correctly decoded in the Python DBNDecoder
215225
## 0.52.0 - 2025-04-15
216226

217227
#### Enhancements
218-
- Added new optional `id` field to `SubcriptionRequest` class which will be used for improved error messages
228+
- Added new optional `id` field to `SubscriptionRequest` class which will be used for improved error messages
219229
- Upgraded `databento-dbn` to 0.32.0
220230
- Fixed `RType` variant names in Python to match `Schema`
221231
- Added missing Python type declarations for `RType` variants
@@ -892,7 +902,7 @@ This release includes updates to the fields in text encodings (CSV and JSON), yo
892902
- Removed `record_size` property from `DBNStore`
893903
- Removed `bad` condition variant from `batch.get_dataset_condition`
894904
- Removed unused `LiveGateway` enum
895-
- Removed `STATSTICS` from `Schema` enum
905+
- Removed `STATISTICS` from `Schema` enum
896906
- Removed `STATUS` from `Schema` enum
897907
- Removed `GATEWAY_ERROR` from `Schema` enum
898908
- Removed `SYMBOL_MAPPING` from `Schema` enum

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The library is fully compatible with the latest distribution of Anaconda 3.9 and
3232
The minimum dependencies as found in the `pyproject.toml` are also listed below:
3333
- python = "^3.9"
3434
- aiohttp = "^3.8.3"
35-
- databento-dbn = "~0.36.1"
35+
- databento-dbn = "~0.42.0"
3636
- numpy = ">=1.23.5"
3737
- pandas = ">=1.5.3"
3838
- pip-system-certs = ">=4.0" (Windows only)

databento/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
"SystemCode",
146146
"SystemMsg",
147147
"TBBOMsg",
148-
"TBBOMsg",
149148
"TCBBOMsg",
150149
"TradeMsg",
151150
"TradingEvent",

databento/common/parsing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ def optional_datetime_to_string(
344344

345345

346346
def datetime_to_unix_nanoseconds(
347-
value: pd.Timestamp | date | str | int,
347+
value: pd.Timestamp | datetime | date | str | int,
348348
) -> int:
349349
"""
350350
Return a valid UNIX nanosecond timestamp from the given value.
351351
352352
Parameters
353353
----------
354-
value : pd.Timestamp, date, str, or int
354+
value : pd.Timestamp, datetime, date, str, or int
355355
The value to parse.
356356
357357
Returns
@@ -378,15 +378,15 @@ def datetime_to_unix_nanoseconds(
378378

379379

380380
def optional_datetime_to_unix_nanoseconds(
381-
value: pd.Timestamp | date | str | int | None,
381+
value: pd.Timestamp | datetime | date | str | int | None,
382382
) -> int | None:
383383
"""
384384
Return a valid UNIX nanosecond timestamp from the given value (if not
385385
None).
386386
387387
Parameters
388388
----------
389-
value : pd.Timestamp, date, str, or int
389+
value : pd.Timestamp, datetime, date, str, or int
390390
The value to parse.
391391
392392
Returns

databento/live/client.py

Lines changed: 57 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
import threading
99
from collections.abc import Iterable
1010
from concurrent import futures
11+
from datetime import date
12+
from datetime import datetime
1113
from os import PathLike
1214
from typing import IO
1315

1416
import databento_dbn
17+
import pandas as pd
1518
from databento_dbn import Schema
1619
from databento_dbn import SType
1720

@@ -368,20 +371,22 @@ def start(
368371
self,
369372
) -> None:
370373
"""
371-
Start the live client session.
374+
Start the session.
372375
373-
It is not necessary to call `Live.start` before iterating a `Live` client and doing so will result in an error.
376+
It is not necessary to call this method before iterating a `Live` client and doing so
377+
will result in an error.
374378
375379
Raises
376380
------
377381
ValueError
378-
If `Live.start` is called before a subscription has been made.
379-
If `Live.start` is called after streaming has already started.
380-
If `Live.start` is called after the live session has closed.
382+
If called before a subscription has been made.
383+
If called after the session has already started.
384+
If called after the session has closed.
381385
382386
See Also
383387
--------
384388
Live.stop
389+
Live.terminate
385390
386391
"""
387392
logger.info("starting live client")
@@ -396,17 +401,25 @@ def start(
396401

397402
def stop(self) -> None:
398403
"""
399-
Stop the live client session as soon as possible. Once stopped, a
400-
client cannot be restarted.
404+
Stop the session and finish processing received records.
405+
406+
A client can only be stopped after a successful connection is made with `Live.start`.
407+
408+
This method does not block waiting for the connection to close.
409+
410+
The connection will eventually close after calling this method. Once the connection
411+
is closed, the client can be reused, but the session state is not preserved.
401412
402413
Raises
403414
------
404415
ValueError
405-
If `Live.stop` is called before a connection has been made.
416+
If called before a connection has started.
406417
407418
See Also
408419
--------
409-
Live.start
420+
Live.terminate
421+
Live.block_for_close
422+
Live.wait_for_close
410423
411424
"""
412425
logger.info("stopping live client")
@@ -424,17 +437,18 @@ def subscribe(
424437
schema: Schema | str,
425438
symbols: Iterable[str | int] | str | int = ALL_SYMBOLS,
426439
stype_in: SType | str = SType.RAW_SYMBOL,
427-
start: str | int | None = None,
440+
start: pd.Timestamp | datetime | date | str | int | None = None,
428441
snapshot: bool = False,
429442
) -> None:
430443
"""
431-
Subscribe to a data stream. Multiple subscription requests can be made
432-
for a streaming session. Once one subscription has been made, future
433-
subscriptions must all belong to the same dataset.
444+
Add a new subscription to the session.
445+
446+
All subscriptions must be for the same `dataset`.
447+
448+
Multiple subscriptions for different schemas can be made.
434449
435-
When creating the first subscription this method will also create
436-
the TCP connection to the remote gateway. All subscriptions must
437-
have the same dataset.
450+
When creating the first subscription, this method will also create
451+
the TCP connection to the remote gateway.
438452
439453
Parameters
440454
----------
@@ -446,12 +460,14 @@ def subscribe(
446460
The symbols to subscribe to.
447461
stype_in : SType or str, default 'raw_symbol'
448462
The input symbology type to resolve from.
449-
start : str or int, optional
450-
UNIX nanosecond epoch timestamp to start streaming from (inclusive), based on `ts_event`. Must be within 24 hours except when requesting the mbo or definition schemas.
463+
start : pd.Timestamp, datetime, date, str or int, optional
464+
The inclusive start of subscription replay.
465+
Pass `0` to request all available data.
466+
Cannot be specified after the session is started.
467+
See `Intraday Replay` https://databento.com/docs/api-reference-live/basics/intraday-replay.
451468
snapshot: bool, default to 'False'
452469
Request subscription with snapshot. The `start` parameter must be `None`.
453-
454-
470+
Only supported with `mbo` schema.
455471
456472
Raises
457473
------
@@ -497,17 +513,23 @@ def subscribe(
497513

498514
def terminate(self) -> None:
499515
"""
500-
Terminate the live client session and stop processing records as soon
501-
as possible.
516+
Terminate the session and stop processing records immediately.
517+
518+
A client can only be terminated after a connection is started with `Live.start`.
519+
520+
Once terminated, the client can be reused, but the session state
521+
is not preserved.
502522
503523
Raises
504524
------
505525
ValueError
506-
If the client is not connected.
526+
If called before a connection has started.
507527
508528
See Also
509529
--------
510530
Live.stop
531+
Live.block_for_close
532+
Live.wait_for_close
511533
512534
"""
513535
logger.info("terminating live client")
@@ -521,11 +543,14 @@ def block_for_close(
521543
) -> None:
522544
"""
523545
Block until the session closes or a timeout is reached. A session will
524-
close after `Live.stop` is called or the remote gateway disconnects.
546+
close after the remote gateway disconnects, or after `Live.stop` or
547+
`Live.terminate` are called.
525548
526-
If a `timeout` is specified, `Live.stop` will be called when the
549+
If a `timeout` is specified, `Live.terminate` will be called when the
527550
timeout is reached.
528551
552+
When this method unblocks, the session is guaranteed to be closed.
553+
529554
Parameters
530555
----------
531556
timeout : float, optional
@@ -541,7 +566,7 @@ def block_for_close(
541566
542567
See Also
543568
--------
544-
wait_for_close
569+
Live.wait_for_close
545570
546571
"""
547572
try:
@@ -565,12 +590,14 @@ async def wait_for_close(
565590
) -> None:
566591
"""
567592
Coroutine to wait until the session closes or a timeout is reached. A
568-
session will close after `Live.stop` is called or the remote gateway
569-
disconnects.
593+
session will close when the remote gateway disconnects, or after
594+
`Live.stop` or `Live.terminate` are called.
570595
571-
If a `timeout` is specified, `Live.stop` will be called when the
596+
If a `timeout` is specified, `Live.terminate` will be called when the
572597
timeout is reached.
573598
599+
When this method unblocks, the session is guaranteed to be closed.
600+
574601
Parameters
575602
----------
576603
timeout : float, optional
@@ -586,7 +613,7 @@ async def wait_for_close(
586613
587614
See Also
588615
--------
589-
block_for_close
616+
Live.block_for_close
590617
591618
"""
592619
waiter = asyncio.wrap_future(

databento/reference/api/adjustment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def get_range(
5050
Parameters
5151
----------
5252
start : pd.Timestamp, datetime, date, str, or int
53-
The start datetime of the request time range (inclusive) based on `ex_date`.
53+
The inclusive start of the request time range based on `ex_date`.
5454
Assumes UTC as timezone unless passed a tz-aware object.
5555
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
5656
end : pd.Timestamp, datetime, date, str, or int, optional
57-
The end datetime of the request time range (exclusive) based on `ex_date`.
57+
The exclusive end of the request time range based on `ex_date`.
5858
Assumes UTC as timezone unless passed a tz-aware object.
5959
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
60-
Defaults to the forward filled value of `start` based on the resolution provided.
60+
If `None`, then will return **all** data available after `start`.
6161
symbols : Iterable[str] or str, optional
6262
The symbols to filter for. Takes up to 2,000 symbols per request.
6363
If more than 1 symbol is specified, the data is merged and sorted by time.

databento/reference/api/corporate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def get_range(
5555
Parameters
5656
----------
5757
start : pd.Timestamp, datetime, date, str, or int
58-
The start datetime of the request time range (inclusive) based on `index`.
58+
The inclusive start of the request range based on `index`.
5959
Assumes UTC as timezone unless passed a tz-aware object.
6060
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
6161
end : pd.Timestamp, datetime, date, str, or int, optional
62-
The end datetime of the request time range (exclusive) based on `index`.
62+
The exclusive end of the request range based on `index`.
6363
Assumes UTC as timezone unless passed a tz-aware object.
6464
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
65-
Defaults to the forward filled value of `start` based on the resolution provided.
65+
If `None`, then will return **all** data available after `start`.
6666
index : str, default 'event_date'
6767
The index column used for filtering the `start` and `end` time range
6868
and for record ordering.

databento/reference/api/security.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def get_range(
5151
Parameters
5252
----------
5353
start : pd.Timestamp, datetime, date, str, or int
54-
The start datetime of the request time range (inclusive) based on `index`.
54+
The inclusive start datetime of the request range based on `index`.
5555
Assumes UTC as timezone unless passed a tz-aware object.
5656
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
5757
end : pd.Timestamp, datetime, date, str, or int, optional
58-
The end datetime of the request time range (exclusive) based on `index`.
58+
The exclusive end of the request range based on `index`.
5959
Assumes UTC as timezone unless passed a tz-aware object.
6060
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
61-
Defaults to the forward filled value of `start` based on the resolution provided.
61+
If `None`, then will return **all** data available after `start`.
6262
index : str, default 'ts_effective'
6363
The index column used for filtering the `start` and `end` time range
6464
and for record ordering.

databento/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.63.0"
1+
__version__ = "0.64.0"

examples/historical_timeseries_from_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55

66
if __name__ == "__main__":
7-
ts_start = datetime.datetime.utcnow()
7+
ts_start = datetime.datetime.now(tz=datetime.timezone.utc)
88

99
# Can load from file path (if exists)
1010
data = DBNStore.from_file(path="my_data.dbn")
1111

1212
print(data.to_df())
13-
print(datetime.datetime.utcnow() - ts_start)
13+
print(datetime.datetime.now(tz=datetime.timezone.utc) - ts_start)

0 commit comments

Comments
 (0)