Skip to content

Market Data

Market Data Resource

composer.resources.market_data.MarketData

Resource for market data endpoints.

Source code in composer/resources/market_data.py
class MarketData:
    """Resource for market data endpoints."""

    def __init__(self, http_client):
        self._client = http_client

    def get_options_chain(
        self,
        underlying: str,
        next_cursor: str | None = None,
        strike_price: float | None = None,
        expiry: str | None = None,
        contract_type: ContractType | None = None,
        order: SortOrder = SortOrder.ASC,
        limit: int | None = None,
        sort_by: OptionSortBy = OptionSortBy.SYMBOL,
    ) -> OptionsChainResponse:
        """
        Get options chain for a specific underlying asset.

        Args:
            underlying: The underlying asset symbol (e.g., "AAPL")
            next_cursor: Pagination cursor for fetching the next page
            strike_price: Filter by specific strike price
            expiry: Filter by expiration date (YYYY-MM-DD format)
            contract_type: Filter by option type (CALL or PUT)
            order: Sort order for results
            limit: Maximum number of results to return (max 250)
            sort_by: Field to sort results by

        Returns
        -------
            OptionsChainResponse with list of options contracts
        """
        params: dict = {
            "underlying_asset_symbol": underlying,
            "order": order.value,
            "sort_by": sort_by.value,
        }
        if next_cursor:
            params["next_cursor"] = next_cursor
        if strike_price:
            params["strike_price"] = strike_price
        if expiry:
            params["expiry"] = expiry
        if contract_type:
            params["contract_type"] = contract_type.value
        if limit:
            params["limit"] = limit

        response = self._client.get("/api/v1/market-data/options/chain", params=params)
        return OptionsChainResponse.model_validate(response)

    def get_options_contract(self, symbol: str) -> OptionsContractResponse:
        """
        Get market data for a specific options contract.

        Args:
            symbol: The options contract symbol (e.g., "OPTIONS::AAPL250718C00210000//USD")

        Returns
        -------
            OptionsContractResponse with contract market data
        """
        response = self._client.get(
            "/api/v1/market-data/options/contract", params={"symbol": symbol}
        )

        return OptionsContractResponse.model_validate(response)

    def get_options_overview(self, symbol: str) -> OptionsOverview:
        """
        Get an overview of options data for a given ticker.

        Args:
            symbol: The underlying asset symbol (e.g., "AAPL")

        Returns
        -------
            OptionsOverview with available expiration dates
        """
        response = self._client.get(
            "/api/v1/market-data/options/overview", params={"symbol": symbol}
        )
        return OptionsOverview.model_validate(response)

    def get_snapshot(self, symbol: str) -> MarketSnapshot:
        """
        Get a snapshot of live market data.

        Args:
            symbol: The symbol to get snapshot for (e.g., "AAPL", "BTC-USD")

        Returns
        -------
            MarketSnapshot with bid, ask, last trade, and change data
        """
        response = self._client.get("/api/v1/market-data/snapshot", params={"symbol": symbol})
        return MarketSnapshot.model_validate(response)

    def get_custom_bars(
        self,
        symbol: str,
        range_date_from: str | None = None,
        range_date_to: str | None = None,
        range_preset: str | None = None,
    ) -> CustomBars:
        """
        Get custom bars market data.

        Args:
            symbol: The symbol to get bars for (e.g., "AAPL", "BTC-USD")
            range_date_from: Start date (YYYY-MM-DD format)
            range_date_to: End date (YYYY-MM-DD format)
            range_preset: Preset range (e.g., "1M", "3M", "1Y", "5Y")

        Returns
        -------
            CustomBars with OHLCV data
        """
        params = {"symbol": symbol}
        if range_date_from:
            params["range_date_from"] = range_date_from
        if range_date_to:
            params["range_date_to"] = range_date_to
        if range_preset:
            params["range_preset"] = range_preset

        response = self._client.get("/api/v1/market-data/custom-bars", params=params)
        return CustomBars.model_validate(response)

    def get_market_overview(self, symbol: str) -> MarketOverview:
        """
        Get an overview of reference data for a symbol.

        Args:
            symbol: The symbol to get overview for (e.g., "AAPL", "BTC-USD")

        Returns
        -------
            MarketOverview with company info, market cap, etc.
        """
        response = self._client.get("/api/v1/market-data/overview", params={"symbol": symbol})
        return MarketOverview.model_validate(response)

    def get_top_movers(self) -> TopMoversResponse:
        """
        Get top movers market data.

        Returns
        -------
            TopMoversResponse with list of top gaining/losing symbols
        """
        response = self._client.get("/api/v1/market-data/top-movers")
        return TopMoversResponse.model_validate(response)

