In this report it analyses the financial data of Apple (AAPL), Microsoft(MSFT), and Google(GOOG) from yahoo finance.
install.packages("quantmod")
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
getSymbols("AAPL", src ="yahoo")
## [1] "AAPL"
str(AAPL)
## An 'xts' object on 2007-01-03/2023-03-30 containing:
## Data: num [1:4089, 1:6] 3.08 3 3.06 3.07 3.09 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:6] "AAPL.Open" "AAPL.High" "AAPL.Low" "AAPL.Close" ...
## Indexed by objects of class: [Date] TZ: UTC
## xts Attributes:
## List of 2
## $ src : chr "yahoo"
## $ updated: POSIXct[1:1], format: "2023-03-31 20:36:56"
head(AAPL)
## AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
## 2007-01-03 3.081786 3.092143 2.925000 2.992857 1238319600 2.547276
## 2007-01-04 3.001786 3.069643 2.993571 3.059286 847260400 2.603814
## 2007-01-05 3.063214 3.078571 3.014286 3.037500 834741600 2.585272
## 2007-01-08 3.070000 3.090357 3.045714 3.052500 797106800 2.598038
## 2007-01-09 3.087500 3.320714 3.041071 3.306071 3349298400 2.813858
## 2007-01-10 3.383929 3.492857 3.337500 3.464286 2952880000 2.948517
getSymbols("AAPL",
src="yahoo",
periodicity ="weekly")
## [1] "AAPL"
getSymbols(c("AAPL","MSFT","GOOG"),
src = "yahoo",
periodicity = "weekly",
from = as.Date("2022-01-01"),
to = as.Date("2022-12-31"))
## [1] "AAPL" "MSFT" "GOOG"
Financila data with quant mod (Candlestick) for AAPL / Apple
Plot.1 <- chartSeries(AAPL[, 1:4],
type= "candlestick",
theme = chartTheme("white"),
up.col = "green",
dn.col = "red")
Financila data with quant mod (Candlestick) for MSFT / Micosoft
Plot.2 <- chartSeries(MSFT[, 1:4],
type= "candlestick",
theme = chartTheme("white"),
up.col = "green",
dn.col = "red")
Financila data with quant mod (Candlestick) for GOOG / Google
Plot.3 <- chartSeries(GOOG[, 1:4],
type= "candlestick",
theme = chartTheme("white"),
up.col = "green",
dn.col = "red")
getSymbols("AAPL",
src = "yahoo",
periodicity = "daily",
from = as.Date("2022-01-01"),
to = as.Date("2022-12-31"))
## [1] "AAPL"
chartSeries(AAPL[,1:4], theme = chartTheme("white"))
addSMA(10, col = "blue")
addSMA(30, col = "brown")
getSymbols("MSFT",
src = "yahoo",
periodicity = "daily",
from = as.Date("2022-01-01"),
to = as.Date("2022-12-31"))
## [1] "MSFT"
chartSeries(MSFT[,1:4], theme = chartTheme("white"))
addSMA(10, col = "blue")
addSMA(30, col = "brown")
getSymbols("GOOG",
src = "yahoo",
periodicity = "daily",
from = as.Date("2022-01-01"),
to = as.Date("2022-12-31"))
## [1] "GOOG"
chartSeries(GOOG[,1:4], theme = chartTheme("white"))
addSMA(10, col = "blue")
addSMA(30, col = "brown")