How to Use Excel to Simulate Stock Prices (2024)

Some active investors model variations of a stock or other asset to simulate its price and that of the instruments that are based on it, such as derivatives. Simulating the value of an asset on an Excel spreadsheet can provide a more intuitive representation of its valuation for a portfolio.

Key Takeaways

  • 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.

Building a PricingModel Simulation

Whether we are considering buying or selling a financial instrument, the decision can be aided by studying it both numerically and graphically. This data can help us judge the next likely move that the asset might make and the moves that are less likely.

First of all, the model requires some prior hypotheses. We assume, for example, that the daily returns, or "r(t)," of these assets are normally distributed with themean, "(μ)," and standard deviation sigma, "(σ)." These are the standard assumptions that we will use here, though there are many others that could be used to improve the accuracy of the model.

r(t)=S(t)S(t1)S(t1)N(μ,σ)where:S(t)=closetS(t1)=closet1\begin{aligned} &r ( t ) = \frac { S ( t ) - S ( t - 1 ) }{ S ( t - 1 ) } \sim N ( \mu, \sigma ) \\ &\textbf{where:} \\ &S ( t ) = \text{close}_t \\ &S ( t - 1 ) = \text{close}_{t - 1} \\ \end{aligned}r(t)=S(t1)S(t)S(t1)N(μ,σ)where:S(t)=closetS(t1)=closet1

Which gives:

r(t)=S(t)S(t1)S(t1)=μδt+σϕδtwhere:δt=1day=1365ofayearμ=meanϕN(0,1)σ=annualizedvolatility\begin{aligned} &r ( t ) = \frac { S ( t ) - S ( t - 1 ) }{ S ( t - 1 ) } = \mu \delta t + \sigma \phi \sqrt { \delta t } \\ &\textbf{where:} \\ &\delta t = 1 \ \text{day} = \frac { 1 }{ 365 } \ \text{of a year} \\ &\mu = \text{mean} \\ &\phi \cong N ( 0, 1 ) \\ &\sigma = \text{annualized volatility} \\ \end{aligned}r(t)=S(t1)S(t)S(t1)=μδt+σϕδtwhere:δt=1day=3651ofayearμ=meanϕN(0,1)σ=annualizedvolatility

Which results in:

S(t)S(t1)S(t1)=μδt+σϕδt\begin{aligned} &\frac { S ( t ) - S ( t - 1 ) }{ S ( t - 1 ) } = \mu \delta t + \sigma \phi \sqrt { \delta t } \\ \end{aligned}S(t1)S(t)S(t1)=μδt+σϕδt

Finally:

S(t)S(t1)=S(t1)μδt+S(t1)σϕδtS(t)=S(t1)+S(t1)μδt+S(t1)σϕδtS(t)=S(t1)(1+μδt+σϕδt)\begin{aligned} S ( t ) - S ( t - 1 ) = & \ S ( t - 1 ) \mu \delta t + S ( t - 1 ) \sigma \phi \sqrt { \delta t } \\ S ( t ) = & \ S ( t - 1 ) + S ( t - 1 ) \mu \delta t \ + \\ & \ S ( t - 1 ) \sigma \phi \sqrt { \delta t } \\ S ( t ) = & \ S ( t - 1 ) ( 1 + \mu \delta t + \sigma \phi \sqrt { \delta t } ) \\ \end{aligned}S(t)S(t1)=S(t)=S(t)=S(t1)μδt+S(t1)σϕδtS(t1)+S(t1)μδt+S(t1)σϕδtS(t1)(1+μδt+σϕδt)

And now we can express the value of today’s closing price using the prior day close.

  • Computation of μ:

To compute μ, which is the mean of the daily returns, we take the n successive past close prices and apply, which is the average of the sum of the n past prices:

μ=1nt=1nr(t)\begin{aligned} &\mu = \frac { 1 }{ n } \sum_{ t = 1 } ^ { n } r ( t ) \\ \end{aligned}μ=n1t=1nr(t)

  • The computation of the volatility σ - volatility

φ is a volatility with an average of random variable zero and standard deviation one.

Computing Historical Volatility in Excel

For this example, we will use the Excel function "=NORMSINV (RAND ())."With a basis from the normal distribution, this function computes a random numberwith a mean of zero and a standard deviation of one. To compute μ, simply average the yields using the function Ln (.): the log-normaldistribution.

In cell F4, enter "Ln (P (t) / P (t-1)"

How to Use Excel to Simulate Stock Prices (1)

In the F19 cell search "= AVERAGE (F3:F17)"

How to Use Excel to Simulate Stock Prices (2)

In cell H20, enter “=AVERAGE(G4:G17)

How to Use Excel to Simulate Stock Prices (3)

In cell H22, enter "= 365*H20" to compute the annualized variance

How to Use Excel to Simulate Stock Prices (4)

In cell H22, enter "= SQRT(H21) " to compute the annualized standard deviation

How to Use Excel to Simulate Stock Prices (5)

So we now have the "trend" of past daily returns and the standard deviation (the volatility). We can applyour formula found above:

