-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice_1.Rmd
85 lines (65 loc) · 1.09 KB
/
practice_1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: "R Notebook"
output: html_notebook
---
```{r}
source('library.R')
```
```{r}
tq_get_options()
```
```{r}
from <- today() - years(1)
AAPL <- tq_get("AAPL", get = "stock.prices", from = from)
AAPL
```
```{r}
# Get of list of the tq_mutate() options
tq_mutate_fun_options() %>%
select(zoo) %>%
str()
```
```{r}
AAPL %>%
tq_mutate(ohlc_fun = Cl, mutate_fun = SMA, n = 15) %>%
rename(SMA.15 = SMA) %>%
tq_mutate(ohlc_fun = Cl, mutate_fun = SMA, n = 50) %>%
rename(SMA.50 = SMA)
```
```{r}
AAPL %>%
tq_mutate_xy(x = close, mutate_fun = SMA, n = 15) %>%
rename(SMA.15 = SMA) %>%
tq_mutate_xy(x = close, mutate_fun = SMA, n = 50) %>%
rename(SMA.50 = SMA)
```
```{r}
AAPL %>%
mutate(SMA.15 = SMA(close,n=10))
```
```{r}
```
```{r}
1 + 4
```
```{r}
aapl_stock_prices<- tq_get("AAPL")
```
```{r}
mult_stocks <- tq_get(c("FB","AMZN"),
get = "stock.prices",
from = "2016-01-01",
to = "2017-01-01")
```
```{r}
acf(mult_stocks$open)
```
```{r}
pacf(mult_stocks$open )
```
```{r}
stats::Box.test(mult_stocks$open)
```
```{r}
arima(mult_stocks$open,order = (1 0 2))
```