# Portfolio Analysis Basics: Volatility and Sharpe Ratio

## In this story, we are going to discuss why volatility is so important and how to assess its impact on return.

When we look at a stock or any type of investments, the first thing we care about is usually how much money we can make from it, in other words, the returns of the investments. However, there is actually quite a bit more to it than just that. Here we’ll demonstrate with an example.

First things first, I need some stock prices and their daily returns to do analysis on. So, I am going to generate 4 different price time series and compare them to see which one I want to buy!

## Price Simulation

In order to do that, I am going to use the **Geometric Brownian Motion (GBM) **process that I mentioned in an earlier story (link):

import pandas as pd

import numpy as npdef daily_returns(prices): # cur_price / prev_price - 1.0 = daily_returns

res = (prices/prices.shift(1) - 1.0)[1:]

res.columns = ['return']

return res

def brownian_prices(start, end,

mu=0.0001, sigma=0.01, s0=100.0):

bdates = pd.bdate_range(start, end)

size = len(bdates)

np.random.seed(1)

wt = np.random.standard_normal(size) # GBM process

st = s0 * np.cumprod(

np.exp(mu - (sigma * sigma / 2.0)

+ sigma * wt))

return pd.DataFrame(data={'date': bdates,

'price': st}).set_index('date')

With this process, here are my 4 stock price time series:

`start = '20100101'`

end = '20200101'

returns1 = daily_returns(brownian_prices(start,

end,

mu=0.002,

sigma=0.01,

s0=100.0))

returns2 = daily_returns(brownian_prices(start,

end,

mu=0.002,

sigma=0.02,

s0=100.0))

returns3 = daily_returns(brownian_prices(start…