## [1] "factor"
## symbol date open high low close volume adjusted
## 0 0 3 3 3 3 3 3
## [1] 675 8
stockline <- stockplot %>%
select(symbol,date,volume) %>%
filter(date >= "2020-01-03" & date < "2020-09-03") %>%
hchart(., type = "line",
hcaes(x = date,
y = volume,
group = symbol)) %>%
hc_yAxis(opposite = FALSE,
labels = list(format = "{value}")) %>%
hc_tooltip(pointFormat = '{point.x: %Y-%m-%d}
{point.y:.4f}% ')
stockline# Plot
library(scales)
stockridges <- stockplot %>%
filter(symbol %in% c("AML.L", "BMW.DE", "DAI.DE", "TSLA")) %>%
mutate(month = month(date, label = T),
year = as.factor(year(date)),
year_col = ifelse(year==2020,"A","B")) %>%
ggplot(aes(x = volume, y = month, fill = ..x..)) +
geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01, alpha = 0) + scale_x_continuous(labels = number_format(big.mark = ",")) +
scale_fill_viridis_c(name = "Temp. [F]", option = "B") +
labs(title = 'volume distributions for all stocks in 2020') +
facet_wrap(~symbol, scales = "free_x")+
theme_pander() +
theme(
legend.position="none",
panel.spacing = unit(0.1, "lines"),
strip.text.x = element_text(size = 8)
)
stockridges## Picking joint bandwidth of 4470000
## Picking joint bandwidth of 300000
## Picking joint bandwidth of 806000
## Picking joint bandwidth of 13700000
Dari boxplot dibawah dapat disimpulkan bahwa : - median: secara overall, saham dengan Volume tertinggi adalah TSLA. - lebar kotak (IQR atau selisih 75% dengan 25%): saham dengan Volume yang paling tersebar adalah TSLA, sedangkan yang paling tidak tersebar adalah BMW.DE. - outlier: paling banyak nilai Volume yang ekstrim pada saham TSLA artinya ada beberapa orang yang melakukan transaksi saham dengan nilai sangat tinggi.
stockbox <- stockplot %>%
ggplot(aes(x = symbol, y = volume)) +
geom_boxplot(aes(fill = symbol)) +
labs(title = "volume distributions ")
ggplotly(stockbox)relativerisk_stock <- stock %>%
group_by(symbol) %>%
summarise(relativerisk_stock = sd(close)/mean(close))## `summarise()` ungrouping output (override with `.groups` argument)