Skip to content

Commit a5e6c23

Browse files
committed
ADD: Add Py client batch.submit_job map_symbols
1 parent 8f9de0b commit a5e6c23

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

databento/common/dbnstore.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def to_csv(
847847
prices are replaced with an empty string.
848848
map_symbols : bool, default True
849849
If symbology mappings from the metadata should be used to create
850-
a 'symbol' column, mapping the instrument ID to its native symbol for
850+
a 'symbol' column, mapping the instrument ID to its requested symbol for
851851
every record.
852852
schema : Schema or str, optional
853853
The schema for the csv.
@@ -922,7 +922,7 @@ def to_df(
922922
prices are replaced with NaN.
923923
map_symbols : bool, default True
924924
If symbology mappings from the metadata should be used to create
925-
a 'symbol' column, mapping the instrument ID to its native symbol for
925+
a 'symbol' column, mapping the instrument ID to its requested symbol for
926926
every record.
927927
schema : Schema or str, optional
928928
The schema for the dataframe.
@@ -1020,7 +1020,7 @@ def to_json(
10201020
the correct scale (using the fixed precision scalar 1e-9).
10211021
map_symbols : bool, default True
10221022
If symbology mappings from the metadata should be used to create
1023-
a 'symbol' column, mapping the instrument ID to its native symbol for
1023+
a 'symbol' column, mapping the instrument ID to its requested symbol for
10241024
every record.
10251025
schema : Schema or str, optional
10261026
The schema for the json.

databento/historical/api/batch.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def submit_job(
5454
end: pd.Timestamp | date | str | int | None = None,
5555
encoding: Encoding | str = "dbn",
5656
compression: Compression | str = "zstd",
57+
map_symbols: bool = False,
5758
split_duration: SplitDuration | str = "day",
5859
split_size: int | None = None,
5960
packaging: Packaging | str | None = None,
@@ -91,6 +92,9 @@ def submit_job(
9192
The data encoding.
9293
compression : Compression or str {'none', 'zstd'}, default 'zstd'
9394
The data compression format (if any).
95+
map_symbols : bool, default False
96+
If the raw symbol should be appended to every text encoded record.
97+
Must be requested with either 'csv' or 'json' encoding.
9498
split_duration : SplitDuration or str {'day', 'week', 'month', 'none'}, default 'day'
9599
The maximum time duration before batched data is split into multiple files.
96100
A week starts on Sunday UTC.
@@ -131,7 +135,10 @@ def submit_job(
131135
"compression": str(validate_enum(compression, Compression, "compression"))
132136
if compression
133137
else None,
134-
"split_duration": str(validate_enum(split_duration, SplitDuration, "split_duration")),
138+
"map_symbols": map_symbols,
139+
"split_duration": str(
140+
validate_enum(split_duration, SplitDuration, "split_duration"),
141+
),
135142
"packaging": str(validate_enum(packaging, Packaging, "packaging"))
136143
if packaging
137144
else None,

tests/test_historical_batch.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def test_batch_submit_job_sends_expected_request(
7777

7878
# Assert
7979
call = mocked_post.call_args.kwargs
80-
assert call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.submit_job"
80+
assert (
81+
call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.submit_job"
82+
)
8183
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
8284
assert call["headers"]["accept"] == "application/json"
8385
assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/"))
@@ -91,6 +93,7 @@ def test_batch_submit_job_sends_expected_request(
9193
"stype_out": "instrument_id",
9294
"encoding": "csv",
9395
"compression": "zstd",
96+
"map_symbols": False,
9497
"split_duration": "day",
9598
"packaging": "none",
9699
"delivery": "download",
@@ -112,7 +115,9 @@ def test_batch_list_jobs_sends_expected_request(
112115

113116
# Assert
114117
call = mocked_get.call_args.kwargs
115-
assert call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_jobs"
118+
assert (
119+
call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_jobs"
120+
)
116121
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
117122
assert call["headers"]["accept"] == "application/json"
118123
assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/"))
@@ -137,7 +142,9 @@ def test_batch_list_files_sends_expected_request(
137142

138143
# Assert
139144
call = mocked_get.call_args.kwargs
140-
assert call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_files"
145+
assert (
146+
call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_files"
147+
)
141148
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
142149
assert call["headers"]["accept"] == "application/json"
143150
assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/"))
@@ -168,7 +175,9 @@ def test_batch_download_single_file_sends_expected_request(
168175

169176
# Assert
170177
call = mocked_get.call_args.kwargs
171-
assert call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_files"
178+
assert (
179+
call["url"] == f"{historical_client.gateway}/v{db.API_VERSION}/batch.list_files"
180+
)
172181
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
173182
assert call["headers"]["accept"] == "application/json"
174183
assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/"))

0 commit comments

Comments
 (0)