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. 解决游览器安装Vue.js devtools插件无效的问题

    一: 打开自己写的一个vue.js网页,发现这个图标并没有亮起来,还是灰色 解决方案:  1.我们先看看Vue.js devtools是否生效,打开Bilibili(https://www.bilib ...

  2. plus接口

    //获取手机端本地文件路径 plus.io.resolveLocalFileSystemURL(url, success(e){ }, fail(e){ })

  3. 【SSM - druid 】配置与使用

    web.xml 配置 <!-- druid的监控页面配置开始 --> <servlet> <servlet-name>StatViewServlet</ser ...

  4. C语言-define 与do{}while(0)

    问题引出: 我们都知道宏定义#define只是简单替换,所以遇到复杂的带参数宏,必须很小心的为需要的参数加上括号“()”:同样碰到复杂的多条语句替代,虽然加{}可以将其封装成一个整体,但同时又有另一个 ...

  5. 【PAT甲级】1057 Stack (30 分)(分块)

    题意: 输入一个正整数N(<=1e5),接着输入N行字符串,模拟栈的操作,非入栈操作时输出中位数.(总数为偶数时输入偏小的) trick: 分块操作节约时间 AAAAAccepted code: ...

  6. python字符串操作方法详解

      字符串 字符串序列用于表示和存储文本,python中字符串是不可变对象.字符串是一个有序的字符的集合,用于存储和表示基本的文本信息,一对单,双或三引号中间包含的内容称之为字符串.其中三引号可以由多 ...

  7. EASYUI combobox firefox 下不支持中文检索

    firefox 中文录入因为输入法的问题,无法出发检索的事件.网上的方法试过还是没有解决. 于是使用录入时新增一个模拟键shift,触发keydown事件,最终实现需要的效果. $("inp ...

  8. Educational Codeforces Round 81 + Gym 102267

    UPD:变色了!!!历史最高1618~ Educational Codeforces Round 81 (Rated for Div. 2) The 2019 University of Jordan ...

  9. Python使用pyautogui控制鼠标键盘

    官方文档:https://pyautogui.readthedocs.io/en/latest/# 安装pyautogui模块 在 Windows 上,不需要安装其他模块. 在 OS X 上,运行 s ...

  10. selenium webdriver 屏幕滚动

    //山寨法 String setscroll = "document.documentElement.scrollTop=100"; JavascriptExecutor jse= ...