get_custom_bars(symbol, range_date_from=None, range_date_to=None, range_preset=None)

Get custom bars market data.

Parameters:

Name Type Description Default
symbol str

The symbol to get bars for (e.g., "AAPL", "BTC-USD")

required
range_date_from str | None

Start date (YYYY-MM-DD format)

None
range_date_to str | None

End date (YYYY-MM-DD format)

None
range_preset str | None

Preset range (e.g., "1M", "3M", "1Y", "5Y")

None
Returns
CustomBars with OHLCV data
Source code in composer/resources/market_data.py
def get_custom_bars(
    self,
    symbol: str,
    range_date_from: str | None = None,
    range_date_to: str | None = None,
    range_preset: str | None = None,
) -> CustomBars:
    """
    Get custom bars market data.

    Args:
        symbol: The symbol to get bars for (e.g., "AAPL", "BTC-USD")
        range_date_from: Start date (YYYY-MM-DD format)
        range_date_to: End date (YYYY-MM-DD format)
        range_preset: Preset range (e.g., "1M", "3M", "1Y", "5Y")

    Returns
    -------
        CustomBars with OHLCV data
    """
    params = {"symbol": symbol}
    if range_date_from:
        params["range_date_from"] = range_date_from
    if range_date_to:
        params["range_date_to"] = range_date_to
    if range_preset:
        params["range_preset"] = range_preset

    response = self._client.get("/api/v1/market-data/custom-bars", params=params)
    return CustomBars.model_validate(response)

get_market_overview(symbol)

Get an overview of reference data for a symbol.

Parameters:

Name Type Description Default
symbol str

The symbol to get overview for (e.g., "AAPL", "BTC-USD")

required
Returns
MarketOverview with company info, market cap, etc.
Source code in composer/resources/market_data.py
def get_market_overview(self, symbol: str) -> MarketOverview:
    """
    Get an overview of reference data for a symbol.

    Args:
        symbol: The symbol to get overview for (e.g., "AAPL", "BTC-USD")

    Returns
    -------
        MarketOverview with company info, market cap, etc.
    """
    response = self._client.get("/api/v1/market-data/overview", params={"symbol": symbol})
    return MarketOverview.model_validate(response)

get_options_chain(underlying, next_cursor=None, strike_price=None, expiry=None, contract_type=None, order=SortOrder.ASC, limit=None, sort_by=OptionSortBy.SYMBOL)

Get options chain for a specific underlying asset.

Parameters:

Name Type Description Default
underlying str

The underlying asset symbol (e.g., "AAPL")

required
next_cursor str | None

Pagination cursor for fetching the next page

None
strike_price float | None

Filter by specific strike price

None
expiry str | None

Filter by expiration date (YYYY-MM-DD format)

None
contract_type ContractType | None

Filter by option type (CALL or PUT)

None
order SortOrder

Sort order for results

ASC
limit int | None

Maximum number of results to return (max 250)

None
sort_by OptionSortBy

Field to sort results by

SYMBOL
Returns
OptionsChainResponse with list of options contracts
Source code in composer/resources/market_data.py
def get_options_chain(
    self,
    underlying: str,
    next_cursor: str | None = None,
    strike_price: float | None = None,
    expiry: str | None = None,
    contract_type: ContractType | None = None,
    order: SortOrder = SortOrder.ASC,
    limit: int | None = None,
    sort_by: OptionSortBy = OptionSortBy.SYMBOL,
) -> OptionsChainResponse:
    """
    Get options chain for a specific underlying asset.

    Args:
        underlying: The underlying asset symbol (e.g., "AAPL")
        next_cursor: Pagination cursor for fetching the next page
        strike_price: Filter by specific strike price
        expiry: Filter by expiration date (YYYY-MM-DD format)
        contract_type: Filter by option type (CALL or PUT)
        order: Sort order for results
        limit: Maximum number of results to return (max 250)
        sort_by: Field to sort results by

    Returns
    -------
        OptionsChainResponse with list of options contracts
    """
    params: dict = {
        "underlying_asset_symbol": underlying,
        "order": order.value,
        "sort_by": sort_by.value,
    }
    if next_cursor:
        params["next_cursor"] = next_cursor
    if strike_price:
        params["strike_price"] = strike_price
    if expiry:
        params["expiry"] = expiry
    if contract_type:
        params["contract_type"] = contract_type.value
    if limit:
        params["limit"] = limit

    response = self._client.get("/api/v1/market-data/options/chain", params=params)
    return OptionsChainResponse.model_validate(response)

