Skip to content

Commit

Permalink
VER: Release 0.39.3
Browse files Browse the repository at this point in the history
See release notes.
  • Loading branch information
nmacholl authored Aug 20, 2024
2 parents ee5d7bc + 60d58e5 commit 39a9e36
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.39.3 - 2024-08-20

#### Enhancements
- Added new publisher values for `XCIS.BBOTRADES` and `XNYS.BBOTRADES`

#### Bug fixes
- Fixed an issue receiving multiple DBN v1 `ErrorMsg` in the `Live` client would cause an `InvalidState` error
- Fixed an issue where creating `Live` clients in multiple threads could cause a `RuntimeError` upon initialization

## 0.39.2 - 2024-08-13

#### Enhancements
Expand Down
48 changes: 46 additions & 2 deletions databento/common/publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,13 @@ class Dataset(StringyMixin, str, Enum):
DBEQ_MAX
Databento Equities Max.
XNAS_BASIC
Nasdaq Basic (NLS+QBBO).
Nasdaq Basic (NLS and QBBO).
DBEQ_SUMMARY
Databento Equities Summary.
XCIS_BBOTRADES
NYSE National BBO and Trades.
XNYS_BBOTRADES
NYSE BBO and Trades.
"""

Expand Down Expand Up @@ -533,6 +537,8 @@ class Dataset(StringyMixin, str, Enum):
DBEQ_MAX = "DBEQ.MAX"
XNAS_BASIC = "XNAS.BASIC"
DBEQ_SUMMARY = "DBEQ.SUMMARY"
XCIS_BBOTRADES = "XCIS.BBOTRADES"
XNYS_BBOTRADES = "XNYS.BBOTRADES"

@classmethod
def from_int(cls, value: int) -> Dataset:
Expand Down Expand Up @@ -603,6 +609,10 @@ def from_int(cls, value: int) -> Dataset:
return Dataset.XNAS_BASIC
if value == 32:
return Dataset.DBEQ_SUMMARY
if value == 33:
return Dataset.XCIS_BBOTRADES
if value == 34:
return Dataset.XNYS_BBOTRADES
raise ValueError(f"Integer value {value} does not correspond with any Dataset variant")

def to_int(self) -> int:
Expand Down Expand Up @@ -673,6 +683,10 @@ def to_int(self) -> int:
return 31
if self == Dataset.DBEQ_SUMMARY:
return 32
if self == Dataset.XCIS_BBOTRADES:
return 33
if self == Dataset.XNYS_BBOTRADES:
return 34
raise ValueError("Invalid Dataset")

@property
Expand Down Expand Up @@ -741,9 +755,13 @@ def description(self) -> str:
if self == Dataset.DBEQ_MAX:
return "Databento Equities Max"
if self == Dataset.XNAS_BASIC:
return "Nasdaq Basic (NLS+QBBO)"
return "Nasdaq Basic (NLS and QBBO)"
if self == Dataset.DBEQ_SUMMARY:
return "Databento Equities Summary"
if self == Dataset.XCIS_BBOTRADES:
return "NYSE National BBO and Trades"
if self == Dataset.XNYS_BBOTRADES:
return "NYSE BBO and Trades"
raise ValueError("Unexpected Dataset value")


Expand Down Expand Up @@ -933,6 +951,10 @@ class Publisher(StringyMixin, str, Enum):
Nasdaq Basic - Nasdaq PSX.
DBEQ_SUMMARY_DBEQ
Databento Equities Summary.
XCIS_BBOTRADES_XCIS
NYSE National BBO and Trades.
XNYS_BBOTRADES_XNYS
NYSE BBO and Trades.
"""

Expand Down Expand Up @@ -1026,6 +1048,8 @@ class Publisher(StringyMixin, str, Enum):
XNAS_BASIC_XBOS = "XNAS.BASIC.XBOS"
XNAS_BASIC_XPSX = "XNAS.BASIC.XPSX"
DBEQ_SUMMARY_DBEQ = "DBEQ.SUMMARY.DBEQ"
XCIS_BBOTRADES_XCIS = "XCIS.BBOTRADES.XCIS"
XNYS_BBOTRADES_XNYS = "XNYS.BBOTRADES.XNYS"

