본문 바로가기

Data Science/Data Collection

[04. 금융감독원 API] 006. 사업보고서 주요정보 – 자기주식 취득 및 처분 현황

728x90

자기주식 취득 및 처분 현황 API 코드를 작성해보자.

 

[그림 4.6] 자기주식 취득 및 처분 현황 개발가이드

 

import json
import pandas as pd
import requests

def get_treasury_stock_change(api_key, code, year, report_code):
    fullUrl = 'https://opendart.fss.or.kr/api/tesstkAcqsDspsSttus.json?crtfc_key=%s&corp_code=%s&' \
              'bsns_year=%s&reprt_code=%s' % (api_key, code, year, report_code)

    response = requests.get(fullUrl, headers={'User-Agent': 'Mozilla/5.0'})
    result = response.text
    result = json.loads(result)

    if result['status'] == '000':
        data = pd.DataFrame(result['list'])

        return data

if __name__ == '__main__':
    api_key ='*'
    code = '00126380'
    year = '2018'
    report_code = '11011'

    treasury_stock_change = get_treasury_stock_change(api_key, code, year, report_code)
    print(treasury_stock_change)


결과 값
rcept_no corp_cls corp_code  ... change_qy_incnr trmend_qy rm
0  20190401004781        Y  00126380  ...               -         -  -
728x90