{
  "category": "Information functions",
  "display_name": "STOCKHISTORY",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.STOCKHISTORY",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Deferred by policy: the answer needs Microsoft's market data service. DNA Calc does not run this function yet.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": false,
    "state": "deferred",
    "state_label": "Deferred: needs an outside service",
    "summary": "Deferred: needs an outside service",
    "workbook_corpus": null
  },
  "implementations": [],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.STOCKHISTORY.json",
  "name": "STOCKHISTORY",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n- The Stocks data type with `FIELDVALUE` for current fields.\n- Power Query against a data source you license, for a stored and repeatable history.\n- Recording a result as values, when a report has to stay fixed.\n\n\n",
    "how-to-implement": "\nDNA Calc does not run this function yet. It is deferred by policy, because the data comes from a back end Microsoft\nhosts and controls. An implementation needs:\n\n1. **A licensed data feed** with the same instruments, exchanges and adjustment rules.\n2. **Period logic:** trading calendars per exchange, for the first valid day of each period.\n3. **Column assembly:** an array built from `property` order, with `headers` rows.\n4. **Asynchronous calculation** with a result that can spill late, and a failure outcome such as `#CONNECT!`.\n5. **Argument rules** for tickers, data types, exchange prefixes and date coercion.\n\nAnswers would depend on the provider chosen, so another feed could not promise Excel's values.\n\n\n",
    "quirks": "\n- **The first row can precede `start_date`.** Non-daily intervals report the first day of the period that holds\n  the date. Daily and weekly rows use the first valid trading day; monthly rows use the first calendar day.\n- **Each column is a period summary.** Close is the last trading day's close, Open the first day's open, High and\n  Low the period's extremes, Volume the total.\n- **Today is missing until the market closes.** Data generally updates after the trading day ends.\n- **Some instruments have no history.** Microsoft notes that many index funds and some other items offered as\n  Stocks data types have none.\n- **Column order is yours.** Date appears only if requested, or by default.\n- **Headers add a row.** The default output is one row taller than the data, which matters to any formula indexing\n  into the result.\n- **No formatting is applied**, so cells go back to General if the formula is removed.\n\n### When the service is unavailable\n\nMicrosoft's function page does not say what happens when the service cannot be reached. Its general article\nsays `#CONNECT!` means a formula could not reach a resource it needs. A Microsoft Q&A answer, which is not official\ndocumentation, reports that error for this function. With volatile functions such as `TODAY` and automatic\ncalculation, data refreshes in the background when the workbook opens, and editing continues meanwhile. A\nsubscription is also needed: Microsoft lists Microsoft 365 Personal, Family, Business Standard and Business Premium.\nNo failure of this function has been recorded here.\n\n\n",
    "sources": "\n- [STOCKHISTORY function](https://support.microsoft.com/en-us/excel/functions/stockhistory-function)\n- [How to correct a #CONNECT! error](https://support.microsoft.com/en-us/office/how-to-correct-a-connect-error-584f7de9-b238-480c-8e8f-de0ba2c1aac9)\n- [About the Stocks financial data sources](https://support.microsoft.com/en-us/excel/about-the-stocks-financial-data-sources?ui=en-us&rs=en-us&ad=us)\n- [Microsoft Q&A: resolving the #CONNECT! error](https://learn.microsoft.com/en-us/answers/questions/5861729/how-to-resolve-the-connect-error)\n\n",
    "version-differences": "\nNo Excel answers for this function are recorded here, so no comparison between Excel builds exists. Microsoft's page lists Excel for Microsoft 365 on Windows and Mac. Past prices can also\nchange at the provider, so an old answer is not a stable reference.\n\n\n",
    "what-it-does": "\n`STOCKHISTORY` fetches historical prices for one instrument and spills them as a table of ordinary numbers and\ndates. The values come from Microsoft's data provider, not from the workbook.\n\n`STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], ..., [property5])`\n\n- **`stock`** is a ticker in double quotes, or a cell holding a Stocks data type. To name an exchange, put its\n  four-character market identifier code and a colon first, as in `\"XNAS:MSFT\"`.\n- **`start_date`** is the first date requested.\n- **`end_date`** defaults to `start_date`, so leaving it out asks for one period, not for data up to today.\n- **`interval`** is 0 daily (default), 1 weekly or 2 monthly.\n- **`headers`** is 0 none, 1 headers (default), or 2 instrument identifier and headers.\n- **`property0`** to **`property5`** choose the columns, in the order you list them:\n\n| Code | Column |\n|---|---|\n| 0 | Date |\n| 1 | Close |\n| 2 | Open |\n| 3 | High |\n| 4 | Low |\n| 5 | Volume |\n\nThe default columns are Date and Close.\n\n\n"
  },
  "signature": {
    "display": "STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], [property1], [property2], [property3], [property4], [property5])",
    "parameters": [
      {
        "description": null,
        "name": "stock",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "start_date",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "end_date",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "interval",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "headers",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property0",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property1",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property2",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property3",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property4",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "property5",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "deferred",
        "reason": "Deferred by policy: the answer needs Microsoft's market data service. DNA Calc does not run this function yet."
      },
      "arity": {
        "max": 11,
        "min": 2
      },
      "category": "Information functions",
      "classification": {},
      "descriptions": {
        "long": null,
        "short": "Historical prices of a financial instrument over a date range",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Retrieves historical data about a financial instrument",
        "microsoft_url": "https://support.microsoft.com/en-us/office/stockhistory-function-1ac8b5b3-5f62-4d94-8ab8-7504ec7239a8"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "bg-BG",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "cs-CZ",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "da-DK",
          "name": "AKTIEHISTORIK"
        },
        {
          "locale": "de-DE",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "el-GR",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "en-AU",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "en-GB",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "en-US",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "es-ES",
          "name": "HISTORIALCOTIZACIONES"
        },
        {
          "locale": "et-EE",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "fi-FI",
          "name": "OSAKEHISTORIA"
        },
        {
          "locale": "fr-FR",
          "name": "HISTORIQUE.ACTIONS*"
        },
        {
          "locale": "he-IL",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "hr-HR",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "hu-HU",
          "name": "RÉSZVÉNY.ELŐZMÉNYEK"
        },
        {
          "locale": "id-ID",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "it-IT",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "ja-JP",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "ko-KR",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "lt-LT",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "lv-LV",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "nb-NO",
          "name": "AKSJEHISTORIKK"
        },
        {
          "locale": "nl-NL",
          "name": "AANDELENGESCHIEDENIS"
        },
        {
          "locale": "pl-PL",
          "name": "HISTORIA.AKCJI"
        },
        {
          "locale": "pt-BR",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "pt-PT",
          "name": "HISTÓRICODEAÇÕES"
        },
        {
          "locale": "ro-RO",
          "name": "ISTORIC STOC"
        },
        {
          "locale": "ru-RU",
          "name": "ИСТОРИЯАКЦИЙ"
        },
        {
          "locale": "sk-SK",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "sl-SI",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "sv-SE",
          "name": "AKTIEHISTORIK"
        },
        {
          "locale": "th-TH",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "tr-TR",
          "name": "STOKGEÇMİŞİ"
        },
        {
          "locale": "uk-UA",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "vi-VN",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "zh-CN",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "zh-HK",
          "name": "STOCKHISTORY"
        },
        {
          "locale": "zh-TW",
          "name": "STOCKHISTORY"
        }
      ],
      "signature": {
        "display": "STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], [property1], [property2], [property3], [property4], [property5])",
        "parameters": [
          {
            "description": null,
            "name": "stock",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "start_date",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "end_date",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "interval",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "headers",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property0",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property1",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property2",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property3",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property4",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "property5",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "STOCKHISTORY",
      "version_marker": null,
      "xlcall": null
    },
    "microsoft": "https://support.microsoft.com/en-us/office/stockhistory-function-1ac8b5b3-5f62-4d94-8ab8-7504ec7239a8"
  },
  "try_it": {
    "formula": "=STOCKHISTORY(\"MSFT\",DATE(2026,1,1),DATE(2026,1,8))",
    "note": "This example needs an Excel service or external provider that OneCalc cannot supply in this preview.",
    "preview_status": "refused"
  },
  "url": "https://handbook.dnacalc.com/functions/STOCKHISTORY.html",
  "variants": [],
  "versions": []
}