We explore one of the main assumption of quantitative finance: assets returns are random.
R-code
quant-finance
Author
Francois de Ryckel
Published
April 18, 2023
Modified
April 20, 2023
One of the main pillar of quantitative finance is the assumption that assets’ returns behave in a random manner. Assets returns are normally distributed. It is a poor assumption as asset’s return are usually not normally distributed (fat tails, skewness, etc.), but it is one that is considered when approaching finance with a quantitative finance. Check this post on the normality of assets returns for a deeper dive into how random (or not) are assets returns.
Knowing the average daily return of SBUX over the last 3-ish year and using \(\bar{R} = \mu \delta t\) , or \(\mu = \frac{\bar{R}}{\delta t}\) and in our case \(\delta t = \frac{1}{252}\); we find the average annualized returns \(\mu\) is: -0.027 % with standard deviation \(\sigma\) of 33.2 % annualized.
We could plot the returns and the std of returns
library(ggplot2)ggplot(df |>drop_na(), aes(x = date, y = ret)) +geom_line() +geom_hline(yintercept = stdev, linetype ='dotted', color ='red', linewidth=0.8) +geom_hline(yintercept =-stdev, linetype ='dotted', color ='red', linewidth =0.8) +geom_hline(yintercept =2*stdev, linetype ='dotted', color ='red', linewidth=1) +geom_hline(yintercept =-2*stdev, linetype ='dotted', color ='red', linewidth =1) +xlab(label ='Date') +ylab(label ='Daily returns') +labs(title ='Daily returns')
We could standardized the returns (aka ensure they have a mean = 0 and std = 1) and compare it to the standard normal distribution.
This graph exemplifies what is very common with asset returns: fat tail, and under representation of returns just outside the mean. We discuss this further in our post: The normality of asset returns
The Euler-Maruyana Method to compute the SDE
We start with Equation 6 : \(S_{i+1} = S_i \cdot (1 + \mu \delta t + \sigma \phi \sqrt{\delta t})\)
# create one simulation for price ndays <-252price <-c()price[1] <-last(df$adjClose)phi =rnorm(ndays, mean =0, sd =1)for (i in2:ndays){ price[i] = price[i-1] * (1+ mu * delta_t + sigma * phi[i] *sqrt(delta_t))}yo <-tibble(x =1:ndays, price = price)ggplot(yo, aes(x, price)) +geom_line()
We can now create 100’s such simulations re-using previous code in a function.