Skip to main content

Quote

Get a real-time price quote for a single stock symbol.

Making Requests

Use the quote() method on the stocks resource to fetch a real-time quote:

Output FormatReturn TypeDescription
JSONQuoteReturns a Quote object with typed properties (default).
CSVQuoteReturns a Quote object with CSV data accessible via getCsv().
HTMLQuoteReturns a Quote 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.

quote

public function quote(
string $symbol,
bool $fifty_two_week = false,
bool $extended = true,
?Parameters $parameters = null
): Quote

Get a real-time price quote for a stock symbol, including bid/ask prices, last trade, change, and volume.

Parameters

  • symbol (string)

    The stock ticker symbol (e.g., "AAPL", "MSFT").

  • fifty_two_week (bool, optional)

    Enable the output of 52-week high and 52-week low data. Defaults to false. Uses API alias 52week.

  • extended (bool, optional)

    Control the inclusion of extended hours (pre-market and after-hours) data. Defaults to true.

    • When true: Returns the most recent quote regardless of trading session.
    • When false: Returns only quotes from the primary trading session. During extended hours, returns the closing quote from the last regular session.
  • parameters (Parameters, optional)

    Universal parameters for customizing the output format. See Parameters for details.

Returns

  • Quote

    A Quote response object containing the current quote data.

<?php

use MarketDataApp\Client;

$client = new Client();

// Get real-time quote for AAPL
$quote = $client->stocks->quote('AAPL');

echo "Symbol: " . $quote->symbol . "\n";
echo "Last Price: $" . number_format($quote->last, 2) . "\n";
echo "Change: $" . number_format($quote->change, 2) . " (" . number_format($quote->change_percent * 100, 2) . "%)\n";
echo "Bid: $" . $quote->bid . " x " . $quote->bid_size . "\n";
echo "Ask: $" . $quote->ask . " x " . $quote->ask_size . "\n";
echo "Volume: " . number_format($quote->volume) . "\n";
echo "Updated: " . $quote->updated->format('Y-m-d H:i:s') . "\n";

Output

Symbol: AAPL
Last Price: $186.19
Change: $1.05 (0.57%)
Bid: $186.18 x 200
Ask: $186.20 x 300
Volume: 48,234,500
Updated: 2024-01-15 16:00:00

Quote

class Quote extends ResponseBase
{
public string $status;
public string $symbol;
public ?float $ask;
public ?int $ask_size;
public ?float $bid;
public ?int $bid_size;
public ?float $mid;
public ?float $last;
public ?float $change;
public ?float $change_percent;
public ?float $fifty_two_week_high;
public ?float $fifty_two_week_low;
public ?int $volume;
public ?Carbon $updated;
}

Represents a stock quote with real-time price information.

Properties

  • status (string): Response status ("ok" or "no_data").
  • symbol (string): The stock ticker symbol.
  • ask (float|null): The ask price.
  • ask_size (int|null): Number of shares offered at the ask price.
  • bid (float|null): The bid price.
  • bid_size (int|null): Number of shares that may be sold at the bid price.
  • mid (float|null): The midpoint price between ask and bid.
  • last (float|null): The last traded price.
  • change (float|null): Price change in dollars from previous close.
  • change_percent (float|null): Price change as a decimal (e.g., 0.30 = 30%).
  • fifty_two_week_high (float|null): 52-week high price (only when fifty_two_week: true).
  • fifty_two_week_low (float|null): 52-week low price (only when fifty_two_week: true).
  • volume (int|null): Trading volume for the current session.
  • updated (Carbon|null): Timestamp of the quote.

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.