Skip to content

Commit 4dac2b0

Browse files
committed
ADD: Python client basic reconnection
1 parent 0cdcda9 commit 4dac2b0

16 files changed

+1457
-864
lines changed

CHANGELOG.md

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

33
## 0.14.0 - TBD
4+
- Added support for reusing a `Live` client to reconnect
5+
- Changed iteration of `Live` to no longer yield DBN metadata
6+
- Changed `Live` callbacks to no longer yield DBN metadata
7+
- Added `metadata` property to `Live`
8+
- Added `DatatbentoLiveProtocol` class
49
- Upgraded `aiohttp` to 3.8.3
510
- Upgraded `numpy` to to 1.23.5
611
- Upgraded `pandas` to to 1.5.3

databento/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
)
2727
from databento.historical.api import API_VERSION
2828
from databento.historical.client import Historical
29+
from databento.live import DBNRecord
2930
from databento.live.client import Live
30-
from databento.live.dbn import DBNRecord, DBNStruct
3131
from databento.version import __version__ # noqa
3232
from databento_dbn import (
3333
ErrorMsg,
@@ -38,6 +38,7 @@
3838
MBP10Msg,
3939
Metadata,
4040
OHLCVMsg,
41+
StatMsg,
4142
SymbolMappingMsg,
4243
SystemMsg,
4344
TradeMsg,
@@ -48,7 +49,6 @@
4849
"API_VERSION",
4950
"DBNStore",
5051
"DBNRecord",
51-
"DBNStruct",
5252
"BentoClientError",
5353
"BentoError",
5454
"BentoHttpError",
@@ -75,6 +75,7 @@
7575
"MBP10Msg",
7676
"TradeMsg",
7777
"OHLCVMsg",
78+
"StatMsg",
7879
"InstrumentDefMsg",
7980
"ImbalanceMsg",
8081
"ErrorMsg",

databento/common/dbnstore.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Union,
1919
)
2020

21+
import databento_dbn
2122
import numpy as np
2223
import pandas as pd
2324
import zstandard
@@ -39,7 +40,7 @@
3940
from databento.common.error import BentoError
4041
from databento.common.symbology import InstrumentIdMappingInterval
4142
from databento.common.validation import validate_maybe_enum
42-
from databento.live.data import DBNStruct
43+
from databento.live import DBNRecord
4344

4445

4546
NON_SCHEMA_RECORD_TYPES = [
@@ -357,7 +358,7 @@ def __init__(self, data_source: DataSource) -> None:
357358
Dict[int, str],
358359
] = {}
359360

360-
def __iter__(self) -> Generator[DBNStruct, None, None]:
361+
def __iter__(self) -> Generator[DBNRecord, None, None]:
361362
reader = self.reader
362363
decoder = DBNDecoder()
363364
while True:
@@ -369,6 +370,8 @@ def __iter__(self) -> Generator[DBNStruct, None, None]:
369370
except ValueError:
370371
continue
371372
for record in records:
373+
if isinstance(record, databento_dbn.Metadata):
374+
continue
372375
yield record
373376
else:
374377
if len(decoder.buffer()) > 0:

databento/common/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from databento_dbn import StatMsg
1414
from databento_dbn import TradeMsg
1515

16-
from databento.live.dbn import DBNRecord
16+
from databento.live import DBNRecord
1717

1818

1919
M = TypeVar("M", bound=Enum)

databento/live/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import Union
2+
3+
import databento_dbn
4+
5+
6+
AUTH_TIMEOUT_SECONDS: float = 2
7+
CONNECT_TIMEOUT_SECONDS: float = 5
8+
9+
DBNRecord = Union[
10+
databento_dbn.MBOMsg,
11+
databento_dbn.MBP1Msg,
12+
databento_dbn.MBP10Msg,
13+
databento_dbn.TradeMsg,
14+
databento_dbn.OHLCVMsg,
15+
databento_dbn.ImbalanceMsg,
16+
databento_dbn.InstrumentDefMsg,
17+
databento_dbn.StatMsg,
18+
databento_dbn.SymbolMappingMsg,
19+
databento_dbn.SystemMsg,
20+
databento_dbn.ErrorMsg,
21+
]

0 commit comments

Comments
 (0)