STOCKHISTORY Function (2024)

The STOCKHISTORY function retrieves historical stock price information based on a given symbol and date range. The main purpose of STOCKHISTORY is to get the history of a financial instrument over time. Although the name suggests that STOCKHISTORY is meant to work only with stocks, STOCKHISTORY can also work with bonds, index funds, mutual funds, and currency exchange rates. Note that STOCKHISTORY retrieves multiple results. The result is an array of values that spill onto the worksheet into multiple cells.

STOCKHISTORY only returns historical information recorded after market close. If you need a current stock price, use the stock datatype, as explained here: Get current stock price.

Table of Contents

  • Primary arguments
  • Additional properties
  • Specifying the exchange
  • Example - Daily close prices
  • Example - Monthly close prices
  • Example - Make inputs variable
  • Example - Specifying additional properties
  • Example - A horizontal layout for multiple stocks
  • Example - Last 6 months
  • Example - Make exchange variable
  • Example - Retrieve currency exchange rates

Primary arguments

The STOCKHISTORY function accepts five primary arguments, and six additional property arguments to retrieve additional information. Stock and start_date are the only required arguments. Each argument is described in detail below. Additional properties are described in the table here.

  • Stock - the ticker symbol used to retrieve historical prices. Stock should be supplied as a text value in double quotes ("") when hardcoded, for example, "MSFT", "GOOG", "AAPL", "TSLA", etc. Results are retrieved from the default exchange for the instrument.
  • Start_date - The date at which to start retrieving data. Note that start_date is not necessarily the first date that will appear in the results. If the interval is set to daily (0), the first date in the results will be the first date that the exchange is open and data is available. If the interval is set to weekly (1) or monthly (2), the first date will be set to the first date in the period, i.e., the first day of the week or the first day of the month.
  • End_date - The date at which to stop retrieving data. Like start_date, the actual last date in results may be different from the end_date provided. If the interval is set to daily (0), the last date in the results will be the last date in the date range that data is available. If the interval is set to weekly (1) or monthly (2), the last date will be the last date in the period, i.e., the last day of the week or the last day of the month. End_date is optional and will default to start_date if not supplied.
  • Interval - the time period between data points. The available options are Daily (0), Weekly (1), and Monthly (2). Interval is optional and will default to Daily (0) if not provided.
  • Headers - the headers argument controls header information that will appear at the top of the data retrieved. The available options are No header (0), Basic header (1), and header with instrument information (2). Headers is optional and will default to basic header (1) when not provided.
  • Properties - six arguments for additional information that can be retrieved. See the table below for details.

Note: The safest way to provide the start_date and end_date is as a reference to a cell that contains a valid date or with the DATE function because dates as text values can sometimes be misinterpreted.

Additional Properties

The table below shows the additional information the STOCKHISTORY function can retrieve, which are described as properties. Properties are specified with the numeric code seen in the "Code" column.

CodeValueDescription
0DateThe first trading day in the period
1CloseClosing price on the last trading day in the period
2OpenThe opening price on the last trading day in the period
3HighThe highest price in the period
4LowThe lowest price in the period
5VolumeVolume traded during the period

The order in which you request properties is the order in which they will appear. See: STOCKHISTORY properties example.

Note that by default, STOCKHISTORY will return the Date and Close properties, so there is no need to ask for Date and Close if these are the only properties you need. However, if you request any properties, you will override this default behavior and will need to specify all the properties you want.

Specifying the exchange

When requesting the price for a stock symbol, results are retrieved from the default exchange for the instrument. To request information from a specific exchange, prefix the symbol with a 4-character ISO market identifier code (MIC), followed by a colon. For example, to refer to Microsoft Corporation on the Nasdaq Stock Market, use "XNAS:MSFT". 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.

Exchange NameCodeCountry
New York Stock ExchangeXNYSUnited States
Nasdaq Stock MarketXNASUnited States
London Stock ExchangeXLONUnited Kingdom

You can find a full list of supported exchange codes here.

Example - Get daily close prices for a stock

To retrieve the daily close price for Apple ("AAPL") for the month of January 2021, the formula in cell B4 is:

=STOCKHISTORY("AAPL",DATE(2021,1,1),DATE(2021,1,31))

