Skip to content

Commit 1bcd5a9

Browse files
authored
VER: Release 0.32.0
2 parents e244bd4 + 8969d3c commit 1bcd5a9

File tree

12 files changed

+108
-64
lines changed

12 files changed

+108
-64
lines changed

CHANGELOG.md

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

3+
## 0.32.0 - 2024-04-04
4+
5+
#### Enhancements
6+
- Improved exception messages when multiple `ErrorMsg` are received by the `Live` client
7+
- Upgraded `databento-dbn` to 0.17.1
8+
9+
#### Bug fixes
10+
- Removed live session ID parsing to `int`, that could cause a session to fail when
11+
nothing was wrong
12+
13+
#### Breaking changes
14+
- Renamed publishers from deprecated datasets to their respective sources (`XNAS.NLS`
15+
and `XNYS.TRADES` respectively)
16+
17+
#### Deprecations
18+
- Deprecated dataset values `FINN.NLS` and `FINY.TRADES`
19+
320
## 0.31.1 - 2024-03-20
421

522
#### Enhancements

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
The official Python client library for [Databento](https://databento.com).
1111

1212
Key features include:
13-
- Fast, lightweight access to both live and historical data from [multiple markets](https://docs.databento.com/knowledge-base/new-users/venues-and-publishers?historical=python&live=python).
14-
- [Multiple schemas](https://docs.databento.com/knowledge-base/new-users/market-data-schemas?historical=python&live=python) such as MBO, MBP, top of book, OHLCV, last sale, and more.
15-
- [Fully normalized](https://docs.databento.com/knowledge-base/new-users/normalization?historical=python&live=python), i.e. identical message schemas for both live and historical data, across multiple asset classes.
16-
- Provides mappings between different symbology systems, including [smart symbology](https://docs.databento.com/api-reference-historical/basics/symbology?historical=python&live=python) for futures rollovers.
13+
- Fast, lightweight access to both live and historical data from [multiple markets](https://databento.com/docs/knowledge-base/new-users/venues-and-publishers?historical=python&live=python).
14+
- [Multiple schemas](https://databento.com/docs/knowledge-base/new-users/market-data-schemas?historical=python&live=python) such as MBO, MBP, top of book, OHLCV, last sale, and more.
15+
- [Fully normalized](https://databento.com/docs/knowledge-base/new-users/normalization?historical=python&live=python), i.e. identical message schemas for both live and historical data, across multiple asset classes.
16+
- Provides mappings between different symbology systems, including [smart symbology](https://databento.com/docs/api-reference-historical/basics/symbology?historical=python&live=python) for futures rollovers.
1717
- [Point-in-time]() instrument definitions, free of look-ahead bias and retroactive adjustments.
18-
- Reads and stores market data in an extremely efficient file format using [Databento Binary Encoding](https://docs.databento.com/knowledge-base/new-users/dbn-encoding?historical=python&live=python).
19-
- Event-driven [market replay](https://docs.databento.com/api-reference-historical/helpers/bento-replay?historical=python&live=python), including at high-frequency order book granularity.
20-
- Support for [batch download](https://docs.databento.com/knowledge-base/new-users/stream-vs-batch?historical=python&live=python) of flat files.
18+
- Reads and stores market data in an extremely efficient file format using [Databento Binary Encoding](https://databento.com/docs/knowledge-base/new-users/dbn-encoding?historical=python&live=python).
19+
- Event-driven [market replay](https://databento.com/docs/api-reference-historical/helpers/bento-replay?historical=python&live=python), including at high-frequency order book granularity.
20+
- Support for [batch download](https://databento.com/docs/knowledge-base/new-users/stream-vs-batch?historical=python&live=python) of flat files.
2121
- Support for [pandas](https://pandas.pydata.org/docs/), CSV, and JSON.
2222

2323
## Documentation
24-
The best place to begin is with our [Getting started](https://docs.databento.com/getting-started?historical=python&live=python) guide.
24+
The best place to begin is with our [Getting started](https://databento.com/docs/getting-started?historical=python&live=python) guide.
2525

26-
You can find our full client API reference on the [Historical Reference](https://docs.databento.com/api-reference-historical?historical=python&live=python) and
27-
[Live Reference](https://docs.databento.com/reference-live?historical=python&live=python) sections of our documentation. See also the
28-
[Examples](https://docs.databento.com/examples?historical=python&live=python) section for various tutorials and code samples.
26+
You can find our full client API reference on the [Historical Reference](https://databento.com/docs/api-reference-historical?historical=python&live=python) and
27+
[Live Reference](https://databento.com/docs/reference-live?historical=python&live=python) sections of our documentation. See also the
28+
[Examples](https://databento.com/docs/examples?historical=python&live=python) section for various tutorials and code samples.
2929

3030
## Requirements
3131
The library is fully compatible with the latest distribution of Anaconda 3.8 and above.
3232
The minimum dependencies as found in the `pyproject.toml` are also listed below:
3333
- python = "^3.8"
3434
- aiohttp = "^3.8.3"
35-
- databento-dbn = "0.16.0"
35+
- databento-dbn = "0.17.1"
3636
- numpy= ">=1.23.5"
3737
- pandas = ">=1.5.3"
3838
- pyarrow = ">=13.0.0"
@@ -79,7 +79,7 @@ array = data.to_ndarray() # to ndarray
7979
```
8080

8181
Note that the API key was also passed as a parameter, which is
82-
[not recommended for production applications](https://docs.databento.com/knowledge-base/new-users/security-managing-api-keys?historical=python&live=python).
82+
[not recommended for production applications](https://databento.com/docs/knowledge-base/new-users/security-managing-api-keys?historical=python&live=python).
8383
Instead, you can leave out this parameter to pass your API key via the `DATABENTO_API_KEY` environment variable:
8484

8585
```python

databento/common/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Final
44

55
import numpy as np
6+
from databento_dbn import CbboMsg
67
from databento_dbn import ImbalanceMsg
78
from databento_dbn import InstrumentDefMsg
89
from databento_dbn import InstrumentDefMsgV1
@@ -36,9 +37,16 @@
3637
Schema.OHLCV_1M: OHLCVMsg,
3738
Schema.OHLCV_1H: OHLCVMsg,
3839
Schema.OHLCV_1D: OHLCVMsg,
40+
Schema.OHLCV_EOD: OHLCVMsg,
3941
Schema.STATISTICS: StatMsg,
4042
Schema.TBBO: MBP1Msg,
4143
Schema.TRADES: TradeMsg,
44+
Schema.CBBO: CbboMsg,
45+
Schema.CBBO_1S: CbboMsg,
46+
Schema.CBBO_1M: CbboMsg,
47+
Schema.TCBBO: CbboMsg,
48+
Schema.BBO_1S: MBP1Msg,
49+
Schema.BBO_1M: MBP1Msg,
4250
}
4351

4452
SCHEMA_STRUCT_MAP_V1: Final[dict[Schema, type[DBNRecord]]] = {

databento/common/dbnstore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class DBNStore:
330330
331331
See Also
332332
--------
333-
https://docs.databento.com/knowledge-base/new-users/dbn-encoding
333+
https://databento.com/docs/knowledge-base/new-users/dbn-encoding
334334
335335
"""
336336

databento/common/publishers.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,9 @@ class Dataset(StringyMixin, str, Enum):
458458
EPRL_DOM
459459
MIAX Pearl Depth.
460460
FINN_NLS
461-
FINRA/Nasdaq TRF.
461+
FINRA/Nasdaq TRF (DEPRECATED).
462462
FINY_TRADES
463-
FINRA/NYSE TRF.
463+
FINRA/NYSE TRF (DEPRECATED).
464464
OPRA_PILLAR
465465
OPRA Binary.
466466
DBEQ_BASIC
@@ -690,9 +690,9 @@ def description(self) -> str:
690690
if self == Dataset.EPRL_DOM:
691691
return "MIAX Pearl Depth"
692692
if self == Dataset.FINN_NLS:
693-
return "FINRA/Nasdaq TRF"
693+
return "FINRA/Nasdaq TRF (DEPRECATED)"
694694
if self == Dataset.FINY_TRADES:
695-
return "FINRA/NYSE TRF"
695+
return "FINRA/NYSE TRF (DEPRECATED)"
696696
if self == Dataset.OPRA_PILLAR:
697697
return "OPRA Binary"
698698
if self == Dataset.DBEQ_BASIC:
@@ -758,11 +758,11 @@ class Publisher(StringyMixin, str, Enum):
758758
MEMX Memoir Depth.
759759
EPRL_DOM_EPRL
760760
MIAX Pearl Depth.
761-
FINN_NLS_FINN
761+
XNAS_NLS_FINN
762762
FINRA/Nasdaq TRF Carteret.
763-
FINN_NLS_FINC
763+
XNAS_NLS_FINC
764764
FINRA/Nasdaq TRF Chicago.
765-
FINY_TRADES_FINY
765+
XNYS_TRADES_FINY
766766
FINRA/NYSE TRF.
767767
OPRA_PILLAR_AMXO
768768
OPRA - NYSE American.
@@ -905,9 +905,9 @@ class Publisher(StringyMixin, str, Enum):
905905
XCIS_TRADES_XCIS = "XCIS.TRADES.XCIS"
906906
MEMX_MEMOIR_MEMX = "MEMX.MEMOIR.MEMX"
907907
EPRL_DOM_EPRL = "EPRL.DOM.EPRL"
908-
FINN_NLS_FINN = "FINN.NLS.FINN"
909-
FINN_NLS_FINC = "FINN.NLS.FINC"
910-
FINY_TRADES_FINY = "FINY.TRADES.FINY"
908+
XNAS_NLS_FINN = "XNAS.NLS.FINN"
909+
XNAS_NLS_FINC = "XNAS.NLS.FINC"
910+
XNYS_TRADES_FINY = "XNYS.TRADES.FINY"
911911
OPRA_PILLAR_AMXO = "OPRA.PILLAR.AMXO"
912912
OPRA_PILLAR_XBOX = "OPRA.PILLAR.XBOX"
913913
OPRA_PILLAR_XCBO = "OPRA.PILLAR.XCBO"
@@ -1008,11 +1008,11 @@ def from_int(cls, value: int) -> Publisher:
10081008
if value == 16:
10091009
return Publisher.EPRL_DOM_EPRL
10101010
if value == 17:
1011-
return Publisher.FINN_NLS_FINN
1011+
return Publisher.XNAS_NLS_FINN
10121012
if value == 18:
1013-
return Publisher.FINN_NLS_FINC
1013+
return Publisher.XNAS_NLS_FINC
10141014
if value == 19:
1015-
return Publisher.FINY_TRADES_FINY
1015+
return Publisher.XNYS_TRADES_FINY
10161016
if value == 20:
10171017
return Publisher.OPRA_PILLAR_AMXO
10181018
if value == 21:
@@ -1173,11 +1173,11 @@ def to_int(self) -> int:
11731173
return 15
11741174
if self == Publisher.EPRL_DOM_EPRL:
11751175
return 16
1176-
if self == Publisher.FINN_NLS_FINN:
1176+
if self == Publisher.XNAS_NLS_FINN:
11771177
return 17
1178-
if self == Publisher.FINN_NLS_FINC:
1178+
if self == Publisher.XNAS_NLS_FINC:
11791179
return 18
1180-
if self == Publisher.FINY_TRADES_FINY:
1180+
if self == Publisher.XNYS_TRADES_FINY:
11811181
return 19
11821182
if self == Publisher.OPRA_PILLAR_AMXO:
11831183
return 20
@@ -1340,11 +1340,11 @@ def venue(self) -> Venue:
13401340
return Venue.MEMX
13411341
if self == Publisher.EPRL_DOM_EPRL:
13421342
return Venue.EPRL
1343-
if self == Publisher.FINN_NLS_FINN:
1343+
if self == Publisher.XNAS_NLS_FINN:
13441344
return Venue.FINN
1345-
if self == Publisher.FINN_NLS_FINC:
1345+
if self == Publisher.XNAS_NLS_FINC:
13461346
return Venue.FINC
1347-
if self == Publisher.FINY_TRADES_FINY:
1347+
if self == Publisher.XNYS_TRADES_FINY:
13481348
return Venue.FINY
13491349
if self == Publisher.OPRA_PILLAR_AMXO:
13501350
return Venue.AMXO
@@ -1507,12 +1507,12 @@ def dataset(self) -> Dataset:
15071507
return Dataset.MEMX_MEMOIR
15081508
if self == Publisher.EPRL_DOM_EPRL:
15091509
return Dataset.EPRL_DOM
1510-
if self == Publisher.FINN_NLS_FINN:
1511-
return Dataset.FINN_NLS
1512-
if self == Publisher.FINN_NLS_FINC:
1513-
return Dataset.FINN_NLS
1514-
if self == Publisher.FINY_TRADES_FINY:
1515-
return Dataset.FINY_TRADES
1510+
if self == Publisher.XNAS_NLS_FINN:
1511+
return Dataset.XNAS_NLS
1512+
if self == Publisher.XNAS_NLS_FINC:
1513+
return Dataset.XNAS_NLS
1514+
if self == Publisher.XNYS_TRADES_FINY:
1515+
return Dataset.XNYS_TRADES
15161516
if self == Publisher.OPRA_PILLAR_AMXO:
15171517
return Dataset.OPRA_PILLAR
15181518
if self == Publisher.OPRA_PILLAR_XBOX:
@@ -1674,11 +1674,11 @@ def description(self) -> str:
16741674
return "MEMX Memoir Depth"
16751675
if self == Publisher.EPRL_DOM_EPRL:
16761676
return "MIAX Pearl Depth"
1677-
if self == Publisher.FINN_NLS_FINN:
1677+
if self == Publisher.XNAS_NLS_FINN:
16781678
return "FINRA/Nasdaq TRF Carteret"
1679-
if self == Publisher.FINN_NLS_FINC:
1679+
if self == Publisher.XNAS_NLS_FINC:
16801680
return "FINRA/Nasdaq TRF Chicago"
1681-
if self == Publisher.FINY_TRADES_FINY:
1681+
if self == Publisher.XNYS_TRADES_FINY:
16821682
return "FINRA/NYSE TRF"
16831683
if self == Publisher.OPRA_PILLAR_AMXO:
16841684
return "OPRA - NYSE American"

databento/common/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
DBNRecord = Union[
12+
databento_dbn.CbboMsg,
1213
databento_dbn.MBOMsg,
1314
databento_dbn.MBP1Msg,
1415
databento_dbn.MBP10Msg,
@@ -18,6 +19,7 @@
1819
databento_dbn.InstrumentDefMsg,
1920
databento_dbn.InstrumentDefMsgV1,
2021
databento_dbn.StatMsg,
22+
databento_dbn.StatusMsg,
2123
databento_dbn.SymbolMappingMsg,
2224
databento_dbn.SymbolMappingMsgV1,
2325
databento_dbn.SystemMsg,

databento/live/protocol.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,24 @@ def __init__(
8080
)
8181
self._gateway_decoder = GatewayDecoder()
8282

83-
self._authenticated: asyncio.Future[int] = asyncio.Future()
83+
self._authenticated: asyncio.Future[str | None] = asyncio.Future()
8484
self._disconnected: asyncio.Future[None] = asyncio.Future()
85+
self._error_msgs: list[str] = []
8586
self._started: bool = False
8687

8788
@property
88-
def authenticated(self) -> asyncio.Future[int]:
89+
def authenticated(self) -> asyncio.Future[str | None]:
8990
"""
9091
Future that completes when authentication with the gateway is
9192
completed.
9293
93-
The result will contain the session id if successful.
94+
The result will contain the session ID if successful.
9495
The exception will contain a BentoError if authentication
9596
fails for any reason.
9697
9798
Returns
9899
-------
99-
asyncio.Future[int]
100+
asyncio.Future[str | None]
100101
101102
"""
102103
return self._authenticated
@@ -323,15 +324,22 @@ def _process_dbn(self, data: bytes) -> None:
323324
if isinstance(record, databento_dbn.Metadata):
324325
self.received_metadata(record)
325326
continue
326-
327327
if isinstance(record, databento_dbn.ErrorMsg):
328328
logger.error(
329329
"gateway error: %s",
330330
record.err,
331331
)
332-
self.disconnected.set_exception(
333-
BentoError(record.err),
334-
)
332+
self._error_msgs.append(record.err)
333+
if record.is_last:
334+
if len(self._error_msgs) > 1:
335+
errors = ", ".join(self._error_msgs)
336+
error_msg = f"The following errors occurred: {errors}"
337+
else:
338+
error_msg = self._error_msgs[-1]
339+
self._error_msgs.clear()
340+
self.disconnected.set_exception(
341+
BentoError(error_msg),
342+
)
335343
if isinstance(record, databento_dbn.SystemMsg):
336344
if record.is_heartbeat:
337345
logger.debug("gateway heartbeat")
@@ -391,10 +399,7 @@ def _(self, message: AuthenticationResponse) -> None:
391399
)
392400
self.transport.close()
393401
else:
394-
if message.session_id is None:
395-
session_id = 0
396-
else:
397-
session_id = int(message.session_id)
402+
session_id = message.session_id
398403

399404
logger.debug(
400405
"CRAM authenticated session id assigned `%s`",

databento/live/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,17 @@ def __init__(
281281

282282
self._user_gateway: str | None = user_gateway
283283
self._port = port
284-
self._session_id: int = 0
284+
self._session_id: str | None = None
285285

286286
@property
287-
def session_id(self) -> int:
287+
def session_id(self) -> str | None:
288288
"""
289-
Return the authenticated session ID. A zero value indicates no session
289+
Return the authenticated session ID. A None value indicates no session
290290
has started.
291291
292292
Returns
293293
-------
294-
int
294+
str | None
295295
296296
"""
297297
return self._session_id

databento/version.py

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

notebooks/quickstart.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"\n",
2828
"**Note:**\n",
2929
"\n",
30-
"For information on our symbology, refer to https://docs.databento.com/api-reference-historical/basics/symbology. \n",
30+
"For information on our symbology, refer to https://databento.com/docs/api-reference-historical/basics/symbology. \n",
3131
"\n",
32-
"For a more detailed API reference, refer to https://docs.databento.com/api-reference-historical.\n",
32+
"For a more detailed API reference, refer to https://databento.com/docs/api-reference-historical.\n",
3333
"\n",
3434
"This tutorial covers the following:\n",
3535
"- Using the historical client to request metadata\n",

0 commit comments

Comments
 (0)