The code is here.
The code to estimate the daily squared deviation for each day in the trading period, and for each pair, is here trading_period.
This code will test whether a stock has a significant alpha over the last 5040 calendar days. It will then calculate alpha and beta over each 30 day subinterval and test whether alpha in one period can be used to predict alpha in the next period. The time series of alphas and betas are also plotted. The code is here: time_series_alpha.
I have totally rewritten the pairs trade estimation period code. It will create a csv file in your working directory which has the average squared deviation, and the standard deviation of the squared deviations, for all pairs. The csv is sorted from lowest (best pair) to highest (worst pair) average squared deviation. The code is here estim_period.
See the R markdown page here: alpha_across_firms.
This page shows how the portfolio frontier (of 2 assets) varies given an increasing correlation coefficient between the two assets. If you paste the code into R you can see the variation.
The link below is to R functions which allow you to calculate the 5% and 1% VaR for any stock, using any amount of historical data.
I have reposted the code to test for skewness and kurtosis in the link below. The page is the HTML output generated by using R Markdown and knitr.