#' @export
#' @title get prices from www.oslobors.no
#'
#' @author Lars Nygaard
#'
#' @description
#' Function to get prices
#'
#' @export getMetaDataOsloBors
#'
getMetaDataOsloBors <- function(){
# fund.benchmarks.and.expense.ratios.url <-
# "https://www.oslobors.no/ob_eng/obnewsletter/download/bed6b75e013cf16b9921b1078730528f/file/file/omff_xmlbasicsubscription.xml"
#
# fund.metadata <- NULL
# attempt <- 1
# while( is.null(fund.metadata) && attempt <= 3 ) {
# attempt <- attempt + 1
# try(
# fund.metadata <- fund.benchmarks.and.expense.ratios.url %>% read_xml, # run once again if SSL_ERROR_SYSCALL error
# silent = TRUE)
# #closeAllConnections()
# }
#
# flatten.fund.data <- function(x)
# x %>% xml_children %>% xml_text %>%
# matrix(dimnames=x %>% xml_children %>% xml_name %>% list) %>% t %>% tibble::as_tibble()
#
# funds <- fund.metadata %>% xml_find_all('omff') %>% xml_children
# fund.metadata <-
# lapply(funds, flatten.fund.data) %>%
# dplyr::bind_rows()
#data("fundMetadata.rda")
print(xtable::xtable(fundMetadata), type="html")
}
#' @export
#' @title get prices from www.oslobors.no
#'
#' @author Lars Nygaard
#'
#' @description
#' Function to get prices
#'
#' @export getOverviewFunds
#'
getOverviewFunds <- function(){
fund.benchmarks.and.expense.ratios.url <-
"https://www.oslobors.no/ob_eng/obnewsletter/download/bed6b75e013cf16b9921b1078730528f/file/file/omff_xmlbasicsubscription.xml"
fund.metadata <- NULL
attempt <- 1
while( is.null(fund.metadata) && attempt <= 3 ) {
attempt <- attempt + 1
try(
fund.metadata <- fund.benchmarks.and.expense.ratios.url %>% read_xml, # run once again if SSL_ERROR_SYSCALL error
silent = TRUE)
#closeAllConnections()
}
flatten.fund.data <- function(x)
x %>% xml_children %>% xml_text %>%
matrix(dimnames=x %>% xml_children %>% xml_name %>% list) %>% t %>% tibble::as_tibble()
#load("data/fundMetadata.RData")
funds <- fund.metadata %>% xml_find_all('omff') %>% xml_children
fund.metadata <-
lapply(funds, flatten.fund.data) %>%
dplyr::bind_rows()
fund.metadata <- fund.metadata %>% group_by(rootgroupname, securitytypename, groupname) %>% tally %>% arrange(n %>% desc)
print(xtable::xtable(fund.metadata), type="html")
}
#' @export
#' @title get prices from www.oslobors.no
#'
#' @author Lars Nygaard
#'
#' @description
#' Function to get prices
#'
#' @export getOverviewFunds
#'
getSummary <- function(){
fund.benchmarks.and.expense.ratios.url <-
"https://www.oslobors.no/ob_eng/obnewsletter/download/bed6b75e013cf16b9921b1078730528f/file/file/omff_xmlbasicsubscription.xml"
fund.metadata <- NULL
attempt <- 1
while( is.null(fund.metadata) && attempt <= 3 ) {
attempt <- attempt + 1
try(
fund.metadata <- fund.benchmarks.and.expense.ratios.url %>% read_xml, # run once again if SSL_ERROR_SYSCALL error
silent = TRUE)
#closeAllConnections()
}
flatten.fund.data <- function(x)
x %>% xml_children %>% xml_text %>%
matrix(dimnames=x %>% xml_children %>% xml_name %>% list) %>% t %>% tibble::as_tibble()
#load("data/fundMetadata.RData")
funds <- fund.metadata %>% xml_find_all('omff') %>% xml_children
fund.metadata <-
lapply(funds, flatten.fund.data) %>%
dplyr::bind_rows()
fund.metadata <- fund.metadata %>% group_by(rootgroupname, securitytypename, groupname) %>% tally %>% arrange(n %>% desc)
print(xtable::xtable(fund.metadata), type="html")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.