Skip to content

Commit 4ae0c49

Browse files
committed
MOD: Make forward-fill and end param consistent
1 parent 1399ed1 commit 4ae0c49

File tree

6 files changed

+71
-41
lines changed

6 files changed

+71
-41
lines changed

CHANGELOG.md

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

3+
## 0.11.0 - TBD
4+
- Changed `end` and `end_date` to optional to support new forward-fill behaviour
5+
36
## 0.10.0 - 2023-04-07
47
- Upgraded `databento-dbn` to 0.4.3
58
- Renamed `Bento` class to `DBNStore`

databento/historical/api/batch.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def __init__(self, key: str, gateway: str) -> None:
5555
def submit_job(
5656
self,
5757
dataset: Union[Dataset, str],
58-
start: Union[pd.Timestamp, date, str, int],
59-
end: Union[pd.Timestamp, date, str, int],
6058
symbols: Optional[Union[List[str], str]],
6159
schema: Union[Schema, str],
60+
start: Union[pd.Timestamp, date, str, int],
61+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
6262
encoding: Union[Encoding, str] = "dbn",
6363
compression: Optional[Union[Compression, str]] = "zstd",
6464
split_duration: Union[SplitDuration, str] = "day",
@@ -78,20 +78,22 @@ def submit_job(
7878
----------
7979
dataset : Dataset or str
8080
The dataset code (string identifier) for the request.
81+
symbols : List[Union[str, int]] or str
82+
The product symbols to filter for. Takes up to 2,000 symbols per request.
83+
If more than 1 symbol is specified, the data is merged and sorted by time.
84+
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
85+
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
86+
The data record schema for the request.
8187
start : pd.Timestamp or date or str or int
8288
The start datetime of the request time range (inclusive).
8389
Assumes UTC as timezone unless passed a tz-aware object.
8490
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
85-
end : pd.Timestamp or date or str or int
91+
end : pd.Timestamp or date or str or int, optional
8692
The end datetime of the request time range (exclusive).
8793
Assumes UTC as timezone unless passed a tz-aware object.
8894
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
89-
symbols : List[Union[str, int]] or str
90-
The product symbols to filter for. Takes up to 2,000 symbols per request.
91-
If more than 1 symbol is specified, the data is merged and sorted by time.
92-
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
93-
schema : Schema or str {'mbo', 'mbp-1', 'mbp-10', 'trades', 'tbbo', 'ohlcv-1s', 'ohlcv-1m', 'ohlcv-1h', 'ohlcv-1d', 'definition', 'statistics', 'status'}, default 'trades' # noqa
94-
The data record schema for the request.
95+
Values are forward filled based on the resolution provided.
96+
Defaults to the same value as `start`.
9597
encoding : Encoding or str {'dbn', 'csv', 'json'}, default 'dbn'
9698
The data encoding.
9799
compression : Compression or str {'none', 'zstd'}, default 'zstd'

databento/historical/api/metadata.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def get_record_count(
273273
self,
274274
dataset: Union[Dataset, str],
275275
start: Union[pd.Timestamp, date, str, int],
276-
end: Union[pd.Timestamp, date, str, int],
276+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
277277
symbols: Optional[Union[List[str], str]] = None,
278278
schema: Union[Schema, str] = "trades",
279279
stype_in: Optional[Union[SType, str]] = "native",
@@ -289,11 +289,15 @@ def get_record_count(
289289
dataset : Dataset or str
290290
The dataset code for the request.
291291
start : pd.Timestamp or date or str or int
292-
The start datetime for the request range. Assumes UTC as timezone unless otherwise specified.
292+
The start datetime for the request range (inclusive).
293+
Assumes UTC as timezone unless otherwise specified.
293294
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
294-
end : pd.Timestamp or date or str or int
295-
The end datetime for the request range. Assumes UTC as timezone unless otherwise specified.
295+
end : pd.Timestamp or date or str or int, optional
296+
The end datetime for the request range (exclusive).
297+
Assumes UTC as timezone unless otherwise specified.
296298
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
299+
Values are forward filled based on the resolution provided.
300+
Defaults to the same value as `start`.
297301
symbols : List[Union[str, int]] or str, optional
298302
The product symbols to filter for. Takes up to 2,000 symbols per request.
299303
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
@@ -337,7 +341,7 @@ def get_billable_size(
337341
self,
338342
dataset: Union[Dataset, str],
339343
start: Union[pd.Timestamp, date, str, int],
340-
end: Union[pd.Timestamp, date, str, int],
344+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
341345
symbols: Optional[Union[List[str], str]] = None,
342346
schema: Union[Schema, str] = "trades",
343347
stype_in: Optional[Union[SType, str]] = "native",
@@ -353,12 +357,16 @@ def get_billable_size(
353357
----------
354358
dataset : Dataset or str
355359
The dataset code for the request.
356-
start : pd.Timestamp or date or str or int, optional
357-
The start datetime for the request range. Assumes UTC as timezone unless otherwise specified.
360+
start : pd.Timestamp or date or str or int
361+
The start datetime for the request range (inclusive).
362+
Assumes UTC as timezone unless otherwise specified.
358363
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
359364
end : pd.Timestamp or date or str or int, optional
360-
The end datetime for the request range. Assumes UTC as timezone unless otherwise specified.
365+
The end datetime for the request range (exclusive).
366+
Assumes UTC as timezone unless otherwise specified.
361367
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
368+
Values are forward filled based on the resolution provided.
369+
Defaults to the same value as `start`.
362370
symbols : List[Union[str, int]] or str, optional
363371
The product symbols to filter for. Takes up to 2,000 symbols per request.
364372
If 'ALL_SYMBOLS' or `None` then will be for **all** symbols.
@@ -380,7 +388,7 @@ def get_billable_size(
380388
params: List[Tuple[str, Optional[str]]] = [
381389
("dataset", validate_semantic_string(dataset, "dataset")),
382390
("start", datetime_to_string(start)),
383-
("end", datetime_to_string(end)),
391+
("end", optional_datetime_to_string(end)),
384392
("symbols", symbols_list),
385393
("schema", str(validate_enum(schema, Schema, "schema"))),
386394
("stype_in", str(stype_in_valid)),
@@ -402,7 +410,7 @@ def get_cost(
402410
self,
403411
dataset: Union[Dataset, str],
404412
start: Union[pd.Timestamp, date, str, int],
405-
end: Union[pd.Timestamp, date, str, int],
413+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
406414
mode: Union[FeedMode, str] = "historical-streaming",
407415
symbols: Optional[Union[List[str], str]] = None,
408416
schema: Union[Schema, str] = "trades",
@@ -420,11 +428,15 @@ def get_cost(
420428
dataset : Dataset or str
421429
The dataset code for the request.
422430
start : pd.Timestamp or date or str or int
423-
The start datetime for the request range. Assumes UTC as timezone unless otherwise specified.
431+
The start datetime for the request range (inclusive).
432+
Assumes UTC as timezone unless otherwise specified.
424433
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
425-
end : pd.Timestamp or date or str or int
426-
The end datetime for the request range. Assumes UTC as timezone unless otherwise specified.
434+
end : pd.Timestamp or date or str or int, optional
435+
The end datetime for the request range (exclusive).
436+
Assumes UTC as timezone unless otherwise specified.
427437
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
438+
Values are forward filled based on the resolution provided.
439+
Defaults to the same value as `start`.
428440
mode : FeedMode or str {'live', 'historical-streaming', 'historical'}, default 'historical-streaming'
429441
The data feed mode for the request.
430442
symbols : List[Union[str, int]] or str, optional
@@ -445,10 +457,10 @@ def get_cost(
445457
"""
446458
stype_in_valid = validate_enum(stype_in, SType, "stype_in")
447459
symbols_list = optional_symbols_list_to_string(symbols, stype_in_valid)
448-
params: List[Tuple[str, str]] = [
460+
params: List[Tuple[str, Optional[str]]] = [
449461
("dataset", validate_semantic_string(dataset, "dataset")),
450462
("start", datetime_to_string(start)),
451-
("end", datetime_to_string(end)),
463+
("end", optional_datetime_to_string(end)),
452464
("symbols", symbols_list),
453465
("schema", str(validate_enum(schema, Schema, "schema"))),
454466
("stype_in", str(stype_in_valid)),

databento/historical/api/symbology.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from databento.common.enums import SType
55
from databento.common.parsing import (
66
datetime_to_date_string,
7+
optional_date_to_string,
78
optional_symbols_list_to_string,
89
)
910
from databento.common.validation import validate_enum, validate_semantic_string
@@ -28,7 +29,7 @@ def resolve(
2829
stype_in: Union[SType, str],
2930
stype_out: Union[SType, str],
3031
start_date: Union[date, str],
31-
end_date: Union[date, str],
32+
end_date: Optional[Union[date, str]] = None,
3233
default_value: Optional[str] = "",
3334
) -> Dict[str, Any]:
3435
"""
@@ -48,7 +49,7 @@ def resolve(
4849
The output symbology type to resolve to.
4950
start_date : date or str
5051
The start date (UTC) of the request time range (inclusive).
51-
end_date : date or str
52+
end_date : date or str, optional
5253
The end date (UTC) of the request time range (exclusive).
5354
default_value : str, default '' (empty string)
5455
The default value to return if a symbol cannot be resolved.
@@ -68,7 +69,7 @@ def resolve(
6869
("stype_in", str(stype_in_valid)),
6970
("stype_out", str(validate_enum(stype_out, SType, "stype_out"))),
7071
("start_date", datetime_to_date_string(start_date)),
71-
("end_date", datetime_to_date_string(end_date)),
72+
("end_date", optional_date_to_string(end_date)),
7273
("default_value", default_value),
7374
]
7475

databento/historical/api/timeseries.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
from databento.common.deprecated import deprecated
1212
from databento.common.enums import Compression, Dataset, Encoding, Schema, SType
1313
from databento.common.error import BentoWarning
14-
from databento.common.parsing import datetime_to_string, optional_symbols_list_to_string
14+
from databento.common.parsing import (
15+
datetime_to_string,
16+
optional_datetime_to_string,
17+
optional_symbols_list_to_string,
18+
)
1519
from databento.common.validation import validate_enum, validate_semantic_string
1620
from databento.historical.api import API_VERSION
1721
from databento.historical.http import BentoHttpAPI
@@ -31,7 +35,7 @@ def stream(
3135
self,
3236
dataset: Union[Dataset, str],
3337
start: Union[pd.Timestamp, date, str, int],
34-
end: Union[pd.Timestamp, date, str, int],
38+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
3539
symbols: Optional[Union[List[str], str]] = None,
3640
schema: Union[Schema, str] = "trades",
3741
stype_in: Union[SType, str] = "native",
@@ -59,7 +63,7 @@ def get_range(
5963
self,
6064
dataset: Union[Dataset, str],
6165
start: Union[pd.Timestamp, date, str, int],
62-
end: Union[pd.Timestamp, date, str, int],
66+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
6367
symbols: Optional[Union[List[str], str]] = None,
6468
schema: Union[Schema, str] = "trades",
6569
stype_in: Union[SType, str] = "native",
@@ -83,11 +87,15 @@ def get_range(
8387
dataset : Dataset or str
8488
The dataset code (string identifier) for the request.
8589
start : pd.Timestamp or date or str or int
86-
The start datetime (UTC) of the request time range (inclusive).
90+
The start datetime of the request time range (inclusive).
91+
Assumes UTC as timezone unless passed a tz-aware object.
8792
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
88-
end : pd.Timestamp or date or str or int
89-
The end datetime (UTC) of the request time range (exclusive).
93+
end : pd.Timestamp or date or str or int, optional
94+
The end datetime of the request time range (exclusive).
95+
Assumes UTC as timezone unless passed a tz-aware object.
9096
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
97+
Values are forward filled based on the resolution provided.
98+
Defaults to the same value as `start`.
9199
symbols : List[Union[str, int]] or str, optional
92100
The product symbols to filter for. Takes up to 2,000 symbols per request.
93101
If more than 1 symbol is specified, the data is merged and sorted by time.
@@ -122,7 +130,7 @@ def get_range(
122130
params: List[Tuple[str, Optional[str]]] = [
123131
("dataset", validate_semantic_string(dataset, "dataset")),
124132
("start", datetime_to_string(start)),
125-
("end", datetime_to_string(end)),
133+
("end", optional_datetime_to_string(end)),
126134
("symbols", symbols_list),
127135
("schema", str(schema_valid)),
128136
("stype_in", str(stype_in_valid)),
@@ -166,7 +174,7 @@ async def stream_async(
166174
self,
167175
dataset: Union[Dataset, str],
168176
start: Union[pd.Timestamp, date, str, int],
169-
end: Union[pd.Timestamp, date, str, int],
177+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
170178
symbols: Optional[Union[List[str], str]] = None,
171179
schema: Union[Schema, str] = "trades",
172180
stype_in: Union[SType, str] = "native",
@@ -195,7 +203,7 @@ async def get_range_async(
195203
self,
196204
dataset: Union[Dataset, str],
197205
start: Union[pd.Timestamp, date, str, int],
198-
end: Union[pd.Timestamp, date, str, int],
206+
end: Optional[Union[pd.Timestamp, date, str, int]] = None,
199207
symbols: Optional[Union[List[str], str]] = None,
200208
schema: Union[Schema, str] = "trades",
201209
stype_in: Union[SType, str] = "native",
@@ -219,11 +227,15 @@ async def get_range_async(
219227
dataset : Dataset or str
220228
The dataset code (string identifier) for the request.
221229
start : pd.Timestamp or date or str or int
222-
The start datetime (UTC) of the request time range (inclusive).
230+
The start datetime of the request time range (inclusive).
231+
Assumes UTC as timezone unless passed a tz-aware object.
223232
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
224-
end : pd.Timestamp or date or str or int
225-
The end datetime (UTC) of the request time range (exclusive).
233+
end : pd.Timestamp or date or str or int, optional
234+
The end datetime of the request time range (exclusive).
235+
Assumes UTC as timezone unless passed a tz-aware object.
226236
If an integer is passed, then this represents nanoseconds since the UNIX epoch.
237+
Values are forward filled based on the resolution provided.
238+
Defaults to the same value as `start`.
227239
symbols : List[Union[str, int]] or str, optional
228240
The product symbols to filter for. Takes up to 2,000 symbols per request.
229241
If more than 1 symbol is specified, the data is merged and sorted by time.
@@ -258,7 +270,7 @@ async def get_range_async(
258270
params: List[Tuple[str, Optional[str]]] = [
259271
("dataset", validate_semantic_string(dataset, "dataset")),
260272
("start", datetime_to_string(start)),
261-
("end", datetime_to_string(end)),
273+
("end", optional_datetime_to_string(end)),
262274
("symbols", symbols_list),
263275
("schema", str(schema_valid)),
264276
("stype_in", str(stype_in_valid)),

databento/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.10.0"
1+
__version__ = "0.11.0"

0 commit comments

Comments
 (0)