library(magrittr)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

The goal of CSE (Casablanca Stock Exchange) is to simplify financial programming workflow with Casablanca stock exchange data.

Currently, it implements 3 mains functions:

Quick Demo

Firms currently listed in Casablanca stock exchange

all_stocks <- CSE::listed_symbols(type = "stock")
all_stocks %>% length()
dplyr::tibble(Firm = all_stocks) %>%
    head(n = 10)
dplyr::tibble(Firm = all_stocks) %>%
    head(n = 10) %>%
    knitr::kable()

Available indexes

all_indexes <- CSE::listed_symbols(type = "index")
all_indexes %>% nrow()
all_indexes %>%
    head(n = 10)
all_indexes %>%
    head(n = 10) %>%
    knitr::kable()

IPO Dates

firm_sample <- all_stocks %>% 
    sample(size = 5)

ipo_dates <- firm_sample %>%
    purrr::map(CSE::ipo_date)
dplyr::tibble(Firm = firm_sample, IPO_Date = do.call(c, ipo_dates))
dplyr::tibble(Firm = firm_sample, IPO_Date = do.call(c, ipo_dates)) %>%
    knitr::kable()

Get Some Historical Data

iam <- CSE::get_symbol("ITISSALAT AL-MAGHRIB", "2016-01-01", "2021-09-29", type = "stock")
masi <- CSE::get_symbol("MASI", "2016-01-01", "2021-09-29", type = "index")
dim(iam)
dim(masi)
xts::first(iam, n = 5)
xts::last(iam, n = 5)
xts::first(masi, n = 5)
xts::last(masi, n = 5)
plot(masi, main = "MASI Historical Values")
plot(iam$Adjusted, main = "IAM Historical Adjusted Prices")


bilnash/CSE documentation built on Oct. 1, 2024, 4:17 p.m.