-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
396 lines (267 loc) · 12.7 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
---
title: "Library BRVM"
date: "`r format(Sys.time(),'%d %B,%Y')`"
output:
html_document:
toc: yes
fig_caption: yes
keep_md: yes
fig_width: 8
fig_height: 6
word_document:
toc: yes
pdf_document:
toc: yes
latex_engine: lualatex
always_allow_html: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r,include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
echo = TRUE,
message = FALSE,
warning = FALSE
)
```
<img src="man/figures/brvm-logo.png" width="147" height="170" align="right"/>
<!-- badges: start -->
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/BRVM)](https://cran.r-project.org/package=BRVM)
![](https://cranlogs.r-pkg.org/badges/BRVM)
![](https://cranlogs.r-pkg.org/badges/grand-total/BRVM)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html##experimental)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
<!-- badges: end -->
## BRVM
### Description {.tabset}
#### English
This R package provides a user-friendly interface for accessing data from the BRVM, which is a regional stock exchange serving multiple West African countries. With this package, users can easily retrieve historical stock price data, trading volumes, and other financial indicators for a variety of stocks traded on the BRVM.
The package is designed to simplify the process of gathering and analyzing financial data, making it easier for researchers, investors, and other users to extract insights and make informed decisions based on the information available. Overall, `BRVM` library is a valuable tool for anyone looking to gain a better understanding of the BRVM and the financial markets in West Africa.
#### Français
Ce package R fournit une interface conviviale pour accéder aux données de la BRVM, qui est une bourse régionale desservant plusieurs pays d'Afrique de l'Ouest. Avec ce package, les utilisateurs peuvent facilement récupérer des données historiques sur les prix des actions, les volumes de transactions et d'autres indicateurs financiers pour une variété d'actions négociées sur la BRVM.
Le package est conçu pour simplifier le processus de collecte et d'analyse de données financières, ce qui facilite la tâche des chercheurs, des investisseurs et d'autres utilisateurs pour extraire des informations et prendre des décisions éclairées en se basant sur les informations disponibles. Dans l'ensemble, notre package R est un outil précieux pour quiconque cherche à mieux comprendre la BRVM et les marchés financiers en Afrique de l'Ouest.
## Installation guidelines
```{r echo=FALSE, message=TRUE, warning=TRUE,include=FALSE}
library(lubridate)
library(httr2)
library(stringr)
library(httr)
library(timeDate)
library(xts)
library(rlang)
library(dplyr)
library(formattable)
library(rvest)
library(highcharter)
library(htmlwidgets)
```
You can install using CRAN version
```{r, eval=FALSE}
install.packages("BRVM")
```
You can install the development version of BRVM from [github](https://github.com/Koffi-Fredysessie/BRVM) with:
```{r, eval=FALSE}
# github dev version
## We can use devtools
# install.packages("devtools")
devtools::install_github("Koffi-Fredysessie/BRVM")
# Or use remotes
# install.packages("remotes")
remotes::install_github("Koffi-Fredysessie/BRVM")
```
## Html version of the Readme
Since the size of the readme is huge due to the charts, you can visit the html version of the readme on [RPubs](https://rpubs.com/Fredysessie/Readme_BRVM_Stock)
```{r}
library(BRVM)
```
## The **BRVM_ticker_desc()** function
It receives no argument and returns BRVM tickers information such as its full name, sector and country.
```{r BRVM_ticker_desc, eval=FALSE}
# Display tickers of BRVM
tickers <- BRVM_ticker_desc()
tickers
```
```{r echo=FALSE}
library(knitr)
library(kableExtra)
kable(BRVM_ticker_desc(), "html") %>%
kable_styling(bootstrap_options = "striped")
```
## The **BRVM_index()** function :
It receives no argument and returns a table of updated data (with as table header: indexes, previous closing, closing, change (%), Year to Date Change) on all the indices available on the BRVM exchange.
```{r BRVM_index,eval=FALSE}
the_index <- BRVM_index()
the_index
```
```{r echo=FALSE}
kable(BRVM_index() , "html") %>%
kable_styling(bootstrap_options = "striped")
```
## The **BRVM_get(".symbol", ".from", ".to")** function
This function will get the data of the companies listed on the BVRM stock exchange in Rich Bourse website. The function takes a single parameter, `.symbol` (which represents the "Ticker").
The function will automatically format tickers you enter in uppercase using toupper() and then ensure that the passed ticker is in a Google spreadsheet of allowed tickers.
* .symbol : A vector of symbols, like: c("BICC","XOM","SlbC") ;
* .from : A quoted start date, ie. "2020-01-01" or "2020/01/01". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD" ;
* .to : A quoted end date, ie. "2022-01-31" or "2022/01/31". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD".
```{r BRVM_get}
#' Displaying data of SONATEL Senegal stock
BRVM_get(.symbol = "snts")
symbols <- c("BiCc","XOM","SlbC") # We use here three tickers
data_tbl <- BRVM_get(.symbol = symbols, .from = "2020-01-01", .to = Sys.Date() - 1)
# Display the first twenty observations of the table
head(data_tbl, 20)
# Display the last twenty elements of the table
tail(data_tbl, 20)
```
## The **BRVM_get1("ticker ", "Period", "from", "to")** function
This function will get data of the companies listed on the BVRM stock exchange through the sikafinance site.
The function takes in a single parameter of ticker and will auto-format the tickers you input into all upper case by using `toupper()`
* ticker : A vector of ticker, like: c("BICC","XOM","SlbC", "BRvm10");
* Period : Numeric number indicating time period. Valid entries are 0, 1, 5, 30, 91, and 365 representing respectively 'daily', 'one year', 'weekly', 'monthly', 'quarterly' and 'yearly';
* from : A quoted start date, ie. "2020-01-01" or "2020/01/01". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD";
* to : A quoted end date, ie. "2022-01-31" or "2022/01/31". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD"
** NB : There is a small difference between the BRVM_get and BRVM_get1 functions.
* With BRVM_get it is only possible to download tickers' daily data.
* But with BRVM_get1, you can download daily, weekly, monthly, annual tickers’ data, indices and even market capitalization.
```{r BRVM_get1}
#' Displaying data of SONATEL Senegal stock
BRVM_get1("snts")
# Get daily data of all indexes
all_ind <- BRVM_get1("ALL INDEXES", Period = 0, from = "2020-01-04", to = "2023-03-24")
# display the first two tens elements of the table
head(all_ind, 20)
# display the two tens of the last elements of the table
tail(all_ind, 20)
# To get yearly data
yearly_data <- BRVM_get1(c("brvmtr", "BiCc", "BOAS"), Period = 365 )
# display the first two tens elements of the table
head(yearly_data, 20)
# display the two tens of the last elements of the table
tail(yearly_data, 20)
```
## The **BRVM.index()** function :
It receives no argument and returns the name of all indexes available on BRVM Stock Exchange.
```{r BRVM.index}
BRVM.index()
```
## The **BRVM_bySector(".sectors")** function :
This function will take in the name of sector(s) and returns data for companies belonging to that/those sector(s)
* .sectors : A vector of sectors you wish to have returned.
```{r BRVM_bySector}
# Get informations about brvm sectors like other and agriculture sectors
BRVM_bySector(.sectors = c("Other", "Agriculture"))
```
## The **BRVM_stock_market(".weekday")** function :
This function receives as input a day of the week (working day) and returns the official quotation revews of that day.
* .weekday : A quoted date, ie. "2022-01-31" or "2022/01/31". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD". Must not be a weekend or a holiday.
```{r BRVM_stock_market}
# The BOC of 2022-02-23
BRVM_stock_market("2022-02-23")
```
## The **BRVM_plot(".company", "up.col", "down.col")** function:
This function will get Ticker(s) data and then plot it.
* .company : is the Ticker(s) name(s)
* from : A quoted start date, ie. "2020-01-01" or "2020/01/01". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD".
* to : A quoted end date, ie. "2022-01-31" or "2022/01/31". The date must be in ymd format "YYYY-MM-DD" or "YYYY/MM/DD"
* up.col : is the up color
* down.col : is down color
```{r BRVM_plot}
chart <- BRVM_plot("BICC") # The default colors for the up and down are green and
#chart
```
<div align="center">
<img src="man/figures/OHCL_Bicc_chart.gif" width="100%" height="480" align="center"/>
</div>
```{r}
#It is also possible to plot stock data chart for more than one ticker
#Let's plot BICC, ETIT and BOAM stock data
chart1 <- BRVM_plot(c("BICC","ETIT", "BOAM"))
# chart1
```
<div align="center">
<img src="man/figures/Tickers_line_chart.gif" width="100%" height="480" align="center"/>
</div>
> - `BRVM_plot` : For one ticker, you can also specify your color like
* `BRVM_plot("boas", up.col = "blue", down.col = "pink")` for example
## The **BRVM_company_info("ticker")** function
It receives the ticker of a company listed on the BRVM stock exchange, Turn to upper case the input by using toupper() and returns informations about the company's RSI, Beta, Closing price, etc. .
```{r BRVM_company_info,eval=FALSE}
# Get informations such us beta, RSI, Closing, Valorisation, etc. of Bank Of Africa Senegal
inform <- BRVM_company_info("BOAS")
inform
```
```{r echo=FALSE}
library(knitr)
library(kableExtra)
# Get informations such us beta, RSI, Closing, Valorisation, etc. of Bank Of Africa Senegal
inform <- BRVM_company_info("BOAS")
kable(inform, "html") %>%
kable_styling(bootstrap_options = "striped")
```
> - **BRVM_cap()** : receives no argument and returns informations about BRVM capitalization
```{r BRVM_cap,eval=FALSE}
capit_ <- BRVM_cap()
capit_
```
```{r echo=FALSE}
library(knitr)
library(kableExtra)
capit_ <- BRVM_cap()
kable(capit_, "html") %>%
kable_styling(bootstrap_options = "striped")
```
> - **BRVM_company_rank()** : returns companies rank from the BRVM Bourse exchange according to their daily change (variation).
```{r BRVM_company_rank, eval=FALSE}
comp.rank <- BRVM_company_rank() #Get companies rank
comp.rank <- comp.rank%>%
arrange(desc(percent_change)) #Describe in decreasing order
comp.rank
```
```{r echo=FALSE}
library(knitr)
library(kableExtra)
comp.rank <- BRVM_company_rank() #Get companies rank
comp.rank <- comp.rank%>%
arrange(desc(percent_change)) #Describe in decreasing order
kable(comp.rank, "html")%>%
kable_styling(bootstrap_options = "striped")
```
> - **BRVM_direction(".up_or_down")** : Takes 'Up' or 'Down' and returns respectively n results for the top or flop ranking of the BRVM tickers.
* .up_or_down : This is a character string set to "Up" by default It can either be 'Up' or 'Down'.
```{r BRVM_direction,eval=FALSE}
# Rank in increasing order the price of shares listed on the BRVM according to daily variations.
brvm_down <- BRVM_direction("Down")
brvm_down
```
```{r echo=FALSE}
library(knitr)
library(kableExtra)
# Rank in increasing order the price of shares listed on the BRVM according to daily variations.
brvm_down <- BRVM_direction("Down")
kable(brvm_down, "html") %>%
kable_styling(bootstrap_options = "striped")
```
> - **BRVM_rank** : receives "top" or "flop" and a number 'n' and returns table of companies classification
* top_or_flop : Choose between "top" or "flop"
* n : is the number of companies in the classification
```{r BRVM_rank}
#To get top 15
BRVM_rank("top", 15)
#To get flop 5
BRVM_rank("flop", 5)
```
> - **company_traded_val("company")** : receives one company listed on the BRVM stock exchange, Turn to upper case the input by using toupper() and returns informations about the company's traded value
* company : The name of company listed on the BRVM stock exchange
```{r company_traded_val}
company_traded_val("ontbf") # Traded value of ONATEL BURKINA FASO
```
**Authors** : <br>
* [Koffi Frederic Sessie](https://github.com/Koffi-Fredysessie) (<[email protected]>),
* [Abdoul Oudouss Diakité](https://github.com/AODiakite) (<[email protected]>),
* [Sanderson Steven](https://github.com/spsanderson)(<[email protected]>)<br>
**Creator** : Koffi Frederic Sessie <br>
**cph (Copyright Holder)** : Koffi Frederic Sessie <br>
**License** : MIT 2023, BRVM authors. All rights reserved.