-
Notifications
You must be signed in to change notification settings - Fork 1
/
bonds.R
29 lines (28 loc) · 841 Bytes
/
bonds.R
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
#' Moroccan Bonds
#'
#' @description
#' Scraps all the bonds listed in [**Le Boursier**](http://leboursier.ma/details/marche.html).
#'
#' @return
#' Returns a `data.frame` containing :
#' * `bond_name`: name of the bond.
#' * `issued`: number of issued bonds.
#' * `issuer`: the company that issued the bond.
#' * `full_name`: full name of the bond issuer.
#' * `rate`: rate of return.
#' * `price_ref`: first price.
#' * `price_last`: latest price.
#'
#' @export
#'
#' @rdname bonds
#' @examples
#' if( bcr:::check_internet() ) {
#' bonds()
#' }
bonds <- function() {
resp <- get_html("http://leboursier.ma/index.php?option=com_api&view=api&method=getBondsInfo&format=json")[- c(5,9)]
df <- setNames(resp, nm=c("bond_name", "issued", "issuer", "full_name", "rate", "price_ref", "price_last"))
df$rate <- df$rate/100
df
}