Interval is not provided and defaults to Daily (0). Headers is not provided and defaults to Date and Close. With this configuration, the STOCKHISTORY function returns 19 results. Note that weekends are excluded and the first date retrieved is January 4 since the exchange was closed January 1-3. Also note the DATE function is used to supply the start and end dates.

STOCKHISTORY Function (1)

For a more detailed explanation, see this example.

Example - Monthly close prices

The STOCKHISTORY function can retrieve daily (0), weekly (1), and monthly (2) price data by setting a value for the interval argument. For example, toget monthly close prices for Apple, Inc. ("AAPL") for all of 2023, set the interval to 2. In the workbook below, theformula in cell B4 is:

=STOCKHISTORY("AAPL",DATE(2023,1,1),DATE(2023,12,31),2)

STOCKHISTORY Function (2)

Note that the interval argument is now provided as 2 in order to retrieve monthly results.

Note: When the interval is provided as 2, STOCKHISTORY will return the last closing price in a given month, regardless of the date. In other words, the result for the first of the month will be the same as the last day of the month.

Example - Make inputs variable

In the example below, the inputs for stock, start_date, and end_date are made variable by exposing them on the worksheet in cells F6, F7, and F8. The formula in cell B4 is:

=STOCKHISTORY(F6,F7,F8,2)

Note that the fourth argument, interval, is set to 2, which outputs monthly results.

STOCKHISTORY Function (3)

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.

Example - Additional properties

The properties returned by STOCKHISTORY can be controlled by customizing and/or reordering numbers starting with the sixth argument (property1). In the example shown below, the formula in cell B4 is:

=STOCKHISTORY(I6,I7,I8,2,1,0,5,3,4,1)

The result is monthly stock price information for The 3M Company ("MMM") for the year 2021. The properties requested include Date (0), Volume (5), High (3), Low (4), and Close (1). Notice these are the last 5 arguments in the function.

STOCKHISTORY Function (4)

Note that the reason STOCKHISTORY uses numeric codes for properties is so they can be easily reordered. In the worksheet below, we are returning the same five properties in a new order: Date, Close, High, Low, and Volume. The formula in cell B4 is now:

=STOCKHISTORY(I6,I7,I8,2,1,0,1,3,4,5)

STOCKHISTORY Function (5)

For a full list of properties with codes and descriptions, see the Properties section.

Example - A horizontal layout for multiple stocks

By default, STOCKHISTORY returns information in a vertical layout. To display results in a horizontal layout, you can use the TRANSPOSE function. In the example shown below, the formula in C5, copied down, is:

=TRANSPOSE(STOCKHISTORY(B5,DATE(2024,1,1),DATE(2024,6,1),2,0,1))

The result is the trailing monthly close price for each symbol for the first 6 months of 2024:

STOCKHISTORY Function (6)

TRANSPOSE takes what would normally be a vertical layout and converts it to a horizontal layout.

Example - last 6 months

To get the monthly close price for a list of stocks for the last 6 complete months, you can use a formula based on the TODAY function. You can see the result in the workbook below, where the formula in C5 is:

=TRANSPOSE(STOCKHISTORY(B5,EOMONTH(TODAY(),-7)+1,EOMONTH(TODAY(),-1)+1,2,0,1))

STOCKHISTORY Function (7)

This formula is dynamic and will continue to return data for the last 6 months over time. The EOMONTH function and the TODAY function are used to create a start date on the first day of the month, 6 months before the current month. 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 an example explained in greater detail here.

Notes: (1) Because the TODAY function will recalculate each time a worksheet is opened, the STOCKHISTORY function also recalculates when the worksheet is opened. (2) The trend line is created by selecting a range like C5:H5 and inserting a sparkling at Insert > Sparklines > Line.

Example - Make exchange variable

To request information from a specific exchange, prefix the symbol with a 4-character code, followed by a colon (:). In the worksheet below, the exchange is variable and entered in cell F5. The formula in cell B4 is:

=STOCKHISTORY(F5&":"&F6,F7,F8,2)

The result is the monthly close price for Caterpillar, Inc. on the Wiener-Borse exchange:

STOCKHISTORY Function (8)

If the value in F5 is changed to "XNYS," STOCKHISTORY will return Caterpillar's monthly close price on the New York Stock Exchange.

Example - Retrieve currency exchange rates

