-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
code_get.R
50 lines (49 loc) · 1.17 KB
/
code_get.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#' Get company code
#'
#' Get code for korea finance market
#'
#' @param fresh get code on internet. Default is FALSE.
#' @return a [tibble][tibble::tibble-package] with market, name, code column.
#' @export
#' @examples
#' \donttest{
#' code_get()
#' code_get(fresh = TRUE)
#' }
#' @importFrom httr POST content
#' @importFrom jsonlite fromJSON
#' @importFrom tibble as_tibble
#' @importFrom dplyr transmute
code_get <- function(fresh = FALSE) {
if (!fresh) {
return(krcodedata)
}
. <-
MKT_TP_NM <-
ISU_ABBRV <-
ISU_SRT_CD <- ISU_NM <- ISU_ENG_NM <- ISU_CD <- NULL
"http://data.krx.co.kr/comm/bldAttendant/getJsonData.cmd" %>%
httr::POST(
body = list(
bld = "dbms/MDC/STAT/standard/MDCSTAT01901",
locale = "ko_KR",
mktId = "ALL",
share = 1,
csvxls_isNo = "false"
),
encode = "form"
) %>%
httr::content("text") %>%
jsonlite::fromJSON() %>%
.$OutBlock_1 %>%
tibble::as_tibble() %>%
dplyr::transmute(
market = MKT_TP_NM,
name = ISU_ABBRV,
code = ISU_SRT_CD,
name_full = ISU_NM,
name_eng = ISU_ENG_NM,
code_full = ISU_CD
) %>%
return()
}