Historical Data#
OptionHistoricalDataClient#
- class alpaca.data.historical.option.OptionHistoricalDataClient(api_key: Optional[str] = None, secret_key: Optional[str] = None, oauth_token: Optional[str] = None, use_basic_auth: bool = False, raw_data: bool = False, url_override: Optional[str] = None, sandbox: bool = False)#
The REST client for interacting with Alpaca Market Data API option data endpoints.
Learn more on https://docs.alpaca.markets/docs/about-market-data-api
- __init__(api_key: Optional[str] = None, secret_key: Optional[str] = None, oauth_token: Optional[str] = None, use_basic_auth: bool = False, raw_data: bool = False, url_override: Optional[str] = None, sandbox: bool = False) None #
Instantiates a Historical Data Client.
- Parameters:
api_key (Optional[str], optional) – Alpaca API key. Defaults to None.
secret_key (Optional[str], optional) – Alpaca API secret key. Defaults to None.
oauth_token (Optional[str]) – The oauth token if authenticating via OAuth. Defaults to None.
use_basic_auth (bool, optional) – If true, API requests will use basic authorization headers. Set to true if using broker api sandbox credentials
raw_data (bool, optional) – If true, API responses will not be wrapped and raw responses will be returned from methods. Defaults to False. This has not been implemented yet.
url_override (Optional[str], optional) – If specified allows you to override the base url the client points to for proxy/testing.
sandbox (bool) – True if using sandbox mode. Defaults to False.
Get Option Bars#
- OptionHistoricalDataClient.get_option_bars(request_params: OptionBarsRequest) Union[BarSet, Dict[str, Any]] #
Returns bar data for an option contract or list of option contracts over a given time period and timeframe.
- Parameters:
request_params (OptionBarsRequest) – The request object for retrieving option bar data.
- Returns:
The bar data either in raw or wrapped form
- Return type:
Union[BarSet, RawData]
Get Option Trades#
- OptionHistoricalDataClient.get_option_trades(request_params: OptionTradesRequest) Union[TradeSet, Dict[str, Any]] #
The historical option trades API provides trade data for a list of contract symbols between the specified dates up to 7 days ago.
- Parameters:
request_params (OptionTradesRequest) – The request object for retrieving option trade data.
- Returns:
The trade data either in raw or wrapped form
- Return type:
Union[TradeSet, RawData]
Get Option Exchange Codes#
- OptionHistoricalDataClient.get_option_exchange_codes() Dict[str, Any] #
Returns the mapping between the option exchange codes and the corresponding exchanges names.
- Parameters:
None –
- Returns:
The mapping between the option exchange codes and the corresponding exchanges names.
- Return type:
RawData
Get Option Latest Quote#
- OptionHistoricalDataClient.get_option_latest_quote(request_params: OptionLatestQuoteRequest) Union[Dict[str, Quote], Dict[str, Any]] #
Retrieves the latest quote for an option symbol or list of option symbols.
- Parameters:
request_params (OptionLatestQuoteRequest) – The request object for retrieving the latest quote data.
- Returns:
The latest quote in raw or wrapped format
- Return type:
Union[Dict[str, Quote], RawData]
Get Option Latest Trade#
- OptionHistoricalDataClient.get_option_latest_trade(request_params: OptionLatestTradeRequest) Union[Dict[str, Trade], Dict[str, Any]] #
Retrieves the latest trade for an option symbol or list of option symbols.
- Parameters:
request_params (OptionLatestQuoteRequest) – The request object for retrieving the latest quote data.
- Returns:
The latest quote in raw or wrapped format
- Return type:
Union[Dict[str, Quote], RawData]
Get Option Snapshot#
- OptionHistoricalDataClient.get_option_snapshot(request_params: OptionSnapshotRequest) Union[Dict[str, OptionsSnapshot], Dict[str, Any]] #
Returns snapshots of queried symbols. OptionsSnapshot contain latest trade, latest quote, implied volatility, and greeks for the queried symbols.
- Parameters:
request_params (OptionSnapshotRequest) – The request object for retrieving snapshot data.
- Returns:
The snapshot data either in raw or wrapped form
- Return type:
Union[Dict[str, OptionsSnapshot], RawData]
Get Option Chain#
- OptionHistoricalDataClient.get_option_chain(request_params: OptionChainRequest) Union[Dict[str, OptionsSnapshot], Dict[str, Any]] #
The option chain endpoint for underlying symbol provides the latest trade, latest quote, implied volatility, and greeks for each contract symbol of the underlying symbol.
- Parameters:
request_params (OptionChainRequest) – The request object for retrieving snapshot data.
- Returns:
The snapshot data either in raw or wrapped form
- Return type:
Union[Dict[str, OptionsSnapshot], RawData]