To get the currency exchange rate for a given currency pair with STOCKHISTORY, enter the two 3-letter codes separated by a colon (:) as the stock argument. For example, to get the monthly currency exchange rate between the US Dollar ("USD") and the Euro ("EUR") for the months of January 2021 through March 2021, you can use STOCKHISTORY like this:

=STOCKHISTORY("USD:EUR","1-Jan-2021","1-Mar-2021",2)

The result is an array with three months of rates:

STOCKHISTORY Function (9)

To reverse the direction of the exchange, just swap the order of the currency pairs:

=STOCKHISTORY("EUR:USD","1-Jan-2021","1-Mar-2021",2)

For a more detailed explanation, see this example.

Notes

  • If data is not available for the period requested, STOCKHISTORY returns a #VALUE! error.
  • When interval is monthly (2), STOCKHISTORY returns the latest data in a given month. In other words, you will get the latest closing price when a month is not yet complete.
  • By default, STOCKHISTORY will return the date and closing price, but this behavior can be adjusted by specifying custom properties.
  • STOCKHISTORY only returns historical information recorded after market close. If you need a current stock price, use the stock datatype, as explained here: Get current stock price.
STOCKHISTORY Function (2024)

FAQs

What does Stockhistory function do in Excel? ›

The STOCKHISTORY function retrieves historical data about a financial instrument and loads it as an array, which will spill if it's the final result of a formula. This means that Excel will dynamically create the appropriate sized array range when you press ENTER.

Why is stock history blocked in Excel? ›

The fix or issue has to do with server and authentication of online connected services. The user of excel has to authorize connected services as that is a security risk whenever an outside computer can import or have access to local computer services or apps.

How do you enable the stock function in Excel? ›

To create a table, go to Insert > Table. With the cells still selected, go to the Data tab, and then click Stocks. Select one or more cells with the data type, and the Add Column button will appear. Click that button, and then click a field name to extract more information.

How to fetch stock prices in Excel? ›

' First, you type the stock ticker symbol in a cell. Then, you go to the Data tab and click on 'Stocks. ' Excel recognizes the stock and provides real-time information. These data updates automatically.

How to get historical stock data? ›

Internet Sources for Historical Market & Stock Data
  1. Yahoo! Finance - Historical Prices. ...
  2. Dow Jones Industrial Averages. Historical and current performance data. ...
  3. S&P Indices. Historical performance data.
  4. IPL Newspaper Collection. ...
  5. Securities Industry and Financial Markets Association. ...
  6. FINRA: Market Data Center.
Jun 20, 2024

Does Excel track history? ›

History tracking

Excel can display a separate history sheet that provides a printable list of change details on which you can filter to find the changes that you are interested in.

How do I unblock blocked content in Excel? ›

Change external content settings for Excel in the Trust Center
  1. In Excel, click the File tab.
  2. Click Options > Trust Center > Trust Center Settings.
  3. On the left, select External Content.
  4. Click the option that you want under Security settings for Data Connections:

How do I remove restrictions in Excel? ›

On the Format menu, click Data Validation. In the Data Validation dialog box, click the condition that you want to remove, and then click Remove.

Why can't I see Stocks in Excel? ›

Note: The Stocks and Geography data types are only available to Microsoft 365 accounts or those with a free Microsoft Account. You must also have the English, French, German, Italian, Spanish, or Portuguese editing language added to Office Language Preferences.

How to check stock history in Excel? ›

StockHistory Function in Excel 365
  1. Enter the formula =STOCKHISTORY("MSFT","15/9/2023") in the C3 cell. The headings Date and Close are automatically generated along with the starting date and the stock value when we press the “Enter” key.
  2. Let's go with other parameters.
Dec 22, 2023

How to make a stock summary in Excel? ›

Step-by-Step Procedure to Make Stock Balance Sheet in Excel
  1. Step 1 - Create an Outline. ...
  2. Step 2 - Input Opening Stock Details. ...
  3. Step 3 - Enter Data in Stock in Column. ...
  4. Step 4 - Enter Data in Stock Out. ...
  5. Step 5 - Calculate Balance Stock.
Aug 7, 2023

What is the formula for stock in Excel? ›

