Skip to content

Commit 2e8ce08

Browse files
committed
MOD: Timestamp parsing for SymbolMappingMsg
1 parent 6e97322 commit 2e8ce08

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.md

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

3+
## 0.30.0 - TBD
4+
5+
#### Enhancements
6+
- Changed how `SymbolMappingMsg` objects are ingested by `InstrumentMap` to single source the timestamp parsing from the `dbn` package.
7+
8+
#### Breaking changes
9+
- Changed `Live.add_stream` to use the exclusive write mode when handling file paths so existing files won't be overwritten.
10+
311
## 0.29.0 - 2024-02-13
412

513
#### Enhancements

databento/common/symbology.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,12 @@ def insert_symbol_mapping_msg(
297297
if msg.start_ts == UNDEF_TIMESTAMP:
298298
start_ts = pd.Timestamp.min
299299
else:
300-
start_ts = msg.start_ts
300+
start_ts = msg.pretty_start_ts
301301

302302
if msg.end_ts == UNDEF_TIMESTAMP:
303303
end_ts = pd.Timestamp.max
304304
else:
305-
end_ts = msg.end_ts
305+
end_ts = msg.pretty_end_ts
306306

307307
# Need to decide if we care about the input or output symbol
308308
# For smart symbology, the output symbol is more useful
@@ -314,8 +314,8 @@ def insert_symbol_mapping_msg(
314314
self._insert_interval(
315315
msg.hd.instrument_id,
316316
MappingInterval(
317-
start_date=pd.Timestamp(start_ts, unit="ns", tz="utc").date(),
318-
end_date=pd.Timestamp(end_ts, unit="ns", tz="utc").date(),
317+
start_date=start_ts.date(),
318+
end_date=end_ts.date(),
319319
symbol=symbol,
320320
),
321321
)

databento/live/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,15 @@ def add_stream(
357357
If `stream` is not a writable byte stream.
358358
OSError
359359
If `stream` is not a path to a writeable file.
360+
If `stream` is a path to a file that exists.
360361
361362
See Also
362363
--------
363364
Live.add_callback
364365
365366
"""
366367
if isinstance(stream, (str, PathLike)):
367-
stream = pathlib.Path(stream).open("wb")
368+
stream = pathlib.Path(stream).open("xb")
368369

369370
if not hasattr(stream, "write"):
370371
raise ValueError(f"{type(stream).__name__} does not support write()")

0 commit comments

Comments
 (0)