asynctradier.clients.marketdata_client module
- class asynctradier.clients.marketdata_client.MarketDataClient(session: WebUtil, account_id: str, token: str, sandbox: bool = False)[source]
Bases:
objectA client for accessing market data.
- Parameters:
session (WebUtil) – The session object used for making HTTP requests.
account_id (str) – The account ID associated with the client.
token (str) – The authentication token for accessing the market data.
sandbox (bool, optional) – Whether to use the sandbox environment. Defaults to False.
- async get_calendar(year: str, month: str) List[Calendar][source]
Retrieves the calendar for a specific year and month.
- Parameters:
year (str) – The year in the format YYYY.
month (str) – The month in the format MM.
- Returns:
A list of Calendar objects representing the calendar for the specified year and month.
- Return type:
List[Calendar]
- async get_clock(delay: bool = False) Clock[source]
Retrieves the current market clock.
- Returns:
A Clock object representing the current market clock.
- Return type:
- async get_etb_securities() List[Security][source]
Retrieves a list of ETB (Exchange Traded Bond) securities.
- Returns:
A list of ETB securities.
- Return type:
List[str]
- async get_historical_quotes(symbol: str, interval: str, start: str, end: str) List[Quote][source]
Get historical quotes for a symbol.
- Parameters:
symbol (str) – The symbol.
interval (str) – The interval for the historical quotes.
start (str) – The start date (YYYY-MM-DD).
end (str) – The end date (YYYY-MM-DD).
- async get_option_chains(symbol: str, expiration_date: str, greeks: bool = False, option_type: OptionType | None = None) List[Quote][source]
Get option chains for a symbol.
- Parameters:
symbol (str) – The symbol.
expiration_date (str) – The expiration date (YYYY-MM-DD).
greeks (bool, optional) – Whether to include greeks in the response. Defaults to False.
option_type (OptionType, optional) – Filter by option type. Defaults to None.
- async get_option_expirations(symbol: str, strikes: bool = False, contract_size: bool = False, expiration_type: bool = False) List[Expiration][source]
Retrieves the option expirations for a given symbol.
- Parameters:
symbol (str) – The symbol for which to retrieve option expirations.
strikes (bool, optional) – Whether to include strike prices in the response. Defaults to False.
contract_size (bool, optional) – Whether to include contract sizes in the response. Defaults to False.
expiration_type (bool, optional) – Whether to include expiration types in the response. Defaults to False.
- Returns:
A list of Expiration objects representing the option expirations.
- Return type:
List[Expiration]
- async get_option_strikes(symbol: str, expiration_date: str) List[float][source]
Get option strikes for a symbol.
- Parameters:
symbol (str) – The symbol.
expiration_date (str) – The expiration date (YYYY-MM-DD).
- async get_quotes(symbols: List[str], greeks: bool = False) List[Quote][source]
Get quotes for a list of symbols.
- Parameters:
symbols (List[str]) – A list of symbols.
greeks (bool, optional) – Whether to include greeks in the response. Defaults to False.
- async get_time_and_sales(symbol: str, interval: str = 'tick', start: str | None = None, end: str | None = None, session_filter: str = 'all') List[Quote][source]
Retrieves time and sales data for a given symbol within a specified interval.
- Parameters:
symbol (str) – The symbol for which to retrieve time and sales data.
interval (str, optional) – The interval of the time and sales data. Defaults to “tick”.
start (str, optional) – The start date and time for the data retrieval. Format: “YYYY-MM-DD HH:MM”. Defaults to None.
end (str, optional) – The end date and time for the data retrieval. Format: “YYYY-MM-DD HH:MM”. Defaults to None.
session_filter (str, optional) – The session filter for the data retrieval. Must be one of “all” or “open”. Defaults to “all”.
- Returns:
A list of Quote objects representing the time and sales data.
- Return type:
List[Quote]
- Raises:
InvalidParameter – If the provided interval, session_filter, start date, or end date is invalid.
- async lookup_symbol(query: str, exchanges: str | None = None, types: str | None = None) List[Security][source]
Search for companies based on the given query.
- Parameters:
query (str) – The search query.
exchanges (str, optional) – The exchanges to search. Must be one of “Q” or “N”. Defaults to None.
types (str, optional) – The types of securities to search. Must be one of “stock”, “option”, “etf”, or “index”. Defaults to None.
- Returns:
A list of Security objects representing the search results.
- Return type:
List[Security]
- async option_lookup(symbol: str) List[str][source]
Retrieves a list of option symbols for a given symbol.
- Parameters:
symbol (str) – The symbol for which to retrieve option symbols.
- Returns:
A list of option symbols.
- Return type:
List[str]
- async search_companies(query: str, indexes: bool = False) List[Security][source]
Search for companies based on the given query.
- Parameters:
query (str) – The search query.
indexes (bool, optional) – Whether to include indexes in the search results. Defaults to False.
- Returns:
A list of Security objects representing the search results.
- Return type:
List[Security]