Stock Level: =[@[INITIAL STOCK]]+[@INCOMINGS]=[@OUTGOINGS] Excel can combine the formulas you have already into a new formula so you can see what your current stock level is based on the incomings and outgoings.

What is the function of Stockhistory? ›

The STOCKHISTORY function retrieves historical stock price information based on a given symbol and date range. The main purpose of STOCKHISTORY is to get the history of a financial instrument over time.

How to have Excel automatically update stock prices? ›

Here's how: Right-click a data type in your workbook, and then select “Data Type” > “Refresh Settings”. In the “Data Types Refresh Settings” pane, select the option you want. You can choose to refresh when you open the file, manually, or automatically every five minutes.

How do I keep track of stock in Excel? ›

1. Find an inventory template
  1. Open Excel or if Excel is already open, select File > New.
  2. In the search box, type "inventory" or something similar.
  3. Browse the results. ...
  4. Once you've found the one you like, select Create.
  5. The template will open in Excel.

What is the purpose of the stock chart in Excel? ›

Data that is arranged in columns or rows in a specific order on an Excel sheet can be plotted in a stock chart. As its name implies, a stock chart is most frequently used to show the fluctuation of stock prices. However, this chart may also be used for scientific data.

How to do stock keeping in Excel? ›

The following are steps to keep track of inventory using Excel:
  1. Create a spreadsheet. To create a new spreadsheet, you can open Excel, click on "Menu", and select "New". ...
  2. Add product categories as columns. ...
  3. Add each product to the spreadsheet. ...
  4. Adjust quantities as the company's products change.
Feb 12, 2024

What is the use of Excel in stock market analysis? ›

Traders looking to back-test a model or strategy can use simulated prices to validate its effectiveness. Excel can help with your back-testing using a monte carlo simulation to generate random price movements. Excel can also be used to compute historical volatility to plug into your models for greater accuracy.

What is stock market functions Excel add in? ›

The SMF (Stock Market Functions) add-in adds a number of functions to EXCEL that can allow data to be extracted and/or retrieved from the web and placed directly into EXCEL cells or ranges. This website contains the add-in and its supporting files -- documentation, templates, FAQs, etc.

Top Articles
Employee Assessments: HR Terms Explained | Pelago
I can't make a payment
Star Wars Mongol Heleer
Craigslist Monterrey Ca
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Brady Hughes Justified
Occupational therapist
Napa Autocare Locator
Atvs For Sale By Owner Craigslist
Western Union Mexico Rate
Koordinaten w43/b14 mit Umrechner in alle Koordinatensysteme
How To Get Free Credits On Smartjailmail
Steve Strange - From Punk To New Romantic
About Goodwill – Goodwill NY/NJ
My.doculivery.com/Crowncork
Sotyktu Pronounce
Aita Autism
Craigslist Pets Southern Md
Winterset Rants And Raves
7543460065
Hanger Clinic/Billpay
Rondom Ajax: ME grijpt in tijdens protest Ajax-fans bij hoofdbureau politie
Walmart Car Department Phone Number
Iroquois Amphitheater Louisville Ky Seating Chart
Minnick Funeral Home West Point Nebraska
Filthy Rich Boys (Rich Boys Of Burberry Prep #1) - C.M. Stunich [PDF] | Online Book Share
Ou Class Nav
Jeff Nippard Push Pull Program Pdf
Piri Leaked
Die 8 Rollen einer Führungskraft
Narragansett Bay Cruising - A Complete Guide: Explore Newport, Providence & More
Solo Player Level 2K23
Ringcentral Background
Mark Ronchetti Daughters
Martin Village Stm 16 & Imax
Audi Q3 | 2023 - 2024 | De Waal Autogroep
Dmitri Wartranslated
Craiglist Hollywood
Htb Forums
Gary Lezak Annual Salary
Riverton Wyoming Craigslist
RECAP: Resilient Football rallies to claim rollercoaster 24-21 victory over Clarion - Shippensburg University Athletics
The Conners Season 5 Wiki
Smite Builds Season 9
Blackwolf Run Pro Shop
Dickdrainersx Jessica Marie
Celsius Claims Agent
CrossFit 101
Keci News
Legs Gifs
Is My Sister Toxic Quiz
Heat Wave and Summer Temperature Data for Oklahoma City, Oklahoma
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 5623

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.