Skip to content

Commit c42604a

Browse files
authored
VER: Release 0.12.0
See release notes.
2 parents 825b42c + f76ccf9 commit c42604a

40 files changed

+4457
-607
lines changed

CHANGELOG.md

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

3+
## 0.12.0 - 2023-05-01
4+
- Added `Live` client for connecting to Databento's live service
5+
- Upgraded `databento-dbn` to 0.5.0
6+
- Upgraded `DBNStore` to support mixed schema types to support live data
7+
- Changed iteration `DBNStore` to return record types from `databento-dbn` instead of numpy arrays
8+
- Removed `dtype` property from `DBNStore`
9+
- Removed `record_size` property from `DBNStore`
10+
- Renamed the `cost` field to `cost_usd` for `batch.submit_job` and `batch.list_jobs` (value now expressed as US dollars)
11+
- Removed `bad` condition variant from `batch.get_dataset_condition`
12+
- Added `degraded`, `pending` and `missing` condition variants for `batch.get_dataset_condition`
13+
- Added `last_modified_date` field to `batch.get_dataset_condition` response
14+
- Deprecated `SType.PRODUCT_ID` to `SType.INSTRUMENT_ID`
15+
- Deprecated `SType.NATIVE` to `SType.RAW_SYMBOL`
16+
- Deprecated `SType.SMART` to `SType.PARENT` and `SType.CONTINUOUS`
17+
- Removed unused `LiveGateway` enum
18+
- Removed `STATSTICS` from `Schema` enum
19+
- Removed `STATUS` from `Schema` enum
20+
- Removed `GATEWAY_ERROR` from `Schema` enum
21+
- Removed `SYMBOL_MAPPING` from `Schema` enum
22+
323
## 0.11.0 - 2023-04-13
424
- Changed `end` and `end_date` to optional to support new forward-fill behaviour
525
- Upgraded `zstandard` to 0.20.0

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/__init__.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
2+
import warnings
23

3-
from databento.common import utility
4+
from databento.common import bentologging
45
from databento.common.dbnstore import DBNStore
56
from databento.common.enums import (
67
Compression,
@@ -9,7 +10,6 @@
910
Encoding,
1011
FeedMode,
1112
HistoricalGateway,
12-
LiveGateway,
1313
Packaging,
1414
RecordFlags,
1515
RollRule,
@@ -26,12 +26,29 @@
2626
)
2727
from databento.historical.api import API_VERSION
2828
from databento.historical.client import Historical
29+
from databento.live.client import Live
30+
from databento.live.dbn import DBNRecord, DBNStruct
2931
from databento.version import __version__ # noqa
32+
from databento_dbn import (
33+
ErrorMsg,
34+
ImbalanceMsg,
35+
InstrumentDefMsg,
36+
MBOMsg,
37+
MBP1Msg,
38+
MBP10Msg,
39+
Metadata,
40+
OHLCVMsg,
41+
SymbolMappingMsg,
42+
SystemMsg,
43+
TradeMsg,
44+
)
3045

3146

3247
__all__ = [
3348
"API_VERSION",
3449
"DBNStore",
50+
"DBNRecord",
51+
"DBNStruct",
3552
"BentoClientError",
3653
"BentoError",
3754
"BentoHttpError",
@@ -44,18 +61,33 @@
4461
"RecordFlags",
4562
"Historical",
4663
"HistoricalGateway",
47-
"LiveGateway",
64+
"Live",
4865
"Packaging",
4966
"RollRule",
5067
"Schema",
5168
"SplitDuration",
5269
"SType",
5370
"SymbologyResolution",
71+
# DBN Record Types
72+
"Metadata",
73+
"MBOMsg",
74+
"MBP1Msg",
75+
"MBP10Msg",
76+
"TradeMsg",
77+
"OHLCVMsg",
78+
"InstrumentDefMsg",
79+
"ImbalanceMsg",
80+
"ErrorMsg",
81+
"SystemMsg",
82+
"SymbolMappingMsg",
5483
]
5584

5685
# Setup logging
5786
logging.getLogger(__name__).addHandler(logging.NullHandler())
5887

88+
# Setup deprecation warnings
89+
warnings.simplefilter("always", DeprecationWarning)
90+
5991
# Convenience imports
60-
enable_logging = utility.enable_logging
92+
enable_logging = bentologging.enable_logging
6193
from_dbn = DBNStore.from_file

