Skip to content

Commit 81780d2

Browse files
committed
MOD: Integrate DBN 0.5.0
1 parent 09fcabc commit 81780d2

File tree

12 files changed

+58
-120
lines changed

12 files changed

+58
-120
lines changed

CHANGELOG.md

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

33
## 0.12.0 - TBD
4+
- Upgraded `databento-dbn` to 0.5.0
45
- Renamed the `cost` field to `cost_usd` for `batch.submit_job` and `batch.list_jobs` (value now expressed as US dollars)
6+
- Removed `bad` condition variant from `batch.get_dataset_condition`
7+
- Added `degraded`, `pending` and `missing` condition variants for `batch.get_dataset_condition`
8+
- Added `last_modified_date` field to `batch.get_dataset_condition` response
59

610
## 0.11.0 - 2023-04-13
711
- Changed `end` and `end_date` to optional to support new forward-fill behaviour

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The library is fully compatible with the latest distribution of Anaconda 3.7 and
3131
The minimum dependencies as found in the `requirements.txt` are also listed below:
3232
- Python (>=3.7)
3333
- aiohttp (>=3.7.2)
34-
- databento-dbn (==0.4.3)
34+
- databento-dbn (==0.5.0)
3535
- numpy (>=1.17.0)
3636
- pandas (>=1.1.3)
3737
- requests (>=2.24.0)

databento/common/dbnstore.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
)
3232
from databento.common.enums import Compression, Schema, SType
3333
from databento.common.error import BentoError
34-
from databento.common.metadata import MetadataDecoder
3534
from databento.common.symbology import InstrumentIdMappingInterval
35+
from databento_dbn import Metadata
3636

3737

3838
logger = logging.getLogger(__name__)
@@ -195,7 +195,7 @@ class MemoryDataSource(DataSource):
195195
196196
"""
197197

198-
def __init__(self, source: Union[BytesIO, bytes]):
198+
def __init__(self, source: Union[BytesIO, bytes, IO[bytes]]):
199199
initial_data = source if isinstance(source, bytes) else source.read()
200200
if len(initial_data) == 0:
201201
raise ValueError(
@@ -334,7 +334,7 @@ def __init__(self, data_source: DataSource) -> None:
334334
metadata_bytes.write(buffer.read(metadata_length))
335335

336336
# Read metadata
337-
self._metadata: Dict[str, Any] = MetadataDecoder().decode_to_json(
337+
self._metadata: Metadata = Metadata.decode(
338338
metadata_bytes.getvalue(),
339339
)
340340

@@ -408,7 +408,7 @@ def _build_instrument_id_index(self) -> Dict[dt.date, Dict[int, str]]:
408408
),
409409
)
410410

411-
product_id_index: Dict[dt.date, Dict[int, str]] = {}
411+
instrument_id_index: Dict[dt.date, Dict[int, str]] = {}
412412
for interval in intervals:
413413
for ts in pd.date_range(
414414
start=interval.start_date,
@@ -417,12 +417,12 @@ def _build_instrument_id_index(self) -> Dict[dt.date, Dict[int, str]]:
417417
**{"inclusive" if pd.__version__ >= "1.4.0" else "closed": "left"},
418418
):
419419
d: dt.date = ts.date()
420-
date_map: Dict[int, str] = product_id_index.get(d, {})
420+
date_map: Dict[int, str] = instrument_id_index.get(d, {})
421421
if not date_map:
422-
product_id_index[d] = date_map
422+
instrument_id_index[d] = date_map
423423
date_map[interval.instrument_id] = interval.raw_symbol
424424

425-
return product_id_index
425+
return instrument_id_index
426426

427427
def _prepare_dataframe(self, df: pd.DataFrame) -> pd.DataFrame:
428428
# Setup column ordering and index
@@ -495,7 +495,7 @@ def dataset(self) -> str:
495495
str
496496
497497
"""
498-
return str(self._metadata["dataset"])
498+
return str(self._metadata.dataset)
499499

500500
@property
501501
def dtype(self) -> np.dtype[Any]:
@@ -523,7 +523,7 @@ def end(self) -> pd.Timestamp:
523523
The data timestamps will not occur after `end`.
524524
525525
"""
526-
return pd.Timestamp(self._metadata["end"], tz="UTC")
526+
return pd.Timestamp(self._metadata.end, tz="UTC")
527527

528528
@property
529529
def limit(self) -> Optional[int]:
@@ -535,7 +535,7 @@ def limit(self) -> Optional[int]:
535535
int or None
536536
537537
"""
538-
return self._metadata["limit"]
538+
return self._metadata.limit
539539

540540
@property
541541
def nbytes(self) -> int:
@@ -559,16 +559,16 @@ def mappings(self) -> Dict[str, List[Dict[str, Any]]]:
559559
Dict[str, List[Dict[str, Any]]]
560560
561561
"""
562-
return self._metadata["mappings"]
562+
return self._metadata.mappings
563563

564564
@property
565-
def metadata(self) -> Dict[str, Any]:
565+
def metadata(self) -> Metadata:
566566
"""
567567
Return the metadata for the data.
568568
569569
Returns
570570
-------
571-
Dict[str, Any]
571+
Metadata
572572
573573
"""
574574
return self._metadata
@@ -624,7 +624,7 @@ def schema(self) -> Schema:
624624
Schema
625625
626626
"""
627-
return Schema(self._metadata["schema"])
627+
return Schema(self._metadata.schema)
628628

