Skip to content

Commit

Permalink
remove companyInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenngocbinh committed Sep 28, 2023
1 parent ee5f518 commit 2a66233
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 67 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(companyInfo)
export(getData)
import(httr)
importFrom(dplyr,bind_rows)
importFrom(httr,GET)
importFrom(magrittr,`%>%`)
40 changes: 0 additions & 40 deletions R/vndirect.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,44 +77,4 @@ getData <- function(.tickers = NULL, .size = 100) {
}


#' Company Information
#'
#' Retrieves company information from the VNDIRECT API for a given ticker.
#'
#' @param .ticker Ticker with 3 characters. Pass this parameter if you want to return information for a specific company.
#' @return A data frame containing company information.
#' @importFrom httr GET
#' @importFrom magrittr `%>%`
#' @export
#'
#' @examples
#' # Retrieve information for a specific company
#' cpn_info <- companyInfo()
#'
#' @export
companyInfo <- function(.ticker = NULL) {
# Check if .ticker is valid
if (is.null(.ticker) || nchar(.ticker) != 3) {
stop('Invalid or missing .ticker. Please provide a valid 3-character ticker.')
}

# Define the base URL and endpoint
base <- 'https://finfo-api.vndirect.com.vn/v4/stocks'
endpoint <- paste0(base, "code:", .ticker)

# Send the HTTP request
res <- httr::GET(url = base, query = params)

# Check if the HTTP request was successful
if (httr::http_error(res)) {
stop(paste('Failed to retrieve data for ticker:', .ticker))
}

# Extract and process the data
df_company_info <- httr::content(res, "parsed")$data %>%
purrr::map_dfr(bind_rows)

return(df_company_info)
}


5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ dplyr::glimpse(dt)
## $ adChange <dbl> 0.5, -0.6, -0.2, -1.6, 0.1, -0.6, 0.2, -0.3, 0.5, 0.0, 1.~
## $ pctChange <dbl> 0.5917, -0.7051, -0.2345, -1.8412, 0.1152, -0.6865, 0.229~


```
vndirect
├─ cran-comments.md
├─ CRAN-SUBMISSION
├─ DESCRIPTION
├─ LICENSE
├─ man
│ ├─ vnd_company_info.Rd
│ ├─ vnd_get_data.Rd
│ └─ vnd_get_list_data.Rd
│ └─ getData.Rd
├─ NAMESPACE
├─ R
│ └─ vndirect.R
Expand Down
22 changes: 0 additions & 22 deletions man/companyInfo.Rd

This file was deleted.

0 comments on commit 2a66233

Please sign in to comment.