재무제표 일괄 추출

재무제표 추출

dart_fss.fs.extract(corp_code: str, bgn_de: str, end_de: str | None = None, fs_tp: Tuple[str] = ('bs', 'is', 'cis', 'cf'), separate: bool = False, report_tp: str | List[str] = 'annual', lang: str = 'ko', separator: bool = True, dataset: str = 'xbrl', cumulative: bool = False, progressbar: bool = True, skip_error: bool = True, last_report_only: bool = True) FinancialStatement[source]

재무제표 검색

Parameters:
corp_code: str

공시대상회사의 고유번호(8자리)

bgn_de: str

검색 시작일자(YYYYMMDD)

end_de: str, optional

검색 종료일자(YYYYMMDD)

fs_tp: tuple of str, optional

‘bs’ 재무상태표, ‘is’ 손익계산서, ‘cis’ 포괄손익계산서, ‘cf’ 현금흐름표

separate: bool, optional

개별재무제표 여부

report_tp: str or list, optional

‘annual’ 연간, ‘half’ 연간 + 반기, ‘quarter’ 연간 + 반기 + 분기, [‘annual’] 연간, [‘half’] 반기, [‘quarter’] 분기, [‘annual’, ‘half’] 연간 + 반기, [‘annual’, ‘quarter’] 연간 + 분기, [‘half’, ‘quarter’] 반기 + 분기, [‘annual’, ‘half’, ‘quarter’] 연간 + 반기 + 분기

lang: str, optional

‘ko’ 한글, ‘en’ 영문

separator: bool, optional

1000단위 구분자 표시 여부

dataset: str, optional

‘xbrl’: xbrl 파일 우선 데이터 추출, ‘web’: web page 우선 데이터 추출(default: ‘xbrl’)

cumulative: bool, optional

반기 혹은 분기 보고서 추출시 해당분기 값을 제외한 누적값만 추출할지 여부 (default: False)

progressbar: bool, optional

ProgressBar 표시 여부 (default: True)

skip_error: bool, optional

Error 발생시 skip 여부 (default: True)

last_report_only: bool, optional

최종 보고서만을 이용하여 데이터를 추출할지 여부 (default: True)

Returns
——-
FinancialStatement

제무제표 검색 결과

FinancialStatement 클래스

재무제표 일괄 추출의 결과를 담고 있는 클래스

class dart_fss.fs.FinancialStatement(statements: Dict[str, DataFrame], label_df: Dict[str, DataFrame], info: Dict[str, str])[source]

재무제표 검색 결과를 저장하는 클래스

DART 공시 리포트들의 재무제표 검색 결과를 저장하고 있는 클래스로 검색 결과 및 검증을 위한 추출된 데이터의 Label을 확인할 수 있는 클래스

Attributes:
info: dict

재무제표 검색 Parameters 값들

Methods

save([filename, path])

재무제표 정보를 모두 엑셀파일로 일괄저장

show(tp[, show_class, show_depth, show_concept])

재무제표 정보를 표시해주는 Method

to_dict()

FinancialStatement의 요약 정보를 Dictionary 로 반환

load

property labels: Dict[str, DataFrame]

검색된 label들의 정보를 담고 있는 DataFrame

save(filename: str | None = None, path: str | None = None)[source]

재무제표 정보를 모두 엑셀파일로 일괄저장

Parameters:
filename: str

저장할 파일명(default: {corp_code}_{report_tp}.xlsx)

path: str

저장할 폴더(default: 실행폴더/fsdata)

property separator: bool

1000 단위 구분점 표시 여부

show(tp, show_class: bool = True, show_depth: int = 10, show_concept: bool = True) DataFrame | None[source]

재무제표 정보를 표시해주는 Method

Parameters:
tp: str

표시할 재무제표 타입: ‘fs’ 재무상태표, ‘is’ 손익계산서, ‘ci’ 포괄손익계산서, ‘cf’ 현금흐름표

show_class: bool

class 표시 여부

show_depth: bool

표시할 class의 깊이

show_concept: bool

concept_id 표시 여부

Returns:
DataFrame

재무제표

to_dict() Dict[str, str][source]

FinancialStatement의 요약 정보를 Dictionary 로 반환

Example

import dart_fss as dart

# 삼성전자 code
corp_code = '00126380'

# 모든 상장된 기업 리스트 불러오기
crp_list = get_corp_list()

# 삼성전자
samsung = corp_list.find_by_corp_name(corp_code=corp_code)

# 2012년 01월 01일 부터 연결재무제표 검색
# fs = samsung.extract_fs(bgn_de='20120101') 와 동일
fs = dart.fs.extract(corp_code=corp_code, bgn_de='20120101')

# 연결재무상태표
df_fs = fs['bs'] # 또는 df = fs[0] 또는 df = fs.show('bs')
# 연결재무상태표 추출에 사용된 Label 정보
labels_fs = fs.labels['bs']

# 연결손익계산서
df_is = fs['is'] # 또는 df = fs[1] 또는 df = fs.show('is')
# 연결손익계산서 추출에 사용된 Label 정보
labels_is = fs.labels['is']

# 연결포괄손익계산서
df_ci = fs['cis'] # 또는 df = fs[2] 또는 df = fs.show('cis')
# 연결포괄손익계산서 추출에 사용된 Label 정보
labels_ci = fs.labels['cis']

# 현금흐름표
df_cf = fs['cf'] # 또는 df = fs[3] 또는 df = fs.show('cf')
# 현금흐름표 추출에 사용된 Label 정보
labels_cf = fs.labels['cf']

# 재무제표 일괄저장 (default: 실행폴더/fsdata/{corp_code}_{report_tp}.xlsx)
fs.save()

# 재무제표 일괄저장
filename = '삼성전자'
path = '/User/xxxxx/Desktop/'
fs.save(filename=filename, path=path)