Skip to main content

Market Status

Get the past, present, or future market status (open/closed) for any trading day.

Making Requests

Use the status() method on the markets resource to check market status:

Output FormatReturn TypeDescription
JSONStatusesReturns a Statuses object containing market status data (default).
CSVStatusesReturns a Statuses object with CSV data accessible via getCsv().
HTMLStatusesReturns a Statuses object with HTML data accessible via getHtml().
HTML Not Yet Available

Format::HTML is included for forward compatibility, but HTML responses are not currently implemented by the Market Data API.

status

public function status(
string $country = "US",
?string $date = null,
?string $from = null,
?string $to = null,
?int $countback = null,
?Parameters $parameters = null
): Statuses

Get the past, present, or future status for a stock market. The endpoint will respond with "open" for trading days or "closed" for weekends or market holidays.

Parameters

  • country (string, optional)

    The country code using the two-digit ISO 3166 format. Defaults to "US". Currently, only the United States is supported.

  • date (string, optional)

    Check whether the market was open or closed on a specific date. Accepted formats: ISO 8601, Unix timestamp, spreadsheet serial number.

  • from (string, optional)

    The earliest date (inclusive) for a date range query. Combine with to or countback.

  • to (string, optional)

    The last date (inclusive) for a date range query.

  • countback (int, optional)

    Number of dates to return before to. Use instead of from.

  • parameters (Parameters, optional)

    Universal parameters for customizing the output format.

Returns

  • Statuses

    A Statuses response object containing the market status for the requested date(s).

<?php

use MarketDataApp\Client;

$client = new Client();

// Get current market status
$statuses = $client->markets->status();

foreach ($statuses->statuses as $status) {
echo "Date: " . $status->date->format('Y-m-d') . "\n";
echo "Status: " . $status->status . "\n";
}

Output

Date: 2024-01-15
Status: open

Status

class Status
{
public Carbon $date;
public string $status;
}

Represents the market status for a single date.

Properties

  • date (Carbon): The date.
  • status (string): The market status ("open" or "closed").

Statuses

class Statuses extends ResponseBase
{
public string $status;
public array $statuses;
}

Represents a collection of market status entries.

Properties

  • status (string): Response status ("ok" or "no_data").
  • statuses (Status[]): Array of Status objects.

Methods

  • getCsv(): Returns the raw CSV data (when using Format::CSV).
  • getHtml(): Returns the raw HTML data (when using Format::HTML).
  • isJson(): Returns true if the response contains JSON data.