library(quantmod)
## Загрузка требуемого пакета: xts
## Загрузка требуемого пакета: zoo
##
## Присоединяю пакет: 'zoo'
## Следующие объекты скрыты от 'package:base':
##
## as.Date, as.Date.numeric
##
## ################################### WARNING ###################################
## # We noticed you have dplyr installed. The dplyr lag() function breaks how #
## # base R's lag() function is supposed to work, which breaks lag(my_xts). #
## # #
## # If you call library(dplyr) later in this session, then calls to lag(my_xts) #
## # that you enter or source() into this session won't work correctly. #
## # #
## # All package code is unaffected because it is protected by the R namespace #
## # mechanism. #
## # #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## # You can use stats::lag() to make sure you're not using dplyr::lag(), or you #
## # can add conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## ################################### WARNING ###################################
## Загрузка требуемого пакета: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(ggplot2)
library(PerformanceAnalytics)
##
## Присоединяю пакет: 'PerformanceAnalytics'
## Следующий объект скрыт от 'package:graphics':
##
## legend
#25.08.2020
NVTK1 <- getSymbols("NVTK.ME", from = "2020-08-19", to = "2020-08-31", auto.assign = FALSE)
plot(NVTK1$NVTK.ME.Close)

plot(na.omit(Return.calculate(NVTK1$NVTK.ME.Close)), main = "Динамика доходности акций, снижение DPS", col = "slateblue")

#27.08.2021
NVTK2 <- getSymbols("NVTK.ME", from = "2021-08-23", to = "2021-09-02", auto.assign = FALSE)
plot(na.omit(Return.calculate(NVTK2$NVTK.ME.Close)), main = "Динамика доходности акций, увеличение DPS", col = "darkblue")

#17.03.2023
NVTK3 <- data.frame(Date = c("13.03.2023", "14.03.2023", "15.03.2023", "16.03.2023",
"17.03.2023", "20.03.2023", "21.03.2023", "22.02.2023"),
Close_Price = c(1061.8, 1059.2, 1048.4, 1064, 1074.6, 1122.2, 1126.2, 1128.8))
i <- NULL
for (i in 1:8) {
NVTK3[i+1,3] <- NVTK3$Close_Price[i+1]/NVTK3$Close_Price[i]-1
}
colnames(NVTK3) <- c("Date", "Close_Price", "Return")
NVTK4 <- na.omit(NVTK3)
ggplot(data = NVTK4, aes(x = Date, y = Return)) + geom_col(fill = "lightblue") + xlab("") + theme_classic()
