# Section 5: Predicting Future Stock Behavior

In this lesson, you will try to predict future stock behavior.

We'll cover the following

There are two main techniques used to analyze stock behavior.

1. Fundamental analysis: This mostly deals with the intrinsic value of companies based on the various changes in their financials on a regular basis.

2. Technical analysis: This provides results based on the historical data of a company’s stock.

Fundamental analysis is beyond the scope of this course, and the information required for it is also not easily accessible.

Until now, our focus has been on technical analysis, as we calculated various results from the historical data of the companies. However, these techniques won’t help us predict the random and irregular behavior of stocks.

## Random walk theory

Many analysts believe that the stock market prices follow the random walk theory. This theory states the following:

The stock market may take random, irregular, and unpredictable paths in determining the prices of stocks. It also assumes that past trends are useless in predicting future prices and that the future price only depends on the current price of the stock.

Detailed information about this theory can be found here. This theory rejects both fundamental and technical analysis techniques with rational arguments.

We will also use the random walk theory to determine the future behavior of stocks. The Monte Carlo simulations will be deployed to assess the results using this theory.

## MonteCarlo simulations

This method uses randomness to solve problems. It converts the randomness in the variables into probability distributions. It then generates a range of future price values in a normal distribution instead of just one value. More detailed information about this can be found here.

The following is the formula for MonteCarlo simulations:

$S_{t+1}=S_{t}*e^{Drift+Rv}$

$Drift=AveragedDailyReturn-DailyReturnVariance/2$

$Rv=STD*NORMSINV(RAND())$

Here, $S_{t+1}$ is the future price of a stock. $S_{t}$ is the current price of a stock. e is the universal constant. Drift and Rv are represented by their formulas. The Drift component represents the direction of stock, whether it’ll go up or down. The Rv is our random variable; which either pushes the stock price up or down. More information on the NORMSINV() function can be found here.

### Implementation

Now, let’s see monte-carlo simulations in action by predicting future stock price values of the Systems Ltd company. Our final range of predictions will be in a multidimensional NumPy array that will be plotted to get the predicted range of future prices.

Before computing the results from the formula, some extra variables need to be calculated. We learned how to calculate daily returns for our stocks in the previous lesson. For this exercise, logarithmic returns will be calculated instead of daily returns, as they provide more concise information.

#### Calculating drift

Here we show how drift is calculated using logarithmic daily returns.

Get hands-on with 1000+ tech skills courses.