금융 정보원에서 제공하는 자료들을 파이썬 혹은 R로 수집하는 것이 가능합니다.
R 코드는 아래와 같습니다. (* 주요사항 보고서, 증권신고서, 공시서류원본파일은 코드가 없습니다. (220422)
[필요 패키지]
###Packages--------------------------------------------------------------------------------------
if (!require('httr')) install.packages('httr'); library('httr')
if (!require('jsonlite')) install.packages('jsonlite'); library('jsonlite')
if (!require('dplyr')) install.packages('dplyr'); library('dplyr')
if (!require('tidyverse')) install.packages('tidyverse'); library('tidyverse')
if (!require('rvest')) install.packages('rvest'); library('rvest')
if (!require('xml2')) install.packages('xml2'); library('xml2')
if (!require('dplyr')) install.packages('dplyr'); library('dplyr', warn.conflicts = FALSE)
if (!require('shiny')) install.packages('shiny'); library('shiny')
if (!require('ggplot2')) install.packages('ggplot2'); library('ggplot2')
if (!require('DT')) install.packages('DT'); library('DT')
if (!require('tibble')) install.packages('tibble'); library('tibble')
if (!require('shinythemes')) install.packages('shinythemes'); library('shinythemes')
if (!require('lubridate')) install.packages('lubridate'); library('lubridate')
if (!require('rsconnect')) install.packages('rsconnect'); library('rsconnect')
if (!require('scales')) install.packages('scales'); library('scales')
#installpackages-----------------------------------
install.packages("httr")
install.packages("XML")
install.packages("RCurl")
install.packages("data.table")
#library------------------------------------------
library(XML)
library(httr)
library(RCurl)
library(plyr)
library(data.table)
library(pivottabler)
library(haven)
library(devtools)
library(na.tools)
library(expss)
library(plyr)
library(utils)
library(janitor)
library(dplyr)
library(do)
library(ggplot2)
library(skimr)
library(matrixStats)
library(magrittr)
library(openxlsx)
library(viridis)
library(hrbrthemes)
library(stringr)
library(aurelius)
#Data Import------------------------------------------------------------
load('corpCode_data.Rda') ##Not working in first trial, but after the second trial, we can skip [1].[2].[3] step,
load('list.rda') ## Except for the case of updating current data (Updating Data is recommended)
load('comp.rda')
#-----------------------------------------------------------------------
#API Validation KEY#----------------------------------------------------
crtfc_key = "개인 코드"
#Parameter Setting#-------------------------------------------------------------------------------------------------------------
#All Corp Set-----------------------------------------------------------
corpcodeall=as.character(unlist(corpCode_data[1]))
#One Company Parameter Setting (Give parameter indicating which company would we want to call from OPENDART)-------------------------------
corp = corpCode_data[corpCode_data$name =='카카오',]
if (nrow(corp)>1) {corp=corp[nrow(corp),]} #Cause there are some cases that same company has two identification number when they transfer from KOSDAQ to KOSPI, set the condition so that we can call only for the recent case
corp_code = corp[[1]] #Beaware of overlaps
#Select specific corps as a group var------------------------------------
corpgroup=c("00258801", "00266961", "00983271")
str(corpgroup)
##Business Yr to See-----------------------------------------------------
bsns_year = 2020 # (Range: 2015-Current)
reprt_code = 11011 # 1Q: 11013 2Q : 11012 3Q : 11014 4Q(Final Business Report)
list_bsns_year= c('2015', '2016', '2017', '2018', '2019','2020','2021')
list_reprt_code= c('11011', '11012', '11013', '11014') # 분기 리포트
'지식 창고 > R 언어' 카테고리의 다른 글
금융통계정보시스템 OPEN API R 코드 (0) | 2022.05.25 |
---|---|
[R 웹 스크래핑 코드] 열린 재정 OPEN API 이용하기 (0) | 2022.05.25 |
공공데이터 포털 OPEN API 데이터 R로 불러오기 (0) | 2022.03.24 |
R Script Note (0) | 2021.09.04 |
R 언어 설치 및 프로그램 구성 PPT 자료 (1) | 2020.07.19 |
댓글