The main purpose of STOCKHISTORY is to get the history of a financial instrument over time.
Note that STOCKHISTORY retrieves multiple results.
The result is anarrayof values thatspillonto the worksheet into multiple cells.
Each argument is described in detail below.
Additional properties are described in thetable here.
Properties are specified with the numeric code seen in the “Code” column.
The order in which you request properties is the order in which they will appear.
See:STOCKHISTORY properties example.
To refer to Microsoft Corporation on Austria’s Wiener Boerse exchange, use “XWBO:MSFT”.
The table below lists the 4-character code for a few common exchanges.
you might find a full list of supported exchange codeshere.
With this configuration, the STOCKHISTORY function returns 19 results.
Also note theDATE functionis used to supply the start and end dates.
For a more detailed explanation,see this example.
The result is the close price for Tesla (“TSLA”) for the 12 months in 2021.
If the values in F6:F8 are changed, the results from STOCKHISTORY will automatically update.
Notice these are thelast 5 argumentsin the function.
Note that the reason STOCKHISTORY uses numeric codes for properties is so they can be easily reordered.
Example - A horizontal layout for multiple stocks
By default, STOCKHISTORY returns information in averticallayout.
To display results in ahorizontallayout, it’s possible for you to use theTRANSPOSE function.
The end date is created in the same way and is the first day of the previous month.
The formula here is a variation of anexample explained in greater detail here.
In the worksheet below, the exchange is variable and entered in cell F5.