Skip to main content

STOCKDATA

Fetches a current stock quote or historical stock candle from Market Data.

Sample Usage

STOCKDATA("AAPL")
STOCKDATA("AAPL", "open")
STOCKDATA("AAPL", "close", "1/1/2021", "1/31/2021", "hourly")
STOCKDATA("AAPL", "all", TODAY()-30, 30)

Syntax

STOCKDATA(symbol, [historial attribute|quote attribute], startDate, endDate, resolution)
  • symbol (REQUIRED) The stock’s ticker symbol.

  • [historial attributes | quote attributes] (Optional) Use a historical or quote attribute:

    • historical attributes (OPTIONAL – "close" by default) Use one of the following attributes when requesting historical candles:

      • "open" – The opening price of the stock.
      • "high" – The high price of the stock.
      • "low" – The low price of the stock.
      • "close" – The closing price of the stock.
      • "volume" – The number of shares traded.
      • "all" – Returns all values.
    • quote attributes (OPTIONAL – "mid" by default) Use one of the following attributes when requesting a quote:

      • "price", "mid", "mark" – The midpoint price of the stock.
      • "bid" – The bid price of the stock.
      • "ask" – The ask price of the stock.
      • "last" – The last price of the stock.
      • "bidSize" – The quantity of shares offered at the bid price.
      • "askSize" – The quantity of shares offered at the ask price.
      • "volume" – The quantity of shares traded.
      • "all" – Returns all values.
  • startDate (OPTIONAL) The start date when fetching historical data. If start date is specified, but endDate is not, only the single day’s data is returned.

  • endDate (OPTIONAL) The end date when fetching historical data, or the number of calendar days (not trading days) from startDate for which to return data.

  • resolution (OPTIONAL) The duration of each candle when fetching historical candles. Daily resolution is default if no value is specified. Use one of the following resolutions:

    • Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...)
    • Hourly Resolutions: (hourly, H, 1H, 2H, ...)
    • Daily Resolutions: (daily, D, 1D, 2D, ...)
    • Weekly Resolutions: (weekly, W, 1W, 2W, ...)
    • Monthly Resolutions: (monthly, M, 1M, 2M, ...)
    • Yearly Resolutions: (yearly, Y, 1Y, 2Y, ...)

Notes

Notes

All parameters must be enclosed in quotation marks or be references to cells containing text. A possible exception is when endDate is specified as a number of days.


Real-time or current day results will be returned as a value within a single cell unless specific attributes are requested. Historical data, even for a single day, will be returned as an expanded array with column headers.


If any date parameters are specified, the request is considered historical and only the historical attributes are allowed.


Dates and times are returned in the same timezone of the exchange.