Skip to content

Commit

Permalink
feat: Add updated_since to the option chain request (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnvk authored Aug 22, 2024
1 parent d0622bd commit 10dbe05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions alpaca/data/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class OptionChainRequest(NonEmptyRequest):
expiration_date_gte (Optional[Union[date, str]]): Filter contracts with expiration date greater than or equal to the specified date.
expiration_date_lte (Optional[Union[date, str]]): Filter contracts with expiration date less than or equal to the specified date.
root_symbol (Optional[str]): Filter contracts by the root symbol.
updated_since (Optional[datetime]): Filter to snapshots that were updated since this timestamp.
"""

underlying_symbol: str
Expand All @@ -464,6 +465,7 @@ class OptionChainRequest(NonEmptyRequest):
expiration_date_gte: Optional[Union[date, str]] = None
expiration_date_lte: Optional[Union[date, str]] = None
root_symbol: Optional[str] = None
updated_since: Optional[datetime] = None


# ############################## Orderbooks ################################# #
Expand Down
6 changes: 4 additions & 2 deletions tests/data/test_historical_option_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def test_get_option_chain(reqmock, option_client: OptionHistoricalDataClient):
symbol = "AAPL"

reqmock.get(
f"https://data.alpaca.markets/v1beta1/options/snapshots/{symbol}",
f"https://data.alpaca.markets/v1beta1/options/snapshots/{symbol}?updated_since=2024-04-25T00%3A00%3A00%2B00%3A00",
text="""
{
"next_page_token": null,
Expand Down Expand Up @@ -1037,7 +1037,9 @@ def test_get_option_chain(reqmock, option_client: OptionHistoricalDataClient):
""",
)

request = OptionChainRequest(underlying_symbol=symbol)
request = OptionChainRequest(
underlying_symbol=symbol, updated_since=datetime(2024, 4, 25)
)

snapshots = option_client.get_option_chain(request)

Expand Down

0 comments on commit 10dbe05

Please sign in to comment.