Skip to content

Commit 32e6ea1

Browse files
authored
VER: Release 0.25.0
See release notes.
2 parents 9090bdd + aef77da commit 32e6ea1

File tree

11 files changed

+60
-40
lines changed

11 files changed

+60
-40
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# Changelog
22

3+
## 0.25.0 - 2024-01-09
4+
5+
#### Breaking changes
6+
- Removed deprecated `pretty_px` parameter for `DBNStore.to_df`; `price_type` can be used instead
7+
8+
#### Bug fixes
9+
- Fixed an issue where the `Live` client would not raise an exception when reading an incompatible DBN version
10+
- Fixed an issue where sending lots of subscriptions could cause a `BufferError`
11+
- Fixed an issue where `Historical.batch.download` was slow
12+
- Fixed an issue where `Historical.timeseries.get_range` was slow
13+
- Fixed an issue where reading a DBN file with non-empty metadata symbol mappings and mixed `SType` would cause an error when mapping symbols (credit: Jakob Lövhall)
14+
315
## 0.24.1 - 2023-12-15
416

5-
##### Enhancements
17+
#### Enhancements
618
- Added new publisher value for OPRA MIAX Sapphire
719

820
#### Bug fixes

databento/common/dbnstore.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import decimal
55
import itertools
66
import logging
7-
import warnings
87
from collections.abc import Generator
98
from collections.abc import Iterator
109
from io import BytesIO
@@ -826,7 +825,6 @@ def to_csv(
826825
@overload
827826
def to_df(
828827
self,
829-
pretty_px: bool | None = ...,
830828
price_type: Literal["fixed", "float", "decimal"] = ...,
831829
pretty_ts: bool = ...,
832830
map_symbols: bool = ...,
@@ -838,7 +836,6 @@ def to_df(
838836
@overload
839837
def to_df(
840838
self,
841-
pretty_px: bool | None = ...,
842839
price_type: Literal["fixed", "float", "decimal"] = ...,
843840
pretty_ts: bool = ...,
844841
map_symbols: bool = ...,
@@ -849,7 +846,6 @@ def to_df(
849846

850847
def to_df(
851848
self,
852-
pretty_px: bool | None = None,
853849
price_type: Literal["fixed", "float", "decimal"] = "float",
854850
pretty_ts: bool = True,
855851
map_symbols: bool = True,
@@ -861,11 +857,6 @@ def to_df(
861857
862858
Parameters
863859
----------
864-
pretty_px : bool, default True
865-
This parameter is deprecated and will be removed in a future release.
866-
If all price columns should be converted from `int` to `float` at
867-
the correct scale (using the fixed-precision scalar 1e-9). Null
868-
prices are replaced with NaN.
869860
price_type : str, default "float"
870861
The price type to use for price fields.
871862
If "fixed", prices will have a type of `int` in fixed decimal format; each unit representing 1e-9 or 0.000000001.
@@ -899,20 +890,6 @@ def to_df(
899890
If the schema for the array cannot be determined.
900891
901892
"""
902-
if pretty_px is True:
903-
warnings.warn(
904-
'The argument `pretty_px` is deprecated and will be removed in a future release; `price_type="float"` can be used instead.',
905-
DeprecationWarning,
906-
stacklevel=2,
907-
)
908-
elif pretty_px is False:
909-
price_type = "fixed"
910-
warnings.warn(
911-
'The argument `pretty_px` is deprecated and will be removed in a future release; `price_type="fixed"` can be used instead.',
912-
DeprecationWarning,
913-
stacklevel=2,
914-
)
915-
916893
schema = validate_maybe_enum(schema, Schema, "schema")
917894
if schema is None:
918895
if self.schema is None:

databento/common/symbology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def insert_metadata(self, metadata: Metadata) -> None:
242242
# Nothing to do
243243
return
244244

245-
stype_in = SType(metadata.stype_in)
246-
stype_out = SType(metadata.stype_out)
245+
stype_in = SType(metadata.stype_in) if metadata.stype_in is not None else None
246+
stype_out = SType(metadata.stype_out) if metadata.stype_out is not None else None
247247

248248
for symbol_in, entries in metadata.mappings.items():
249249
for entry in entries:

databento/historical/api/batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def _download_file(
370370

371371
logger.debug("Starting download of file %s", output_path.name)
372372
with open(output_path, mode=mode) as f:
373-
for chunk in response.iter_content():
373+
for chunk in response.iter_content(chunk_size=None):
374374
f.write(chunk)
375375
logger.debug("Download of %s completed", output_path.name)
376376

databento/historical/http.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from databento.common.system import USER_AGENT
2424

2525

26-
_32KIB = 1024 * 32 # 32_768
2726
WARNING_HEADER_FIELD: str = "X-Warning"
2827

2928

@@ -133,7 +132,7 @@ def _stream(
133132
else:
134133
writer = open(path, "x+b")
135134

136-
for chunk in response.iter_content(chunk_size=_32KIB):
135+
for chunk in response.iter_content(chunk_size=None):
137136
writer.write(chunk)
138137

139138
if path is None:

databento/live/protocol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def subscribe(
283283
stype_in_valid = validate_enum(stype_in, SType, "stype_in")
284284
symbols_list = optional_symbols_list_to_list(symbols, stype_in_valid)
285285

286+
subscription_bytes: list[bytes] = []
286287
for batch in chunk(symbols_list, SYMBOL_LIST_BATCH_SIZE):
287288
batch_str = ",".join(batch)
288289
message = SubscriptionRequest(
@@ -291,8 +292,9 @@ def subscribe(
291292
symbols=batch_str,
292293
start=optional_datetime_to_unix_nanoseconds(start),
293294
)
295+
subscription_bytes.append(bytes(message))
294296

295-
self.transport.write(bytes(message))
297+
self.transport.writelines(subscription_bytes)
296298

297299
def start(
298300
self,
@@ -312,8 +314,6 @@ def _process_dbn(self, data: bytes) -> None:
312314
try:
313315
self._dbn_decoder.write(bytes(data))
314316
records = self._dbn_decoder.decode()
315-
except ValueError:
316-
pass # expected for partial records
317317
except Exception:
318318
logger.exception("error decoding DBN record")
319319
self.__transport.close()

databento/live/session.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,15 @@ def subscribe(
366366
loop=self._loop,
367367
)
368368

369-
self._protocol.subscribe(
369+
asyncio.run_coroutine_threadsafe(
370+
self._subscribe_task(
370371
schema=schema,
371372
symbols=symbols,
372373
stype_in=stype_in,
373374
start=start,
374-
)
375+
),
376+
loop=self._loop,
377+
).result()
375378

376379
def resume_reading(self) -> None:
377380
"""
@@ -477,7 +480,7 @@ async def _connect_task(
477480
)
478481

479482
try:
480-
await asyncio.wait_for(
483+
session_id = await asyncio.wait_for(
481484
protocol.authenticated,
482485
timeout=AUTH_TIMEOUT_SECONDS,
483486
)
@@ -488,9 +491,29 @@ async def _connect_task(
488491
) from None
489492
except ValueError as exc:
490493
raise BentoError(f"User authentication failed: {exc!s}") from None
494+
else:
495+
logger.info("assigned session id %s", session_id)
491496

492497
logger.info(
493498
"authentication with remote gateway completed",
494499
)
495500

496501
return transport, protocol
502+
503+
async def _subscribe_task(
504+
self,
505+
schema: Schema | str,
506+
symbols: Iterable[str] | Iterable[Number] | str | Number = ALL_SYMBOLS,
507+
stype_in: SType | str = SType.RAW_SYMBOL,
508+
start: str | int | None = None,
509+
) -> None:
510+
with self._lock:
511+
if self._protocol is None:
512+
return
513+
514+
self._protocol.subscribe(
515+
schema=schema,
516+
symbols=symbols,
517+
stype_in=stype_in,
518+
start=start,
519+
)

databento/version.py

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "databento"
3-
version = "0.24.1"
3+
version = "0.25.0"
44
description = "Official Python client library for Databento"
55
authors = [
66
"Databento <[email protected]>",

tests/test_common_symbology.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def create_metadata(
166166
dataset: str = "UNIT.TEST",
167167
start: int = UNDEF_TIMESTAMP,
168168
end: int = UNDEF_TIMESTAMP,
169-
stype_in: SType = SType.RAW_SYMBOL,
169+
stype_in: SType | None = SType.RAW_SYMBOL,
170170
stype_out: SType = SType.INSTRUMENT_ID,
171171
schema: Schema = Schema.TRADES,
172172
limit: int | None = None,
@@ -198,10 +198,18 @@ def test_instrument_map(
198198
assert instrument_map._data == {}
199199

200200

201+
@pytest.mark.parametrize(
202+
"stype_in",
203+
[
204+
SType.RAW_SYMBOL,
205+
None,
206+
],
207+
)
201208
def test_instrument_map_insert_metadata(
202209
instrument_map: InstrumentMap,
203210
start_date: pd.Timestamp,
204211
end_date: pd.Timestamp,
212+
stype_in: SType | None,
205213
) -> None:
206214
"""
207215
Test the insertion of DBN Metadata.
@@ -224,6 +232,7 @@ def test_instrument_map_insert_metadata(
224232
]
225233

226234
metadata = create_metadata(
235+
stype_in=stype_in,
227236
mappings=mappings,
228237
)
229238

0 commit comments

Comments
 (0)