S(t)S(t1)=S(t1)μδt+S(t1)σϕδtS(t)=S(t1)+S(t1)μδt+S(t1)σϕδtS(t)=S(t1)(1+μδt+σϕδt)\begin{aligned} S ( t ) - S ( t - 1 ) = & \ S ( t - 1 ) \mu \delta t + S ( t - 1 ) \sigma \phi \sqrt { \delta t } \\ S ( t ) = & \ S ( t - 1 ) + S ( t - 1 ) \mu \delta t \ + \\ & \ S ( t - 1 ) \sigma \phi \sqrt { \delta t } \\ S ( t ) = & \ S ( t - 1 ) ( 1 + \mu \delta t + \sigma \phi \sqrt { \delta t } ) \\ \end{aligned}S(t)S(t1)=S(t)=S(t)=S(t1)μδt+S(t1)σϕδtS(t1)+S(t1)μδt+S(t1)σϕδtS(t1)(1+μδt+σϕδt)

We will do a simulation over 29 days, thereforedt = 1/29.Our starting point is the last close price: 95.

  • In the cell K2, enter "0."
  • In the cell L2, enter "95."
  • In the cell K3, enter "1."
  • In the cell L3, enter "= L2 * (1 + $F$19 * (1/29) + $H$22 *SQRT(1/29)*NORMSINV (RAND ()))."

Next, we dragthe formula down the column to complete the entire series of simulated prices.

How to Use Excel to Simulate Stock Prices (6)

This model allows us to find a simulation of the assets down to 29 dates given, with the same volatility as the former 15 prices we selected and with a similar trend.

How to Use Excel to Simulate Stock Prices (7)

Lastly, we can click on "F9" to start another simulation since we have the rand function as part of the model.

How to Use Excel to Simulate Stock Prices (2024)

FAQs

How to simulate stock prices in Excel? ›

For this example, we will use the Excel function "= NORMSINV (RAND ())." With a basis from the normal distribution, this function computes a random number with a mean of zero and a standard deviation of one. To compute μ, simply average the yields using the function Ln (.): the log-normal distribution.

Is there a way to pull stock prices into Excel? ›

To insert a stock price into Excel, first convert text into the Stocks data type. Then you can use another column to extract certain details relative to that data type, like the stock price, change in price, and so on.

How do I get Excel to 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 you simulate stock prices? ›

In regard to simulating stock prices, the most common model is geometric Brownian motion (GBM). GBM assumes that a constant drift is accompanied by random shocks. While the period returns under GBM are normally distributed, the consequent multi-period (for example, ten days) price levels are lognormally distributed.

How to generate simulation in Excel? ›

Running a Simulation Using Microsoft Excel
  1. Open a new Excel spreadsheet.
  2. Enter a heading at the top of a column, if desired.
  3. Under “Tools” click on “Data Analysis.”
  4. Find “Random Number Generation,” and double-click on it or highlight it and click OK.

Does Excel have a stock price function? ›

You can get stock and geographic data in Excel. It's as easy as typing text into a cell, and converting it to the Stocks data type, or the Geography data type. These two data types are considered linked data types because they have a connection to an online data source.

What is the formula for the stock price? ›

We can calculate the stock price by simply dividing the market cap by the number of shares outstanding. Let's now think about why we can calculate it this way. The Market Cap (aka Market Capitalization) reflects the market value of the equity of the company.

Can I use Excel for stock control? ›

Keeping track of your business inventory, whether it's stock to sell to customers or key assets for your business, is very important. Using Excel makes this task easier. You can use a free downloadable template or build out your own, helping you save time and stay on top of your inventory.

How do I plot stock prices in Excel? ›

First, select the range of cells, then click on insert, and then click on the "See All Charts Arrow". Then click on all charts, click on stock, select volume open high low close chart, and click OK. Select cells > Insert > All charts > Stock > Volume Open High Low > Ok.

What is the best Excel add in for stock prices? ›

Getting Stock Fundamental and Real-time Data

Wisesheets is a fantastic Excel stock add-in that makes bringing stock data into your spreadsheets easy. With Wisesheets, you can access both real-time and historical stock information, such as prices, financials, dividends, and key metrics.

How to use GOOGLEFINANCE function in Excel? ›

To use the GOOGLEFINANCE function, you need to provide the necessary parameters such as the stock symbol, the attribute you want to fetch, and optional parameters like the start and end dates for historical data. For example, =GOOGLEFINANCE("AAPL", "price") will fetch the current stock price for Apple Inc.

What is the formula for calculating 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.

How to use Excel for stock market? ›

- Excel Data Types: Use the "Stocks" data type feature in Excel 365 or Excel 2019 to automatically pull in current stock prices and other financial information directly into your spreadsheet.

How do you pull stock price data? ›

Online brokerage sites such as eTrade and TD Ameritrade or apps like Robinhood will have both real-time and historical quote data for customers and usually limited access for non-customers as well. Financial websites like Motley Fool or Google Finance will also provide quote information for both stocks and indices.

What is the stock market price simulator? ›

The stock simulator is a software program that mirrors the fluctuations of real-life stock prices. Once the new user registers, they receive a specific sum of virtual money that can be used to purchase virtual stocks at current market rates.

How do I generate random prices in Excel? ›

If you want to use RAND to generate a random number but don't want the numbers to change every time the cell is calculated, you can enter =RAND() in the formula bar, and then press F9 to change the formula to a random number. The formula will calculate and leave you with just a value.

How do I add the stockhistory function 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

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 5844

Rating: 4.8 / 5 (78 voted)

Reviews: 85% 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.