AAPL

library(quantmod)
## Warning: package 'quantmod' was built under R version 4.1.2
## Zorunlu paket yükleniyor: xts
## Warning: package 'xts' was built under R version 4.1.2
## Zorunlu paket yükleniyor: zoo
## Warning: package 'zoo' was built under R version 4.1.2
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Zorunlu paket yükleniyor: TTR
## Warning: package 'TTR' was built under R version 4.1.2
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
getSymbols("AAPL")
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## [1] "AAPL"
dim(AAPL)
## [1] 3817    6
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.562706
## 2007-01-04  3.001786  3.069643 2.993571   3.059286   847260400      2.619588
## 2007-01-05  3.063214  3.078571 3.014286   3.037500   834741600      2.600932
## 2007-01-08  3.070000  3.090357 3.045714   3.052500   797106800      2.613776
## 2007-01-09  3.087500  3.320714 3.041071   3.306071  3349298400      2.830904
## 2007-01-10  3.383929  3.492857 3.337500   3.464286  2952880000      2.966379
tail(AAPL)
##            AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
## 2022-02-22    164.98    166.69   162.15     164.32    91162800        164.32
## 2022-02-23    165.54    166.15   159.75     160.07    90009200        160.07
## 2022-02-24    152.58    162.85   152.00     162.74   141147500        162.74
## 2022-02-25    163.84    165.12   160.87     164.85    91974200        164.85
## 2022-02-28    163.06    165.42   162.43     165.12    94869100        165.12
## 2022-03-01    164.70    166.60   161.97     163.20    83361500        163.20
chartSeries(AAPL)

chartSeries(AAPL, theme="white")

GDP İN TURKEY

getSymbols("GDP",src="FRED")
## [1] "GDP"
chartSeries(GDP)

chartSeries(GDP,theme="white") 

USD/EUR currency parity

getFX("USD/EUR",from="2022-02-20")
## [1] "USD/EUR"
chartSeries(USDEUR)

GDP Per capita (current US$)

library(WDI)
## Warning: package 'WDI' was built under R version 4.1.2
df = WDI(indicator='NY.GDP.PCAP.CD', country=c('TR','EU'), start=2000, end=2020)
head(df)
##   iso2c        country NY.GDP.PCAP.CD year
## 1    EU European Union       34148.92 2020
## 2    EU European Union       35083.81 2019
## 3    EU European Union       35737.30 2018
## 4    EU European Union       33023.79 2017
## 5    EU European Union       31168.44 2016
## 6    EU European Union       30474.50 2015
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.1.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
## 
##     first, last
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
df <- df %>%
  rename(ulkekodu= 1,
         ulke= 2,
          GDP = 3,
         sene= 4)
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.1.2
data_genis <- dcast(df, sene ~ ulke, value.var="GDP")
head(data_genis)
##   sene European Union   Turkey
## 1 2000       16910.40 4337.478
## 2 2001       17185.96 3142.921
## 3 2002       18682.65 3687.956
## 4 2003       22923.65 4760.104
## 5 2004       26266.17 6101.632
## 6 2005       27335.77 7456.296
df2 <- WDI(
  country = "all",
  indicator ='NY.GDP.PCAP.CD',
  start = 2010,
  end = 2020,
  extra = TRUE,
  cache = NULL,
  latest = NULL,
  language = "tr"
)
## Warning in WDI(country = "all", indicator = "NY.GDP.PCAP.CD", start = 2010, :
## This language is only supported partially.
View(df2)
tsveri <- ts(data_genis, start=1960, frequency=1)
head(tsveri)
##      sene European Union   Turkey
## [1,] 2000       16910.40 4337.478
## [2,] 2001       17185.96 3142.921
## [3,] 2002       18682.65 3687.956
## [4,] 2003       22923.65 4760.104
## [5,] 2004       26266.17 6101.632
## [6,] 2005       27335.77 7456.296
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.1.2
library(ggfortify)
## Warning: package 'ggfortify' was built under R version 4.1.2
autoplot(tsveri[,"Turkey"]) +
  ggtitle("Turkey GDP Per capita (current US$") +
  xlab("Sene") +
  ylab("")

autoplot(tsveri[,"Turkey"], ts.colour = 'red', ts.linetype = 'dashed')

plot(tsveri[,"Turkey"])

plot(tsveri[,2:3])

plot(tsveri[,2:3], plot.type = "single")

plot(tsveri[,2],
     type = "l",
     col = 2,
     ylim = c(0, 25),
     xlab = "Sene",
     ylab = "GDP")
lines(tsveri[,2],
      type = "l",
      col = 3)
lines(tsveri[,3],
      type = "l",
      col = 4)
legend("topright",                           
       c("Türkiye", "EU"),
       lty = 1,
       col = 2:3)

data_uzun <- melt(data_genis, id.vars = "sene") 
ggplot(data_uzun,                           
       aes(x = sene,
           y = value,
           col = variable)) +
  geom_line()