-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Dict, Optional | ||
|
||
from alpaca.common.enums import BaseURL | ||
from alpaca.common.websocket import BaseStream | ||
from alpaca.data.enums import DataFeed | ||
|
||
|
||
class OptionDataStream(BaseStream): | ||
""" | ||
A WebSocket client for streaming live option data. | ||
See BaseStream for more information on implementation and the methods available. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
api_key: str, | ||
secret_key: str, | ||
raw_data: bool = False, | ||
websocket_params: Optional[Dict] = None, | ||
url_override: Optional[str] = None, | ||
) -> None: | ||
""" | ||
Instantiates a WebSocket client for accessing live option data. | ||
Args: | ||
api_key (str): Alpaca API key. | ||
secret_key (str): Alpaca API secret key. | ||
raw_data (bool, optional): Whether to return wrapped data or raw API data. Defaults to False. | ||
websocket_params (Optional[Dict], optional): Any parameters for configuring websocket connection. Defaults to None. | ||
url_override (Optional[str]): If specified allows you to override the base url the client | ||
points to for proxy/testing. Defaults to None. | ||
""" | ||
super().__init__( | ||
endpoint=( | ||
url_override | ||
if url_override is not None | ||
else BaseURL.OPTION_DATA_STREAM.value + "/v1beta1/opra" | ||
), | ||
api_key=api_key, | ||
secret_key=secret_key, | ||
raw_data=raw_data, | ||
websocket_params=websocket_params, | ||
) |