Skip to content

Commit d1e6adf

Browse files
committed
REF: Rename to timeseries.get_range
1 parent 1e721db commit d1e6adf

15 files changed

+73
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 0.8.0 - TBD
44
- Renamed 'dbz' encoding to 'dbn'
5+
- Renamed `timeseries.stream` to `timeseries.get_range`
56
- Added `batch.list_files(...)` method
67
- Added `batch.download(...)` method
78
- Changed `.to_df(...)` `pretty_ts` default argument to `True`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ A simple Databento application looks like this:
5454
import databento as db
5555

5656
client = db.Historical('YOUR_API_KEY')
57-
data = client.timeseries.stream(
57+
data = client.timeseries.get_range(
5858
dataset='GLBX.MDP3',
5959
symbols='ES.FUT',
6060
stype_in='smart',

databento/common/bento.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ def request_full_definitions(
702702
"""
703703
Request full instrument definitions based on the metadata properties.
704704
705-
Makes a `GET /timeseries.stream` HTTP request.
705+
Makes a `GET /timeseries.get_range` HTTP request.
706706
707707
Parameters
708708
----------
@@ -720,7 +720,7 @@ def request_full_definitions(
720720
Calling this method will incur a cost.
721721
722722
"""
723-
return client.timeseries.stream(
723+
return client.timeseries.get_range(
724724
dataset=self.dataset,
725725
symbols=self.symbols,
726726
schema=Schema.DEFINITION,

databento/common/deprecated.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import functools
2+
import warnings
3+
from typing import Any
4+
5+
6+
def deprecated(func: Any) -> Any:
7+
@functools.wraps(func)
8+
def new_func(*args: Any, **kwargs: Any) -> Any:
9+
warnings.simplefilter("always", DeprecationWarning)
10+
warnings.warn(func.__doc__, category=DeprecationWarning)
11+
return func(*args, **kwargs)
12+
13+
return new_func

databento/historical/api/timeseries.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pandas as pd
77
from databento.common.bento import Bento
8+
from databento.common.deprecated import deprecated
89
from databento.common.enums import Compression, Dataset, Encoding, Schema, SType
910
from databento.common.parsing import datetime_to_string, optional_symbols_list_to_string
1011
from databento.common.validation import validate_enum
@@ -22,6 +23,7 @@ def __init__(self, key: str, gateway: str) -> None:
2223
super().__init__(key=key, gateway=gateway)
2324
self._base_url = gateway + f"/v{API_VERSION}/timeseries"
2425

26+
@deprecated
2527
def stream(
2628
self,
2729
dataset: Union[Dataset, str],
@@ -33,11 +35,39 @@ def stream(
3335
stype_out: Union[SType, str] = "product_id",
3436
limit: Optional[int] = None,
3537
path: Optional[Union[Path, str]] = None,
38+
) -> Bento:
39+
"""
40+
The `.stream` method is deprecated and will be removed in a future version.
41+
The method has been renamed to `.get_range`, which you can now use.
42+
"""
43+
return self.get_range(
44+
dataset=dataset,
45+
start=start,
46+
end=end,
47+
symbols=symbols,
48+
schema=schema,
49+
stype_in=stype_in,
50+
stype_out=stype_out,
51+
limit=limit,
52+
path=path,
53+
)
54+
55+
def get_range(
56+
self,
57+
dataset: Union[Dataset, str],
58+
start: Union[pd.Timestamp, date, str, int],
59+
end: Union[pd.Timestamp, date, str, int],
60+
symbols: Optional[Union[List[str], str]] = None,
61+
schema: Union[Schema, str] = "trades",
62+
stype_in: Union[SType, str] = "native",
63+
stype_out: Union[SType, str] = "product_id",
64+
limit: Optional[int] = None,
65+
path: Optional[Union[Path, str]] = None,
3666
) -> Bento:
3767
"""
3868
Request a historical time series data stream from Databento.
3969
40-
Makes a `GET /timeseries.stream` HTTP request.
70+
Makes a `GET /timeseries.get_range` HTTP request.
4171
4272
Primary method for getting historical intraday market data, daily data,
4373
instrument definitions and market status data directly into your application.
@@ -114,15 +144,15 @@ def stream(
114144
bento: Bento = self._create_bento(path=path)
115145

116146
self._stream(
117-
url=self._base_url + ".stream",
147+
url=self._base_url + ".get_range",
118148
params=params,
119149
basic_auth=True,
120150
bento=bento,
121151
)
122152

123153
return bento
124154

125-
async def stream_async(
155+
async def get_range_async(
126156
self,
127157
dataset: Union[Dataset, str],
128158
start: Union[pd.Timestamp, date, str, int],
@@ -137,7 +167,7 @@ async def stream_async(
137167
"""
138168
Request a historical time series data stream from Databento asynchronously.
139169
140-
Makes a `GET /timeseries.stream` HTTP request.
170+
Makes a `GET /timeseries.get_range` HTTP request.
141171
142172
Primary method for getting historical intraday market data, daily data,
143173
instrument definitions and market status data directly into your application.
@@ -213,7 +243,7 @@ async def stream_async(
213243
bento: Bento = self._create_bento(path=path)
214244

215245
await self._stream_async(
216-
url=self._base_url + ".stream",
246+
url=self._base_url + ".get_range",
217247
params=params,
218248
basic_auth=True,
219249
bento=bento,

examples/historical_timeseries_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async def request_stream_async() -> None:
1111
key = "YOUR_API_KEY"
1212
client = db.Historical(key=key)
1313

14-
data: Bento = await client.timeseries.stream_async(
14+
data: Bento = await client.timeseries.get_range_async(
1515
dataset="GLBX.MDP3",
1616
symbols=["ESM2"],
1717
schema="mbo",

examples/historical_timeseries_disk_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
path = "my_data.dbn"
1414

1515
# Execute request through client
16-
data: Bento = client.timeseries.stream(
16+
data: Bento = client.timeseries.get_range(
1717
dataset="GLBX.MDP3",
1818
symbols=["ESM2"],
1919
schema="mbo",

examples/historical_timeseries_replay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
key = "YOUR_API_KEY"
99
client = db.Historical(key=key)
1010

11-
data: Bento = client.timeseries.stream(
11+
data: Bento = client.timeseries.get_range(
1212
dataset="GLBX.MDP3",
1313
symbols=["ESM2"],
1414
schema="trades",

examples/historical_timeseries_to_df.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
key = "YOUR_API_KEY"
1111
client = db.Historical(key=key)
1212

13-
data: Bento = client.timeseries.stream(
13+
data: Bento = client.timeseries.get_range(
1414
dataset="GLBX.MDP3",
1515
symbols=["ESM2"],
1616
schema="trades",

examples/historical_timeseries_to_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
key = "YOUR_API_KEY"
1111
client = db.Historical(key=key)
1212

13-
data: Bento = client.timeseries.stream(
13+
data: Bento = client.timeseries.get_range(
1414
dataset="GLBX.MDP3",
1515
symbols=["ESM2"],
1616
schema="trades",

0 commit comments

Comments
 (0)