Journalism Finance - v2.0.6
    Preparing search index...

    Function getYahooFinanceData

    • Fetches historical prices or trading volume for a symbol from Yahoo Finance.

      Yahoo Finance notice: This function uses an undocumented Yahoo Finance endpoint and is not affiliated with or endorsed by Yahoo. It is provided for educational, research, and journalistic purposes. Before using it, review Yahoo's terms and any applicable data-provider restrictions.

      Parameters

      • symbol: string

        The stock or index symbol, such as "AAPL" or "^GSPTSE".

      • startDate: Date

        The inclusive start of the requested range.

      • endDate: Date

        The inclusive end of the requested range. The observation beginning at this date or time is included when available.

      • variable: "open" | "high" | "low" | "close" | "adjclose" | "volume"

        The financial variable to retrieve.

      • interval: "1d" | "1h" | "1m"

        The interval between observations: daily, hourly, or every minute.

      Returns Promise<{ timestamp: number; value: number }[]>

      The available observations, with Unix timestamps in milliseconds. Missing values reported by Yahoo are omitted.

      const prices = await getYahooFinanceData(
      "^GSPTSE",
      new Date("2025-03-01"),
      new Date("2025-03-15"),
      "adjclose",
      "1d",
      );
      console.log(prices);

      If either date is invalid or endDate is before startDate.

      If Yahoo rejects the request, returns no data, or provides invalid timestamps.