Skip to content

Commit

Permalink
DOC: Document potential lower expiration precision
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen committed Dec 4, 2024
1 parent dcdf7b1 commit 44e2267
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 66 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- Changed async DBN decoding to return `Ok(None)` when an incomplete record remains in
the stream. This matches the existing behavior of sync DBN decoding

### Bug fixes
- Added handling for `UNDEF_TIMESTAMP` in `pretty_` timestamp getters for Python. They
now return `None` in the case of `UNDEF_TIMESTAMP`

## 0.23.1 - 2024-11-12

### Enhancements
Expand Down
58 changes: 39 additions & 19 deletions python/python/databento_dbn/_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ class Record(SupportsBytes):
"""

@property
def pretty_ts_event(self) -> dt.datetime:
def pretty_ts_event(self) -> dt.datetime | None:
"""
The matching-engine-received timestamp expressed as a
datetime or a `pandas.Timestamp`, if available.
Expand Down Expand Up @@ -1281,7 +1281,7 @@ class _MBOBase:
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -1705,7 +1705,7 @@ class _MBPBase:
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -1897,7 +1897,7 @@ class BBOMsg(Record):
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -2054,7 +2054,7 @@ class CMBP1Msg(Record):
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The interval timestamp as a datetime or `pandas.Timestamp` if available.
Expand Down Expand Up @@ -2197,7 +2197,7 @@ class CBBOMsg(Record):
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -2506,7 +2506,7 @@ class InstrumentDefMsg(Record):
tick_rule: int | None = None,
) -> None: ...
@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -2573,11 +2573,13 @@ class InstrumentDefMsg(Record):
"""

@property
def pretty_expiration(self) -> dt.datetime:
def pretty_expiration(self) -> dt.datetime | None:
"""
The last eligible trade time expressed as a datetime or
`pandas.Timestamp`, if available.
Some publishers only provide date-level granularity.
Returns
-------
datetime.datetime
Expand All @@ -2590,18 +2592,23 @@ class InstrumentDefMsg(Record):
The last eligible trade time expressed as a number of nanoseconds since
the UNIX epoch.
Will be `UNDEF_TIMESTAMP` when null, such as for equities. Some publishers
only provide date-level granularity.
Returns
-------
int
"""

@property
def pretty_activation(self) -> dt.datetime:
def pretty_activation(self) -> dt.datetime | None:
"""
The time of instrument activation expressed as a datetime or
`pandas.Timestamp`, if available.
Some publishers only provide date-level granularity.
Returns
-------
datetime.datetime
Expand All @@ -2614,6 +2621,9 @@ class InstrumentDefMsg(Record):
The time of instrument activation expressed as a number of nanoseconds
since the UNIX epoch.
Will be `UNDEF_TIMESTAMP` when null, such as for equities. Some publishers
only provide date-level granularity.
Returns
-------
int
Expand Down Expand Up @@ -3447,7 +3457,7 @@ class InstrumentDefMsgV1(Record):
tick_rule: int | None = None,
) -> None: ...
@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -3514,11 +3524,13 @@ class InstrumentDefMsgV1(Record):
"""

@property
def pretty_expiration(self) -> dt.datetime:
def pretty_expiration(self) -> dt.datetime | None:
"""
The last eligible trade time expressed as a datetime or
`pandas.Timestamp`, if available.
Some publishers only provide date-level granularity.
Returns
-------
datetime.datetime
Expand All @@ -3531,18 +3543,23 @@ class InstrumentDefMsgV1(Record):
The last eligible trade time expressed as a number of nanoseconds since
the UNIX epoch.
Will be `UNDEF_TIMESTAMP` when null, such as for equities. Some publishers
only provide date-level granularity.
Returns
-------
int
"""

@property
def pretty_activation(self) -> dt.datetime:
def pretty_activation(self) -> dt.datetime | None:
"""
The time of instrument activation expressed as a datetime or
`pandas.Timestamp`, if available.
Some publishers only provide date-level granularity.
Returns
-------
datetime.datetime
Expand All @@ -3555,6 +3572,9 @@ class InstrumentDefMsgV1(Record):
The time of instrument activation expressed as a number of nanoseconds
since the UNIX epoch.
Will be `UNDEF_TIMESTAMP` when null, such as for equities. Some publishers
only provide date-level granularity.
Returns
-------
int
Expand Down Expand Up @@ -4337,7 +4357,7 @@ class ImbalanceMsg(Record):
significant_imbalance: str,
) -> None: ...
@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -4660,7 +4680,7 @@ class StatMsg(Record):
stat_flags: int = 0,
) -> None: ...
@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand All @@ -4684,7 +4704,7 @@ class StatMsg(Record):
"""

@property
def pretty_ts_ref(self) -> dt.datetime:
def pretty_ts_ref(self) -> dt.datetime | None:
"""
Reference timestamp expressed as the number of nanoseconds since the
UNIX epoch as a datetime or `pandas.Timestamp`, if available.
Expand Down Expand Up @@ -4823,7 +4843,7 @@ class StatusMsg(Record):
"""

@property
def pretty_ts_recv(self) -> dt.datetime:
def pretty_ts_recv(self) -> dt.datetime | None:
"""
The capture-server-received timestamp as a datetime or
`pandas.Timestamp`, if available.
Expand Down Expand Up @@ -5007,7 +5027,7 @@ class SymbolMappingMsg(Record):
"""

@property
def pretty_start_ts(self) -> dt.datetime:
def pretty_start_ts(self) -> dt.datetime | None:
"""
The start of the mapping interval expressed as a datetime
or `pandas.Timestamp`, if available.
Expand All @@ -5031,7 +5051,7 @@ class SymbolMappingMsg(Record):
"""

@property
def pretty_end_ts(self) -> dt.datetime:
def pretty_end_ts(self) -> dt.datetime | None:
"""
The end of the mapping interval expressed as a datetime
or `pandas.Timestamp`, if available.
Expand Down Expand Up @@ -5201,7 +5221,7 @@ class Transcoder:
pretty_px : bool, default True
Whether to serialize fixed-precision prices as decimal strings. Only applicable
to CSV and JSON.
pretty_ts : bool, default True
pretty_ts : bool, default Tru | Nonee
Whether to serialize nanosecond UNIX timestamps as ISO8601 datetime strings.
Only applicable to CSV and JSON.
map_symbols : bool, default None
Expand Down
10 changes: 8 additions & 2 deletions rust/dbn/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ pub struct InstrumentDefMsgV1 {
#[pyo3(get, set)]
pub display_factor: i64,
/// The last eligible trade time expressed as a number of nanoseconds since the
/// UNIX epoch. Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities.
/// UNIX epoch.
///
/// Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities. Some publishers
/// only provide date-level granularity.
#[dbn(unix_nanos)]
#[pyo3(get, set)]
pub expiration: u64,
/// The time of instrument activation expressed as a number of nanoseconds since the
/// UNIX epoch. Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities.
/// UNIX epoch.
///
/// Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities. Some publishers
/// only provide date-level granularity.
#[dbn(unix_nanos)]
#[pyo3(get, set)]
pub activation: u64,
Expand Down
Loading

0 comments on commit 44e2267

Please sign in to comment.