Berkshire Hathaway (The most expensive stock ever in the world)

1.1 Download data

require(quantmod)
data_env <- new.env()
getSymbols(Symbols = 'BRK-A',env = data_env)
brka_close <- do.call(merge, eapply(data_env, Cl))

1.2 Overview

1.2.1 Returns

Method 1

library(fImport)
yield <- returns(brka_close)
head(yield)

Method 2

library(zoo)
# unit in percentage terms
yield_simple <- diff(brka_close) / lag(brka_close, k = -1) * 100
# coredate method: indicate we only care about price column, not the date
summary(coredata(yield_simple))

The biggest single-day loss is 14.90%, we can find out the date by:

yield_simple[which.min(yield_simple)]

1.2.2 Distribution of returns

hist(yield_simple, breaks = 100,
main = 'Histogram of Simple Returns', xlab = '%')

1.2.3 Simple VaR calculation

To determine the 1-day 99% VaR:

quantile(yield_simple,na.rm = T, probs = 0.01)

Thus, the prob. that yield below 3.6894% on any given day is only 1%. If that day comes, 3.6894% is the minimum amount we will lose.

1.3 Modeling the price

require(forecast)
mod <- auto.arima(yield, stationary = T, seasonal = F, ic = 'aic')

AR(2) process didn't appear in the result below, which indicates that historic returns don't depend on earlier periods, i.e.,it depends on stochastic terms.

#compute confidence interval
tsdiag(mod)

Time series diagnosis below, firstly there were volatility clusters in standard residuals throughout time, secondly no autocorrelations exisit within residuals in ACF test, thirdly, Ljung-Box show p-values small to reject null hypothesis.

Time Series_1_BRKA Case的更多相关文章

  1. C#中,switch case语句中多个值匹配一个代码块的写法

    switch (num) { case 1: Response.Write("1"); break; case 2: case 3: Response.Write("2| ...

  2. Android Studio快捷键switch case 轻松转换为if else

    Android Studio快捷键switch case 轻松转换为if else 今天碰到的问题,没有找到资料,后面找到了方法,这个记下来,转载请注明出处:http://www.cnblogs.co ...

  3. 你真的会玩SQL吗?Case也疯狂

    你真的会玩SQL吗?系列目录 你真的会玩SQL吗?之逻辑查询处理阶段 你真的会玩SQL吗?和平大使 内连接.外连接 你真的会玩SQL吗?三范式.数据完整性 你真的会玩SQL吗?查询指定节点及其所有父节 ...

  4. java中的switch case

    switch-case语句格式如下 switch(变量){ case 变量值1: //; break; case 变量值2: //...; break; ... case default: //... ...

  5. sql case when...then...else...end 选择判断

    达到的需求为: 吓数收回日期为空:当接单日期不等于空和当天减接单日期大于3天时,为1,否则为0:当接单日期为空.最大发织交期不等于空和当天减去最大发织交期大于3天时,为1,否则为0:当接单日期和发织交 ...

  6. C# 中Switch case 返回不止用break

    Switch(temp) { case "A": //跳出循环 break; case "B": //返回值 return var; case "C& ...

  7. SQL --- Case when 的使用方法

    1. Case具有两种格式.简单Case函数和Case搜索函数. --简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE '其他' E ...

  8. 2.3switch case 语句注意事项。

    #include<stdio.h> int main() { void action1(int, int),action2(int, int); char ch; , b=; ch = g ...

  9. sh4.case语句

    case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构.case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令.case语句格式如下: ...

随机推荐

  1. SprintBoot学习(一)

    Spring Boot是什么? 1. SpringBoot是一个框架,一种全新的编程规范,他的产生简化了框架的使用,所谓简化是指简化了Spring众多框架中所需的大量且繁琐的配置文件,所以 Sprin ...

  2. 吴裕雄--天生自然Numpy库学习笔记:NumPy 算术函数

    NumPy 算术函数包含简单的加减乘除: add(),subtract(),multiply() 和 divide(). 需要注意的是数组必须具有相同的形状或符合数组广播规则. import nump ...

  3. UVA10723 电子人的基因

    UVA10723 电子人的基因 题目比较难找附上链接:https://vjudge.net/problem/UVA-10723 题目描述: 给你两个字符串,你需要找出一个最短的字符串,使得两个给定字符 ...

  4. 给Linux系统运维新手的四点建议

    随着计算机的普及.互联网的发展,原本黑客手中的攻城利器---Linux,渐渐进入到普通群众的视线里,让越来越多的人接触到Linux,并学习Linux进而投身到Linux运维工作中去. 学习Linux的 ...

  5. springMVC读取本地图片显示到前端页面

    @RequestMapping("/getImage") @ResponseBody public void getImagesId(HttpServletResponse rp) ...

  6. Tensorflow机器学习入门——ModuleNotFoundError: No module named 'tensorflow.keras'

    这个bug的解决办法: # from tensorflow.keras import datasets, layers, models from tensorflow.python.keras imp ...

  7. js 字符串相关函数

    https://www.jb51.net/article/74614.htm

  8. 2 CSS盒子模型&边框&轮廓&外边距&填充&分组嵌套&尺寸&display与visibility

    盒子模型 Box  Model 所有HTML元素可以看做盒子,CSS模型本质上是一个盒子,封装周围的HTML元素 包括:边距,边框,填充和实际内容 盒子模型允许我们在其他元素和周围元素边框之间的空间放 ...

  9. spring boot中不能识别RestController

    参考:https://blog.csdn.net/qq_16739693/article/details/80271987

  10. springboot不能加载主类

    参考:https://www.cnblogs.com/iyyy/p/8085719.html 若为maven项目:用maven更新下项目.