Skip to content

Commit fc63f9d

Browse files
committed
MOD: Update InstrumentDefMsg
1 parent 1aae8df commit fc63f9d

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Removed `metadata.list_compressions` (redundant with docs)
66
- Removed `metadata.list_encodings` (redundant with docs)
77
- Removed optional `start` and `end` params from `metadata.list_schemas` (redundant)
8+
- Removed `related` and `related_security_id` from definition schema
9+
- Added `instrument_class`, `strike_price`, and `strike_price_currency` to definition
10+
schema
811

912
## 0.9.0 - 2023-03-10
1013
- Removed `record_count` property from Bento class

databento/common/data.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
114114
("contract_multiplier", np.int32),
115115
("decay_quantity", np.int32),
116116
("original_contract_size", np.int32),
117-
("related_security_id", np.uint32),
117+
("reserved1", "S4"),
118118
("trading_reference_date", np.uint16),
119119
("appl_id", np.int16),
120120
("maturity_year", np.uint16),
@@ -131,7 +131,11 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
131131
("security_type", "S7"), # 7 byte chararray
132132
("unit_of_measure", "S31"), # 31 byte chararray
133133
("underlying", "S21"), # 21 byte chararray
134-
("related", "S21"), # 21 byte chararray
134+
("strike_price_currency", "S4"),
135+
("instrument_class", "S1"),
136+
("reserved2", "S2"),
137+
("strike_price", np.int64),
138+
("reserved3", "S6"),
135139
("match_algorithm", "S1"), # 1 byte chararray
136140
("md_security_trading_status", np.uint8),
137141
("main_fraction", np.uint8),
@@ -199,10 +203,10 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
199203
"security_type",
200204
"unit_of_measure",
201205
"underlying",
202-
"related",
203206
"match_algorithm",
204207
"security_update_action",
205208
"user_defined_instrument",
209+
"strike_price_currency",
206210
]
207211

208212
DEFINITION_PRICE_COLUMNS = [
@@ -213,6 +217,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
213217
"max_price_variation",
214218
"trading_reference_price",
215219
"min_price_increment_amount",
220+
"strike_price",
216221
]
217222

218223
DEFINITION_TYPE_MAX_MAP = {
@@ -261,14 +266,26 @@ def get_deriv_ba_fields(level: int) -> List[str]:
261266
"volume",
262267
]
263268

264-
STATUS_COLUMNS = [x for x in np.dtype(STATUS_MSG).names or ()]
265-
STATUS_COLUMNS.remove("ts_recv") # Index
269+
STATUS_DROP_COLUMNS = ["ts_recv"]
270+
DEFINITION_DROP_COLUMNS = [
271+
"ts_recv",
272+
"length",
273+
"rtype",
274+
"reserved1",
275+
"reserved2",
276+
"reserved3",
277+
"dummy",
278+
]
279+
280+
STATUS_COLUMNS = [
281+
x for x in (np.dtype(STATUS_MSG).names or ()) if x not in STATUS_DROP_COLUMNS
282+
]
266283

267-
DEFINITION_COLUMNS = [x for x in np.dtype(DEFINITION_MSG).names or ()]
268-
DEFINITION_COLUMNS.remove("ts_recv") # Index
269-
DEFINITION_COLUMNS.remove("length")
270-
DEFINITION_COLUMNS.remove("rtype")
271-
DEFINITION_COLUMNS.remove("dummy")
284+
DEFINITION_COLUMNS = [
285+
x
286+
for x in (np.dtype(DEFINITION_MSG).names or ())
287+
if x not in DEFINITION_DROP_COLUMNS
288+
]
272289

273290

274291
COLUMNS = {

tests/test_historical_bento.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pandas as pd
1010
import pytest
1111
import zstandard
12+
from databento.common.data import DEFINITION_DROP_COLUMNS
1213
from databento.common.dbnstore import DBNStore
1314
from databento.common.enums import Schema, SType
1415
from databento.historical.error import BentoError
@@ -287,7 +288,7 @@ def test_to_df_drop_columns(
287288
schema: Schema,
288289
) -> None:
289290
"""
290-
Test that rtype, length, and dummy columns are dropped when
291+
Test that rtype, length, reserved, and dummy columns are dropped when
291292
calling to_df().
292293
"""
293294
# Arrange
@@ -298,9 +299,8 @@ def test_to_df_drop_columns(
298299
df = data.to_df()
299300

300301
# Assert
301-
assert "length" not in df
302-
assert "rtype" not in df
303-
assert "dummy" not in df
302+
for col in DEFINITION_DROP_COLUMNS:
303+
assert col not in df.columns
304304

305305

306306
def test_to_df_with_mbo_data_returns_expected_record(

0 commit comments

Comments
 (0)