get_options_contract(symbol)

Get market data for a specific options contract.

Parameters:

Name Type Description Default
symbol str

The options contract symbol (e.g., "OPTIONS::AAPL250718C00210000//USD")

required
Returns
OptionsContractResponse with contract market data
Source code in composer/resources/market_data.py
def get_options_contract(self, symbol: str) -> OptionsContractResponse:
    """
    Get market data for a specific options contract.

    Args:
        symbol: The options contract symbol (e.g., "OPTIONS::AAPL250718C00210000//USD")

    Returns
    -------
        OptionsContractResponse with contract market data
    """
    response = self._client.get(
        "/api/v1/market-data/options/contract", params={"symbol": symbol}
    )

    return OptionsContractResponse.model_validate(response)

get_options_overview(symbol)

Get an overview of options data for a given ticker.

Parameters:

Name Type Description Default
symbol str

The underlying asset symbol (e.g., "AAPL")

required
Returns
OptionsOverview with available expiration dates
Source code in composer/resources/market_data.py
def get_options_overview(self, symbol: str) -> OptionsOverview:
    """
    Get an overview of options data for a given ticker.

    Args:
        symbol: The underlying asset symbol (e.g., "AAPL")

    Returns
    -------
        OptionsOverview with available expiration dates
    """
    response = self._client.get(
        "/api/v1/market-data/options/overview", params={"symbol": symbol}
    )
    return OptionsOverview.model_validate(response)

get_snapshot(symbol)

Get a snapshot of live market data.

Parameters:

Name Type Description Default
symbol str

The symbol to get snapshot for (e.g., "AAPL", "BTC-USD")

required
Returns
MarketSnapshot with bid, ask, last trade, and change data
Source code in composer/resources/market_data.py
def get_snapshot(self, symbol: str) -> MarketSnapshot:
    """
    Get a snapshot of live market data.

    Args:
        symbol: The symbol to get snapshot for (e.g., "AAPL", "BTC-USD")

    Returns
    -------
        MarketSnapshot with bid, ask, last trade, and change data
    """
    response = self._client.get("/api/v1/market-data/snapshot", params={"symbol": symbol})
    return MarketSnapshot.model_validate(response)

get_top_movers()

Get top movers market data.

Returns
TopMoversResponse with list of top gaining/losing symbols
Source code in composer/resources/market_data.py
def get_top_movers(self) -> TopMoversResponse:
    """
    Get top movers market data.

    Returns
    -------
        TopMoversResponse with list of top gaining/losing symbols
    """
    response = self._client.get("/api/v1/market-data/top-movers")
    return TopMoversResponse.model_validate(response)

Quotes Resource

composer.resources.quotes.Quotes

Resource for quote endpoints.

Source code in composer/resources/quotes.py
class Quotes:
    """Resource for quote endpoints."""

    def __init__(self, http_client):
        self._client = http_client

    def get_quotes(self, tickers: list[str]) -> _QuoteDict:
        """
        Get realtime crypto and (15-minute delayed) equity quotes.

        If equity markets are closed, returns the last close price.

        Args:
            tickers: List of tickers to get quotes for (e.g., ["AAPL", "CRYPTO::BTC//USD"])

        Returns
        -------
            Dict mapping ticker to QuoteResult
        """
        response = self._client.post(
            "/api/v1/public/quotes",
            json={"tickers": tickers},
        )
        return _QuoteDict({ticker: QuoteResult(**data) for ticker, data in response.items()})

get_quotes(tickers)

Get realtime crypto and (15-minute delayed) equity quotes.

If equity markets are closed, returns the last close price.

Parameters:

Name Type Description Default
tickers list[str]

List of tickers to get quotes for (e.g., ["AAPL", "CRYPTO::BTC//USD"])

required
Returns
Dict mapping ticker to QuoteResult
Source code in composer/resources/quotes.py
def get_quotes(self, tickers: list[str]) -> _QuoteDict:
    """
    Get realtime crypto and (15-minute delayed) equity quotes.

    If equity markets are closed, returns the last close price.

    Args:
        tickers: List of tickers to get quotes for (e.g., ["AAPL", "CRYPTO::BTC//USD"])

    Returns
    -------
        Dict mapping ticker to QuoteResult
    """
    response = self._client.post(
        "/api/v1/public/quotes",
        json={"tickers": tickers},
    )
    return _QuoteDict({ticker: QuoteResult(**data) for ticker, data in response.items()})