629629
@property
630630
def start(self) -> pd.Timestamp:
@@ -640,7 +640,7 @@ def start(self) -> pd.Timestamp:
640640
The data timestamps will not occur prior to `start`.
641641
642642
"""
643-
return pd.Timestamp(self._metadata["start"], tz="UTC")
643+
return pd.Timestamp(self._metadata.start, tz="UTC")
644644

645645
@property
646646
def record_size(self) -> int:
@@ -664,7 +664,7 @@ def stype_in(self) -> SType:
664664
SType
665665
666666
"""
667-
return SType(self._metadata["stype_in"])
667+
return SType(self._metadata.stype_in)
668668

669669
@property
670670
def stype_out(self) -> SType:
@@ -676,7 +676,7 @@ def stype_out(self) -> SType:
676676
SType
677677
678678
"""
679-
return SType(self._metadata["stype_out"])
679+
return SType(self._metadata.stype_out)
680680

681681
@property
682682
def symbology(self) -> Dict[str, Any]:
@@ -694,8 +694,8 @@ def symbology(self) -> Dict[str, Any]:
694694
"stype_out": str(self.stype_out),
695695
"start_date": str(self.start.date()),
696696
"end_date": str(self.end.date()),
697-
"partial": self._metadata["partial"],
698-
"not_found": self._metadata["not_found"],
697+
"partial": self._metadata.partial,
698+
"not_found": self._metadata.not_found,
699699
"mappings": self.mappings,
700700
}
701701

@@ -709,7 +709,7 @@ def symbols(self) -> List[str]:
709709
List[str]
710710
711711
"""
712-
return self._metadata["symbols"]
712+
return self._metadata.symbols
713713

714714
@classmethod
715715
def from_file(cls, path: Union[PathLike[str], str]) -> "DBNStore":

databento/common/enums.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,15 @@ class RecordFlags(StringyMixin, IntFlag): # type: ignore
253253
"""Represents record flags.
254254
255255
F_LAST
256-
Last message in the packet from the venue for a given `product_id`
256+
Last message in the packet from the venue for a given `instrument_id`.
257257
F_SNAPSHOT
258-
Message sourced from a replay, such as a snapshot server
258+
Message sourced from a replay, such as a snapshot server.
259259
F_MBP
260-
Aggregated price level message, not an individual order
260+
Aggregated price level message, not an individual order.
261261
F_BAD_TS_RECV
262-
The `ts_recv` value is inaccurate (clock issues or reordering)
262+
The `ts_recv` value is inaccurate (clock issues or reordering).
263263
264264
Other bits are reserved and have no current meaning.
265-
266265
"""
267266

268267
F_LAST = 128

databento/common/metadata.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

databento/common/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _(symbols: str, stype_in: SType) -> str:
142142
symbol_list = symbols.strip().strip(",").split(",")
143143
return ",".join(map(symbol_to_string, symbol_list))
144144

145-
# TODO(cs): Temporary mapping until new DBN released
145+
# TODO(cs): Temporary mapping until past stype rename deprecation period
146146
if stype_in in (SType.SMART, SType.CONTINUOUS):
147147
return validate_smart_symbol(symbols)
148148
return symbols.strip().upper()

databento/historical/api/batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def submit_job(
7979
dataset : Dataset or str
8080
The dataset code (string identifier) for the request.
8181
symbols : List[Union[str, int]] or str
82-
The product symbols to filter for. Takes up to 2,000 symbols per request.
82+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
8383
If more than 1 symbol is specified, the data is merged and sorted by time.
8484
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
8585
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa

databento/historical/api/metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def get_record_count(
299299
Values are forward filled based on the resolution provided.
300300
Defaults to the same value as `start`.
301301
symbols : List[Union[str, int]] or str, optional
302-
The product symbols to filter for. Takes up to 2,000 symbols per request.
302+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
303303
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
304304
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
305305
The data record schema for the request.
@@ -368,7 +368,7 @@ def get_billable_size(
368368
Values are forward filled based on the resolution provided.
369369
Defaults to the same value as `start`.
370370
symbols : List[Union[str, int]] or str, optional
371-
The product symbols to filter for. Takes up to 2,000 symbols per request.
371+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
372372
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
373373
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
374374
The data record schema for the request.
@@ -440,7 +440,7 @@ def get_cost(
440440
mode : FeedMode or str {'live', 'historical-streaming', 'historical'}, default 'historical-streaming'
441441
The data feed mode for the request.
442442
symbols : List[Union[str, int]] or str, optional
443-
The product symbols to filter for. Takes up to 2,000 symbols per request.
443+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
444444
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
445445
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
446446
The data record schema for the request.

databento/historical/api/timeseries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_range(
9797
Values are forward filled based on the resolution provided.
9898
Defaults to the same value as `start`.
9999
symbols : List[Union[str, int]] or str, optional
100-
The product symbols to filter for. Takes up to 2,000 symbols per request.
100+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
101101
If more than 1 symbol is specified, the data is merged and sorted by time.
102102
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
103103
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
@@ -237,7 +237,7 @@ async def get_range_async(
237237
Values are forward filled based on the resolution provided.
238238
Defaults to the same value as `start`.
239239
symbols : List[Union[str, int]] or str, optional
240-
The product symbols to filter for. Takes up to 2,000 symbols per request.
240+
The instrument symbols to filter for. Takes up to 2,000 symbols per request.
241241
If more than 1 symbol is specified, the data is merged and sorted by time.
242242
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
243243
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aiohttp>=3.7.2,<4.0.0
2-
databento-dbn==0.4.3
2+
databento-dbn==0.5.0
33
numpy>=1.17.0
44
pandas>=1.1.3
55
requests>=2.24.0

0 commit comments

Comments
 (0)