개발

[Python] FinanceData 활용기 (1)

hellworld 2022. 9. 28. 19:58

주식 정보를 읽어올 수 있는 finance-datareader 패키지를 설치한다.

pip install finance-datareader
finance-datareader 패키지 설치

웹 기반 크로링을 위해 bs4 패키지를 설치한다.

pip install bs4
bs4 패키지 설치

간단하게 기본 정보를 수집할 수 있는 코드를 작성한다.

import FinanceDataReader as Finance
# 한국 전체 주식
FinanceDataKRX = Finance.StockListing('KRX')
print('[KRX]---------------------------------------------')
print(FinanceDataKRX)
print('\n\n\n')

# 한국 코스피 조회
FinanceDataKOSPI = Finance.StockListing('KOSPI')
print('[KOSPI]-------------------------------------------')
print(FinanceDataKOSPI)
코드 실행 결과물


다음 장에서는 구체적인 데이터를 수집하고 질의할 수 있는 함수를 만들어 볼 예정.

pip install finance-datareader 참고: https://seong6496.tistory.com/169 [파이프마임:티스토리]