@classmethod
def from_int(cls, value: int) -> Publisher:
Expand Down Expand Up @@ -1212,6 +1236,10 @@ def from_int(cls, value: int) -> Publisher:
return Publisher.XNAS_BASIC_XPSX
if value == 90:
return Publisher.DBEQ_SUMMARY_DBEQ
if value == 91:
return Publisher.XCIS_BBOTRADES_XCIS
if value == 92:
return Publisher.XNYS_BBOTRADES_XNYS
raise ValueError(f"Integer value {value} does not correspond with any Publisher variant")

def to_int(self) -> int:
Expand Down Expand Up @@ -1398,6 +1426,10 @@ def to_int(self) -> int:
return 89
if self == Publisher.DBEQ_SUMMARY_DBEQ:
return 90
if self == Publisher.XCIS_BBOTRADES_XCIS:
return 91
if self == Publisher.XNYS_BBOTRADES_XNYS:
return 92
raise ValueError("Invalid Publisher")

@property
Expand Down Expand Up @@ -1585,6 +1617,10 @@ def venue(self) -> Venue:
return Venue.XPSX
if self == Publisher.DBEQ_SUMMARY_DBEQ:
return Venue.DBEQ
if self == Publisher.XCIS_BBOTRADES_XCIS:
return Venue.XCIS
if self == Publisher.XNYS_BBOTRADES_XNYS:
return Venue.XNYS
raise ValueError("Unexpected Publisher value")

@property
Expand Down Expand Up @@ -1772,6 +1808,10 @@ def dataset(self) -> Dataset:
return Dataset.XNAS_BASIC
if self == Publisher.DBEQ_SUMMARY_DBEQ:
return Dataset.DBEQ_SUMMARY
if self == Publisher.XCIS_BBOTRADES_XCIS:
return Dataset.XCIS_BBOTRADES
if self == Publisher.XNYS_BBOTRADES_XNYS:
return Dataset.XNYS_BBOTRADES
raise ValueError("Unexpected Publisher value")

@property
Expand Down Expand Up @@ -1959,4 +1999,8 @@ def description(self) -> str:
return "Nasdaq Basic - Nasdaq PSX"
if self == Publisher.DBEQ_SUMMARY_DBEQ:
return "Databento Equities Summary"
if self == Publisher.XCIS_BBOTRADES_XCIS:
return "NYSE National BBO and Trades"
if self == Publisher.XNYS_BBOTRADES_XNYS:
return "NYSE BBO and Trades"
raise ValueError("Unexpected Publisher value")
6 changes: 4 additions & 2 deletions databento/live/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Live:
"""

_loop = asyncio.new_event_loop()
_lock = threading.Lock()
_thread = threading.Thread(
target=_loop.run_forever,
name="databento_live",
Expand Down Expand Up @@ -109,8 +110,9 @@ def __init__(

self._session._user_callbacks.append((self._map_symbol, None))

if not Live._thread.is_alive():
Live._thread.start()
with Live._lock:
if not Live._thread.is_alive():
Live._thread.start()

def __del__(self) -> None:
try:
Expand Down
23 changes: 11 additions & 12 deletions databento/live/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,16 @@ def connection_lost(self, exc: Exception | None) -> None:
if not self.disconnected.done():
if exc is None:
logger.info("connection closed")
self.disconnected.set_result(None)
if self._error_msgs:
error_msg = ", ".join(self._error_msgs)
if len(self._error_msgs) > 1:
error_msg = f"The following errors occurred: {error_msg}"
self._error_msgs.clear()
self.disconnected.set_exception(
BentoError(error_msg),
)
else:
self.disconnected.set_result(None)
else:
logger.error("connection lost: %s", exc)
self.disconnected.set_exception(exc)
Expand Down Expand Up @@ -361,17 +370,7 @@ def _process_dbn(self, data: bytes) -> None:
record.err,
)
self._error_msgs.append(record.err)
if record.is_last:
if len(self._error_msgs) > 1:
errors = ", ".join(self._error_msgs)
error_msg = f"The following errors occurred: {errors}"
else:
error_msg = self._error_msgs[-1]
self._error_msgs.clear()
self.disconnected.set_exception(
BentoError(error_msg),
)
if isinstance(record, databento_dbn.SystemMsg):
elif isinstance(record, databento_dbn.SystemMsg):
if record.is_heartbeat:
logger.debug("gateway heartbeat")
else:
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.39.2"
__version__ = "0.39.3"
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.39.2"
version = "0.39.3"
description = "Official Python client library for Databento"
authors = [
"Databento <[email protected]>",
Expand Down

0 comments on commit 39a9e36

Please sign in to comment.