Skip to content

Commit 7b6c7f6

Browse files
committed
MOD: Rename dataset_id to publisher_id
1 parent 4236756 commit 7b6c7f6

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

databento/common/data.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
3939
DBZ_COMMON_HEADER: List[Tuple[str, Union[type, str]]] = [
4040
("nwords", np.uint8),
4141
("type", np.uint8),
42-
("dataset_id", np.uint16),
42+
("publisher_id", np.uint16),
4343
("product_id", np.uint32),
4444
("ts_event", np.uint64),
4545
]
4646

4747

48-
DBZ_DERIV_TMUP: List[Tuple[str, Union[type, str]]] = [
48+
DBZ_MBP_MSG: List[Tuple[str, Union[type, str]]] = [
4949
("price", np.int64),
5050
("size", np.uint32),
5151
("action", "S1"), # 1 byte chararray
@@ -58,7 +58,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
5858
]
5959

6060

61-
DBZ_DERIV_OHLCV: List[Tuple[str, Union[type, str]]] = [
61+
DBZ_OHLCV_MSG: List[Tuple[str, Union[type, str]]] = [
6262
("open", np.int64),
6363
("high", np.int64),
6464
("low", np.int64),
@@ -81,9 +81,9 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
8181
("ts_in_delta", np.int32),
8282
("sequence", np.uint32),
8383
],
84-
Schema.MBP_1: DBZ_COMMON_HEADER + DBZ_DERIV_TMUP + get_deriv_ba_types(0), # 1
84+
Schema.MBP_1: DBZ_COMMON_HEADER + DBZ_MBP_MSG + get_deriv_ba_types(0), # 1
8585
Schema.MBP_10: DBZ_COMMON_HEADER
86-
+ DBZ_DERIV_TMUP
86+
+ DBZ_MBP_MSG
8787
+ get_deriv_ba_types(0) # 1
8888
+ get_deriv_ba_types(1) # 2
8989
+ get_deriv_ba_types(2) # 3
@@ -94,12 +94,12 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
9494
+ get_deriv_ba_types(7) # 8
9595
+ get_deriv_ba_types(8) # 9
9696
+ get_deriv_ba_types(9), # 10
97-
Schema.TBBO: DBZ_COMMON_HEADER + DBZ_DERIV_TMUP + get_deriv_ba_types(0),
98-
Schema.TRADES: DBZ_COMMON_HEADER + DBZ_DERIV_TMUP,
99-
Schema.OHLCV_1S: DBZ_COMMON_HEADER + DBZ_DERIV_OHLCV,
100-
Schema.OHLCV_1M: DBZ_COMMON_HEADER + DBZ_DERIV_OHLCV,
101-
Schema.OHLCV_1H: DBZ_COMMON_HEADER + DBZ_DERIV_OHLCV,
102-
Schema.OHLCV_1D: DBZ_COMMON_HEADER + DBZ_DERIV_OHLCV,
97+
Schema.TBBO: DBZ_COMMON_HEADER + DBZ_MBP_MSG + get_deriv_ba_types(0),
98+
Schema.TRADES: DBZ_COMMON_HEADER + DBZ_MBP_MSG,
99+
Schema.OHLCV_1S: DBZ_COMMON_HEADER + DBZ_OHLCV_MSG,
100+
Schema.OHLCV_1M: DBZ_COMMON_HEADER + DBZ_OHLCV_MSG,
101+
Schema.OHLCV_1H: DBZ_COMMON_HEADER + DBZ_OHLCV_MSG,
102+
Schema.OHLCV_1D: DBZ_COMMON_HEADER + DBZ_OHLCV_MSG,
103103
Schema.STATUS: DBZ_COMMON_HEADER
104104
+ [
105105
("ts_recv", np.uint64),
@@ -194,7 +194,7 @@ def get_deriv_ba_fields(level: int) -> List[str]:
194194
DBZ_DERIV_HEADER_FIELDS = [
195195
"ts_event",
196196
"ts_in_delta",
197-
"dataset_id",
197+
"publisher_id",
198198
"product_id",
199199
"action",
200200
"side",
@@ -208,7 +208,7 @@ def get_deriv_ba_fields(level: int) -> List[str]:
208208
Schema.MBO: [
209209
"ts_event",
210210
"ts_in_delta",
211-
"dataset_id",
211+
"publisher_id",
212212
"product_id",
213213
"order_id",
214214
"action",
@@ -239,12 +239,12 @@ def get_deriv_ba_fields(level: int) -> List[str]:
239239
# CSV headers
240240
################################################################################
241241

242-
CSV_DERIV_HEADER = b"ts_recv,ts_event,ts_in_delta,dataset_id,product_id,action,side,flags,price,size,sequence" # noqa
243-
CSV_OHLCV_HEADER = b"ts_event,dataset_id,product_id,open,high,low,close,volume"
242+
CSV_DERIV_HEADER = b"ts_recv,ts_event,ts_in_delta,publisher_id,product_id,action,side,flags,price,size,sequence" # noqa
243+
CSV_OHLCV_HEADER = b"ts_event,publisher_id,product_id,open,high,low,close,volume"
244244

245245

246246
CSV_HEADERS = {
247-
Schema.MBO: b"ts_recv,ts_event,ts_in_delta,dataset_id,product_id,order_id,action,side,flags,price,size,sequence", # noqa
247+
Schema.MBO: b"ts_recv,ts_event,ts_in_delta,publisher_id,product_id,order_id,action,side,flags,price,size,sequence", # noqa
248248
Schema.MBP_1: CSV_DERIV_HEADER + b"," + ",".join(get_deriv_ba_fields(0)).encode(),
249249
Schema.MBP_10: CSV_DERIV_HEADER
250250
+ b","

notebooks/quickstart.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"{'GLBX.MDP3': {'csv': {'trades': {'ts_recv': 'int',\n",
160160
" 'ts_event': 'int',\n",
161161
" 'ts_in_delta': 'int',\n",
162-
" 'dataset_id': 'int',\n",
162+
" 'publisher_id': 'int',\n",
163163
" 'product_id': 'int',\n",
164164
" 'action': 'string',\n",
165165
" 'side': 'string',\n",
@@ -620,7 +620,7 @@
620620
{
621621
"data": {
622622
"text/plain": [
623-
"dtype([('nwords', 'u1'), ('type', 'u1'), ('dataset_id', '<u2'), ('product_id', '<u4'), ('ts_event', '<u8'), ('order_id', '<u8'), ('price', '<i8'), ('size', '<u4'), ('flags', 'i1'), ('channel_id', 'u1'), ('action', 'S1'), ('side', 'S1'), ('ts_recv', '<u8'), ('ts_in_delta', '<i4'), ('sequence', '<u4')])"
623+
"dtype([('nwords', 'u1'), ('type', 'u1'), ('publisher_id', '<u2'), ('product_id', '<u4'), ('ts_event', '<u8'), ('order_id', '<u8'), ('price', '<i8'), ('size', '<u4'), ('flags', 'i1'), ('channel_id', 'u1'), ('action', 'S1'), ('side', 'S1'), ('ts_recv', '<u8'), ('ts_in_delta', '<i4'), ('sequence', '<u4')])"
624624
]
625625
},
626626
"execution_count": 32,
@@ -807,7 +807,7 @@
807807
" <th></th>\n",
808808
" <th>ts_event</th>\n",
809809
" <th>ts_in_delta</th>\n",
810-
" <th>dataset_id</th>\n",
810+
" <th>publisher_id</th>\n",
811811
" <th>product_id</th>\n",
812812
" <th>order_id</th>\n",
813813
" <th>action</th>\n",
@@ -1141,7 +1141,7 @@
11411141
"2020-12-27 20:00:25.252346963+00:00 2020-12-27 20:00:25.061045683+00:00 \n",
11421142
"2020-12-27 20:00:25.252346963+00:00 2020-12-27 20:00:25.061045683+00:00 \n",
11431143
"\n",
1144-
" ts_in_delta dataset_id product_id \\\n",
1144+
" ts_in_delta publisher_id product_id \\\n",
11451145
"ts_recv \n",
11461146
"2020-12-27 20:00:25.252293395+00:00 26179 1 5482 \n",
11471147
"2020-12-27 20:00:25.252293395+00:00 26179 1 5482 \n",
@@ -1251,7 +1251,7 @@
12511251
" (14, 32, 1, 5482, 1609099225061045683, 647570749727, 321025000000000, 1, 0, 0, b'B', b'A', 1609099225250461359, 92701, 1098),\n",
12521252
" (14, 32, 1, 5482, 1609099225061045683, 647570749776, 320925000000000, 1, 0, 0, b'B', b'A', 1609099225250461359, 92701, 1098),\n",
12531253
" (14, 32, 1, 5482, 1609099225061045683, 647570749868, 320825000000000, 1, 0, 0, b'B', b'A', 1609099225250461359, 92701, 1098)],\n",
1254-
" dtype=[('nwords', 'u1'), ('type', 'u1'), ('dataset_id', '<u2'), ('product_id', '<u4'), ('ts_event', '<u8'), ('order_id', '<u8'), ('price', '<i8'), ('size', '<u4'), ('flags', 'i1'), ('channel_id', 'u1'), ('action', 'S1'), ('side', 'S1'), ('ts_recv', '<u8'), ('ts_in_delta', '<i4'), ('sequence', '<u4')])"
1254+
" dtype=[('nwords', 'u1'), ('type', 'u1'), ('publisher_id', '<u2'), ('product_id', '<u4'), ('ts_event', '<u8'), ('order_id', '<u8'), ('price', '<i8'), ('size', '<u4'), ('flags', 'i1'), ('channel_id', 'u1'), ('action', 'S1'), ('side', 'S1'), ('ts_recv', '<u8'), ('ts_in_delta', '<i4'), ('sequence', '<u4')])"
12551255
]
12561256
},
12571257
"execution_count": 31,

tests/test_historical_bento.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_bento_given_initial_nbytes_returns_expected_metadata(self) -> None:
8383
[
8484
("nwords", "u1"),
8585
("type", "u1"),
86-
("dataset_id", "<u2"),
86+
("publisher_id", "<u2"),
8787
("product_id", "<u4"),
8888
("ts_event", "<u8"),
8989
("order_id", "<u8"),
@@ -224,7 +224,7 @@ def test_to_df_with_mbo_data_returns_expected_record(self) -> None:
224224
assert df.index.name == "ts_recv"
225225
assert df.index.values[0] == 1609160400000704060
226226
assert df.iloc[0].ts_event == 1609160400000429831
227-
assert df.iloc[0].dataset_id == 1
227+
assert df.iloc[0].publisher_id == 1
228228
assert df.iloc[0].product_id == 5482
229229
assert df.iloc[0].order_id == 647784973705
230230
assert df.iloc[0].action == "A" # TODO(cs): Invalid until data regenerated
@@ -365,7 +365,7 @@ def test_to_csv_writes_expected_file_to_disk(self) -> None:
365365
written = open(path, mode="rb").read()
366366
assert os.path.isfile(path)
367367
expected = (
368-
b"ts_recv,ts_event,ts_in_delta,dataset_id,product_id,order_id,action,side,flags,pr" # noqa
368+
b"ts_recv,ts_event,ts_in_delta,publisher_id,product_id,order_id,action,side,flags,pr" # noqa
369369
b"ice,size,sequence\n1609160400000704060,1609160400000429831,22993,1,5482,6" # noqa
370370
b"47784973705,A,C,128,372275000000000,1,1170352\n1609160400000711344,160916" # noqa
371371
b"0400000431665,19621,1,5482,647784973631,A,C,128,372300000000000,1,1170353\n" # noqa
@@ -391,10 +391,10 @@ def test_to_json_writes_expected_file_to_disk(self) -> None:
391391
written = open(path, mode="rb").read()
392392
assert os.path.isfile(path)
393393
assert written == (
394-
b'{"ts_event":1609160400000429831,"ts_in_delta":22993,"dataset_id":1,"product_id":' # noqa
394+
b'{"ts_event":1609160400000429831,"ts_in_delta":22993,"publisher_id":1,"product_id":' # noqa
395395
b'5482,"order_id":647784973705,"action":"A","side":"C","flags":128,"price":372' # noqa
396396
b'275000000000,"size":1,"sequence":1170352}\n{"ts_event":160916040000043166' # noqa
397-
b'5,"ts_in_delta":19621,"dataset_id":1,"product_id":5482,"order_id":647784973631,"' # noqa
397+
b'5,"ts_in_delta":19621,"publisher_id":1,"product_id":5482,"order_id":647784973631,"' # noqa
398398
b'action":"A","side":"C","flags":128,"price":372300000000000,"size":1,"sequenc' # noqa
399399
b'e":1170353}\n'
400400
)

0 commit comments

Comments
 (0)