databento/common/cram.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Functions for handling challenge-response authentication"""
2+
import argparse
3+
import hashlib
4+
import os
5+
import sys
6+
7+
8+
BUCKET_ID_LENGTH = 5
9+
10+
11+
def get_challenge_response(challenge: str, key: str) -> str:
12+
"""
13+
Return the response for a given challenge-response
14+
authentication mechanism (CRAM) code provided by
15+
a Databento service.
16+
17+
A valid API key is hashed with the challenge string.
18+
19+
Parameters
20+
----------
21+
challenge : str
22+
The CRAM challenge string.
23+
key : str
24+
The user API key for authentication.
25+
26+
Returns
27+
-------
28+
str
29+
30+
"""
31+
bucket_id = key[-BUCKET_ID_LENGTH:]
32+
sha = hashlib.sha256(f"{challenge}|{key}".encode("utf-8")).hexdigest()
33+
return f"{sha}-{bucket_id}"
34+
35+
36+
if __name__ == "__main__":
37+
parser = argparse.ArgumentParser(
38+
description="Script for computing a CRAM response.",
39+
)
40+
parser.add_argument(
41+
"challenge",
42+
help="The CRAM challenge string",
43+
)
44+
parser.add_argument(
45+
"key",
46+
nargs="?",
47+
default=os.environ.get("DATABENTO_API_KEY"),
48+
help="An API key; defaults to the value of DATABENTO_API_KEY if set",
49+
)
50+
arguments = parser.parse_args(sys.argv[1:])
51+
52+
if arguments.key is None:
53+
parser.print_usage()
54+
exit(1)
55+
56+
print(
57+
get_challenge_response(
58+
challenge=arguments.challenge,
59+
key=arguments.key,
60+
),
61+
)

databento/common/data.py

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
4040
("length", np.uint8),
4141
("rtype", np.uint8),
4242
("publisher_id", np.uint16),
43-
("product_id", np.uint32),
43+
("instrument_id", np.uint32),
4444
("ts_event", np.uint64),
4545
]
4646

@@ -78,14 +78,6 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
7878
("volume", np.int64),
7979
]
8080

81-
STATUS_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
82-
("ts_recv", np.uint64),
83-
("group", "S1"), # 1 byte chararray
84-
("trading_status", np.uint8),
85-
("halt_reason", np.uint8),
86-
("trading_event", np.uint8),
87-
]
88-
8981
DEFINITION_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
9082
("ts_recv", np.uint64),
9183
("min_price_increment", np.int64),
@@ -199,23 +191,11 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
199191
Schema.OHLCV_1M: OHLCV_MSG,
200192
Schema.OHLCV_1H: OHLCV_MSG,
201193
Schema.OHLCV_1D: OHLCV_MSG,
202-
Schema.STATUS: STATUS_MSG,
203194
Schema.DEFINITION: DEFINITION_MSG,
204195
Schema.IMBALANCE: IMBALANCE_MSG,
205-
Schema.GATEWAY_ERROR: RECORD_HEADER
206-
+ [
207-
("error", "S64"),
208-
],
209-
Schema.SYMBOL_MAPPING: RECORD_HEADER
210-
+ [
211-
("stype_in_symbol", "S22"),
212-
("stype_out_symbol", "S22"),
213-
("dummy", "S4"),
214-
("start_ts", np.uint64),
215-
("end_ts", np.uint64),
216-
],
217196
}
218197

198+
219199
DEFINITION_CHARARRAY_COLUMNS = [
220200
"currency",
221201
"settl_currency",
@@ -271,7 +251,7 @@ def get_deriv_ba_fields(level: int) -> List[str]:
271251
"ts_event",
272252
"ts_in_delta",
273253
"publisher_id",
274-
"product_id",
254+
"instrument_id",
275255
"action",
276256
"side",
277257
"depth",
@@ -283,15 +263,14 @@ def get_deriv_ba_fields(level: int) -> List[str]:
283263

284264
OHLCV_HEADER_COLUMNS = [
285265
"publisher_id",
286-
"product_id",
266+
"instrument_id",
287267
"open",
288268
"high",
289269
"low",
290270
"close",
291271
"volume",
292272
]
293273

294-
STATUS_DROP_COLUMNS = ["ts_recv"]
295274
DEFINITION_DROP_COLUMNS = [
296275
"ts_recv",
297276
"length",
@@ -309,10 +288,6 @@ def get_deriv_ba_fields(level: int) -> List[str]:
309288
"dummy",
310289
]
311290

312-
STATUS_COLUMNS = [
313-
x for x in (np.dtype(STATUS_MSG).names or ()) if x not in STATUS_DROP_COLUMNS
314-
]
315-
316291
DEFINITION_COLUMNS = [
317292
x
318293
for x in (np.dtype(DEFINITION_MSG).names or ())
@@ -323,14 +298,13 @@ def get_deriv_ba_fields(level: int) -> List[str]:
323298
x for x in (np.dtype(IMBALANCE_MSG).names or ()) if x not in IMBALANCE_DROP_COLUMNS
324299
]
325300

326-
327301
COLUMNS = {
328302
Schema.MBO: [
329303
"ts_event",
330304
"ts_in_delta",
331305
"publisher_id",
332306
"channel_id",
333-
"product_id",
307+
"instrument_id",
334308
"order_id",
335309
"action",
336310
"side",
@@ -357,7 +331,6 @@ def get_deriv_ba_fields(level: int) -> List[str]:
357331
Schema.OHLCV_1M: OHLCV_HEADER_COLUMNS,
358332
Schema.OHLCV_1H: OHLCV_HEADER_COLUMNS,
359333
Schema.OHLCV_1D: OHLCV_HEADER_COLUMNS,
360-
Schema.STATUS: STATUS_COLUMNS,
361334
Schema.DEFINITION: DEFINITION_COLUMNS,
362335
Schema.IMBALANCE: IMBALANCE_COLUMNS,
363336
}

0 commit comments

Comments
 (0)