### Quick Start: Fetch and Save Financial Statements Source: https://github.com/josw123/dart-fss/blob/master/docs/welcome.md This example demonstrates how to set up your API key, retrieve a list of companies, find a specific company, extract its financial statements from a specified date, and save them to an Excel file. Ensure your API key is kept confidential. ```python import dart_fss as dart # Open DART API KEY 설정 api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' dart.set_api_key(api_key=api_key) # DART 에 공시된 회사 리스트 불러오기 corp_list = dart.get_corp_list() # 삼성전자 검색 samsung = corp_list.find_by_corp_name('삼성전자', exactly=True)[0] # 2012년부터 연간 연결재무제표 불러오기 fs = samsung.extract_fs(bgn_de='20120101') # 재무제표 검색 결과를 엑셀파일로 저장 ( 기본저장위치: 실행폴더/fsdata ) fs.save() ``` -------------------------------- ### Install dart-fss Library Source: https://github.com/josw123/dart-fss/blob/master/docs/welcome.md Install the dart-fss library using pip. This is the first step to using the library's functionalities. ```default pip install dart-fss ``` -------------------------------- ### Extract Financial Statements for a Corporation Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_fs.md Use this snippet to extract all available financial statements for a specific corporation code starting from a given date. Ensure you have the dart_fss library installed and have obtained the necessary company list. ```python 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) ``` -------------------------------- ### DART 공시 정보 검색 Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_search.md DART 공시 정보를 검색하는 함수입니다. 검색 기간, 공시 유형, 페이지당 건수 등을 지정할 수 있습니다. 기간 지정 시 최대 3개월까지 검색 가능합니다. ```python import dart_fss as dart # 2019년 1월 1일부터 2019년 3월 31일까지 검색 (crp_cd 미지정시 최대 3개월만 검색가능) reports = dart.filings.search(bgn_de='20190101', end_de='20190331') ``` ```python # 2019년 1월 1일부터 2019년 3월 31일까지 검색 (페이지당 표시 건수: 100) reports = dart.filings.search(bgn_de='20190101', end_de='20190331', page_count=100) ``` ```python # 2019년 5월 1일부터 2019년 7월 1일까지 연간보고서만 검색 reports = dart.filings.search(bgn_de='20190501', end_de='20190701', pblntf_detail_ty='a001') ``` ```python # 2019년 5월 1일부터 2019년 7월 1일까지 연간보고서 및 반기보고서 검색 reports = dart.filings.search(bgn_de='20190501', end_de='20190701', pblntf_detail_ty=['a001', 'a002']) ``` -------------------------------- ### 상장된 기업 리스트 불러오기 및 검색 Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_corp.md DART에 공시된 모든 상장 기업 리스트를 불러오고, 이름, 증권 코드, 회사 코드, 제품, 시장, 섹터 등으로 검색합니다. `get_corp_list()` 함수를 사용하여 전체 리스트를 가져옵니다. ```python from dart_fss import get_corp_list # 모든 상장된 기업 리스트 불러오기 crp_list = get_corp_list() # 삼성전자를 이름으로 찾기 ( 리스트 반환 ) samsung = corp_list.find_by_name('삼성전자', exactly=True)[0] # 증권 코드를 이용한 찾기 samsung = corp_list.find_by_stock_code('005930') # 다트에서 사용하는 회사코드를 이용한 찾기 samsung = corp_list.find_by_corp_code('00126380') # "삼성"을 포함한 모든 공시 대상 찾기 corps = corp_list.find_by_name('삼성') # "삼성"을 포함한 모든 공시 대상중 코스피 및 코스닥 시장에 상장된 공시 대상 검색(Y: 코스피, K: 코스닥, N:코넥스, E:기타) # corps = corp_list.find_by_name('삼성', market=['Y','K']) # 아래와 동일 corps = corp_list.find_by_name('삼성', market='YK') # "휴대폰" 생산품과 연관된 공시 대상 corps = corp_list.find_by_product('휴대폰') # "휴대폰" 생산품과 연관된 공시 대상 중 코스피 시장에 상장된 대상만 검색 corps = corp_list.find_by_product('휴대폰', market='Y') # 섹터 리스트 확인 corp_list.sectors # "텔레비전 방송업" 섹터 검색 corps = corp_list.find_by_sector('텔레비전 방송업') ``` -------------------------------- ### 특정 기업의 공시 정보 조회 Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_corp.md 특정 기업(`Crp` 객체)의 공시 정보를 지정된 기간 및 보고서 유형별로 조회합니다. `search_filings` 메소드를 사용하며, 시작일, 종료일, 공시 상세 유형, 최종 보고서 여부 등을 지정할 수 있습니다. ```python # 2019년 3월 1일부터 2019년 5월 31일까지 삼성전자의 모든 공시 정보 조회 reports = samsung.search_filings(bgn_de='20190301', end_de='20190531') # 2010년 1월 1일부터 현재까지 모든 사업보고서 검색 reports = samsung.search_filings(bgn_de='20100101', pblntf_detail_ty='a001') # 2010년 1월 1일부터 현재까지 모든 사업보고서의 최종보고서만 검색 reports = samsung.search_filings(bgn_de='20100101', pblntf_detail_ty='a001', last_reprt_at='Y') # 2010년 1월 1일부터 현재까지 사업보고서, 반기보고서, 분기보고서 검색 reports = samsung.search_filings(bgn_de='20100101', pblntf_detail_ty=['a001', 'a002', 'a003']) ``` -------------------------------- ### Analyze XBRL Data for Samsung Electronics Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_xbrl.md This snippet demonstrates fetching company information, searching for business reports, and extracting XBRL data for Samsung Electronics. It shows how to check for consolidated financial statements, retrieve audit information in English, and extract cash flow statements. ```python import dart_fss as dart # 삼성전자 code corp_code = '00126380' # 모든 상장된 기업 리스트 불러오기 corp_list = dart.get_corp_list() # 삼성전자 samsung = corp_list.find_by_corp_code(corp_code=corp_code) # 사업보고서 검색 reports = samsung.search_filings(bgn_de='20190101', pblntf_detail_ty='a001') # 첫번째 리포트 선택 report = reports[0] # 리포트의 xbrl 데이터 xbrl = report.xbrl # 연결재무제표 존재 여부 확인( True / False) xbrl.exist_consolidated() # 감사 정보 (영문) -> DataFrame 형태로 반환됨 audit = xbrl.get_audit_information(lang='en') # 연결 현금흐름표 추출 (리스트 반환) cf = xbrl.get_cash_flows() # 연결 현금프름표 cf = cf[0] # Pandas DataFrame으로 변환 df = cf.to_DataFrame() # Pandas DataFrame으로 변환 / 분류 정보 제외 df_wo_class = cf.to_DataFrame(show_class=False) ``` -------------------------------- ### SearchResults 객체 활용 Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_search.md 검색된 공시 보고서 목록을 담는 SearchResults 객체의 활용 예시입니다. 특정 기업의 보고서를 검색하고, 인덱싱 및 슬라이싱을 통해 보고서를 선택하는 방법을 보여줍니다. ```python 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) # 연간보고서 검색 # reports = samsung.search_filings(bgn_de='20100101', pblntf_detail_ty='a001') reports = search_report(corp_code=corp_code, bgn_de='20100101', pblntf_detail_ty='a001') ``` ```python # Reports의 Index는 0부터 시작 # 가장 최신 보고서 선택 newest_report = reports[0] ``` ```python # 0-4번 보고서 선택 zero_to_fourth_report = reports[0:5] ``` ```python # 짝수번째 보고서 선택 even_report = reports[::2] ``` ```python # 가장 오래된 보고서 선택 oldest_report = reports[-1] ``` -------------------------------- ### Configure DART-FSS Request Settings Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_request.md Use dart.utils.request to modify request delay, set proxy servers, and update the user agent. The `set_delay` function takes seconds as input. Proxy configuration requires a dictionary of 'http' and 'https' URLs. `update_user_agent` can force an update. ```python import dart_fss as dart # DART_FSS Request Delay 0.7s로 변경 dart.utils.request.set_delay(0.7) # 프록시 설정 proxies = {'http': 'http://xxxxxxxxx.xxx','https': 'https://xxxxxxxxx.xxx'} dart.utils.request.set_proxies(proxies) # User-Agent 강제 변경 dart.utils.request.update_user_agent(force=True) ``` -------------------------------- ### 특정 기업의 재무제표 추출 Source: https://github.com/josw123/dart-fss/blob/master/docs/dart_corp.md 특정 기업의 연결 또는 개별 재무제표를 지정된 기간 및 보고서 유형별로 추출합니다. `extract_fs` 메소드를 사용하며, 시작일, 보고서 유형(연간, 분기), 개별 재무제표 여부 등을 지정할 수 있습니다. ```python # 2012년 1월 1일부터 현재까지 연간 연결재무제표 검색 fs = samsung.extract_fs(bgn_de='20120101') # 2012년 1월 1일부터 현재까지 분기 연결재무제표 검색 (연간보고서, 반기보고서 포함) fs_quarter = samsung.extract_fs(bgn_de='20120101', report_tp='quarter') # 2012년 1월 1일부터 현재까지 개별재무제표 검색 fs_separate = samsung.extract_fs(bgn_de='20120101', separate=True) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.