User:Dr vulpes/code

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

Code that I use when working on articles.

R[1][edit]

Stock Market[edit]

Generate closing stock prices with the R packages quantmod[2] and tidyquant[3]

Candlestick chart
Colorblind accessible candlestick chart
     getSymbols(c("PACW"),
                src = "yahoo",
                from = '2023-03-01',
                to = '2023-05-10')
     
     # Colors set to blue and red to improve accessability for people who are colorblind
     chartCandlestick  <- chartSeries(
       PACW,
       type = "candlestick",
       name = "PacWest Bancorp",
       theme = chartTheme(
         'white',
         up.col = '#1A85FF',
         dn.col = '#D41159'
       )
     )
     chartLine  <- chartSeries(
       PACW,
       type = "line",
       name = "PacWest Bancorp",
       theme = chartTheme(
         'white',
         up.col = '#1A85FF',
         dn.col = '#D41159'
       )
     )
     
     chartMatchsticks  <- chartSeries(
       PACW,
       type = "matchsticks",
       name = "PacWest Bancorp",
       theme = chartTheme(
         'white',
         up.col = '#1A85FF',
         dn.col = '#D41159'
       )
     )
  1. R Core Team (2023). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/
  2. Ryan JA, Ulrich JM (2023). quantmod: Quantitative Financial Modelling Framework. R package version 0.4.22, https://CRAN.R-project.org/package=quantmod.
  3. Dancho M, Vaughan D (2023). tidyquant: Tidy Quantitative Financial Analysis. R package version 1.0.7, https://CRAN.R-project.org/package=tidyquant