Skip to main content

Status

Retrieve market status information (open/closed) for dates and countries.

Making Requests

Use the status() method on the markets resource to fetch market status information. The method supports multiple output formats:

Output FormatReturn TypeDescription
DATAFRAMEpandas.DataFrame or polars.DataFrameReturns a DataFrame with market status data (default).
INTERNALlist[MarketStatus] or list[MarketStatusHumanReadable]Returns a list of MarketStatus objects. When use_human_readable=True, returns a list of MarketStatusHumanReadable objects with capitalized field names.
JSONdictReturns the raw JSON response as a dictionary.
CSVstrWrites CSV data to file and returns the filename string.

status

def status(
*,
date: str | datetime.datetime = None,
from_date: str | datetime.datetime = None,
to_date: str | datetime.datetime = None,
countback: int = None,
country: str = None,
output_format: OutputFormat = OutputFormat.DATAFRAME,
date_format: DateFormat = None,
columns: list[str] = None,
add_headers: bool = None,
use_human_readable: bool = False,
mode: Mode = None,
filename: str | Path = None,
) -> list[MarketStatus] | list[MarketStatusHumanReadable] | dict | str | MarketDataClientErrorResult

Fetches market status information for specified dates and countries. All parameters must be keyword-only.

Parameters

  • date (str | datetime.datetime, optional)

    Specific date for the market status.

  • from_date (str | datetime.datetime, optional)

    Start date for the date range.

  • to_date (str | datetime.datetime, optional)

    End date for the date range.

  • countback (int, optional)

    Number of days to return, counting backwards from the to_date.

  • country (str, optional)

    Filter by country code (e.g., "US", "CA", "GB").

  • output_format (OutputFormat, optional)

    The format of the returned data. Defaults to OutputFormat.DATAFRAME. See Settings for details.

  • date_format (DateFormat, optional)

    The date format to use in the response. Defaults to DateFormat.UNIX. See Settings for details.

  • columns (optional)

    Specify which columns to include in the response. See Settings for details.

  • add_headers (optional)

    Whether to include headers in the response. See Settings for details.

  • use_human_readable (optional)

    Whether to use human-readable format for values. Only applies when output_format=OutputFormat.INTERNAL. See Settings for details.

  • mode (Mode, optional)

    The data feed mode to use. See Settings for details.

  • filename (str | Path, optional)

    File path for CSV output (only used with output_format=OutputFormat.CSV).

Returns

  • list[MarketStatus] | list[MarketStatusHumanReadable] | dict | str | MarketDataClientErrorResult

    The market status data in the requested format, or a MarketDataClientErrorResult if an error occurred.

Notes

  • All parameters must be keyword-only (no positional arguments).
  • When using countback, it counts backwards from to_date or the current date if to_date is not provided.
from marketdata.client import MarketDataClient

client = MarketDataClient()

# Get market status as DataFrame (default)
# All parameters must be keyword-only
df = client.markets.status(countback=7)

# Get market status for a specific date
df = client.markets.status(date="2023-01-01")

# Get market status for a date range
df = client.markets.status(
from_date="2023-01-01",
to_date="2023-01-31",
country="US"
)

print(df)

MarketStatus

@dataclass
class MarketStatus:
date: datetime.date
status: str

MarketStatus represents market status information for a specific date, indicating whether the market is open or closed.

Properties

  • date (datetime.date): The date for which the market status applies (automatically converted from timestamp).
  • status (str): The market status (e.g., "open", "closed").

Notes

  • The date field is automatically converted to a datetime.date object from a Unix timestamp.

MarketStatusHumanReadable

@dataclass
class MarketStatusHumanReadable:
Status: str
Date: datetime.datetime

MarketStatusHumanReadable represents market status information in human-readable format with capitalized field names and formatted values.

Properties

  • Status (str): The market status (e.g., "open", "closed").
  • Date (datetime.datetime): The date for which the market status applies (automatically converted from timestamp).

Notes

  • The Date field is automatically converted to a datetime.datetime object from a Unix timestamp.
  • Field names use capitalized format (e.g., Date instead of date, Status instead of status).