Closed Fredysessie closed 1 year ago
But we will add two more utils and 6 functions such as :
.sectors =list(Agriculture = c("PALC","SCRC","SICC","SOGC","SPHC"),
Distribution = c("ABJC","BNBC","CFAC","PRSC","SHEC","TTLC","TTLS"),
Industry = c("CABC","FTSC","NEIC","NTLC","SEMC","SIVC","SLBC","SMBC","STBC","TTRC","UNLC","UNXC"),
Finance = c("BOAB","BOABF","BOAC","BOAM","BOAN","BOAS","BICC","CBIBF","ECOC","ETIT","NSBC","ORGT","SAFC","SGBC","SIBC"),
Transport = c("SDSC","SVOC"),
"Public service" = c("CIEC","ONTBF","SDCC","SNTS"),
Other = c("STAC"))
########
Countries<-list(BENIN =c("BOAB"), "BURKINA FASO" = c("BOABF", "CBIBF", "ONTBF"),
"IVORY COAST" = c("ABJC", "BICC", "BNBC","BOAC", "CABC", "CFAC", "CIEC", "ECOC", "FTSC", "NEIC",
"NSBC","NTLC", "PALC", "PRSC", "SAFC", "SCRC", "SDCC", "SDSC", "SEMC","SGBC",
"SHEC", "SIBC", "SICC", "SIVC", "SLBC", "SMBC", "SOGC","SPHC", "STAC", "STBC",
"SVOC", "TTLC", "TTRC", "UNLC","UNXC"),
MALI = c("BOAM"), NIGER = c("BOAN"),
SENEGAL = c("BOAS", "SNTS", "TTLS"),
TOGO = c("ETIT", "ORGT"))
BRVM_ticker_desc<- function(){
tryCatch(
{
Desc.BRVM.all <- rvest::read_html("https://www.brvm.org/en/cours-actions/0/status/200") %>%
rvest::html_nodes('table') %>%
rvest::html_table()
Desc.BRVM.all <- Desc.BRVM.all[[4]]
Desc.BRVM.all<-Desc.BRVM.all[1:2]
colnames(Desc.BRVM.all)<-c(
"Ticker",
"Company name")
#Create sector column
Desc.BRVM.all$Sector<-NA
for (elm in 1:length(Desc.BRVM.all$Ticker)){
for (elm1 in 1 : length(.sectors)) {
if (Desc.BRVM.all$Ticker[elm] %in% .sectors[[elm1]]) {
Desc.BRVM.all$Sector[elm]<-names(.sectors)[[elm1]]
}
}
}
#Create country column
Desc.BRVM.all$Country<-NA
for (elem in 1:length(Desc.BRVM.all$Ticker)){
for (elem1 in 1 : length(Countries)) {
if (Desc.BRVM.all$Ticker[elem] %in% Countries[[elem1]]) {
Desc.BRVM.all$Country[elem]<-names(Countries)[[elem1]]
}
}
}
},
error = function(e) {
print("Make sure you have an active internet connection")
},
warning = function(w) {
print("Make sure you have an active internet connection")
}
)
return(Desc.BRVM.all)
#return(quotes_tbl)
}
########
company_country<- function(company){
company<-toupper(company)
for (elem in 1 :length(Countries)){
if (company %in% Countries[[elem]]) {
return(names(Countries)[[elem]])
}
}
}
########
function(company){
company<-toupper(company)
for (elem in 1 :length(.sectors)){
# if (input$ticker %in% .sectors[[elem]]) {
if (company %in% .sectors[[elem]]) {
return(names(.sectors)[[elem]])
}
}
}
################
company_cap<- function(company){
company<-toupper(company)
tryCatch({
brvm_cap_all <- rvest::read_html("https://www.brvm.org/en/capitalisations/0/status/200") %>%
rvest::html_nodes('table') %>%
rvest::html_table()
brvm_cap_all <- brvm_cap_all[[4]]
brvm_cap_all$`Global capitalization (%)`<-gsub(",", ".",brvm_cap_all$`Global capitalization (%)`)
for (elm in 1:nrow(brvm_cap_all)){
if (brvm_cap_all[elm,1]==company){
the_cap<-paste0(brvm_cap_all[elm,6], "")
}
}
return(the_cap)
},
error = function(e) {
print("Make sure you have an active internet connection")
},
warning = function(w) {
print("Make sure you have an active internet connection")
})
}
###########
function(company){
company<-toupper(company)
tryCatch({
brvm_trade_all <- rvest::read_html("https://www.brvm.org/en/volumes/0/status/200") %>%
rvest::html_nodes('table') %>%
rvest::html_table()
brvm_trade_all <- brvm_trade_all[[4]]
for (elm in 1:nrow(brvm_trade_all)){
if (brvm_trade_all[elm,1]==company){
trade_value<-paste0(brvm_trade_all[elm,4], "")
}
}
return(trade_value)
},
error = function(e) {
print("Make sure you have an active internet connection")
},
warning = function(w) {
print("Make sure you have an active internet connection")
})
}
##############
company_nbrank<-function(.company){
.company<-toupper(.company)
tryCatch({
companies_rk<-BRVM_company_rank()
for (elm in 1:nrow(companies_rk)){
if (companies_rk[elm,1]==.company){
the_rank<- companies_rk[elm,8]
}
}
if (the_rank!= 11& substr(the_rank, nchar(the_rank),nchar(the_rank)) == 1){
the_rank<- paste0(the_rank, " st")
}
else if (the_rank!= 12 & substr(the_rank, nchar(the_rank),nchar(the_rank)) == 2){
the_rank<- paste0(the_rank, " nd")
}
else if (the_rank!= 13 & substr(the_rank, nchar(the_rank),nchar(the_rank)) == 3){
the_rank<- paste0(the_rank, " rd")
} else {
the_rank<- paste0(the_rank, " th")
}
the_rank<-paste0(.company," is the ", the_rank)
return(the_rank)
},
error = function(e) {
print("Make sure you have an active internet connection")
},
warning = function(w) {
print("Make sure you have an active internet connection")
})
}
Belowing pictures are the r shiny version.
Best regards
wow nice
Hi Koffi I really appreciate shiny app. You're doing well. Congrats ! Now lets submit the package !
Hi @spsanderson and @AODiakite hope that you are doing good. We can publish the package and continue with the r shiny after. Please befor doing it can you please add all the 2 news utils and 6 functions in the following comment to the main and their description? Waiting for your point of view. Thanks