250x250
Notice
Recent Posts
Recent Comments
Link
코딩걸음마
특정기간 상승률 순위 검색기 본문
728x90
pykrx에는 특정기간동안 가격등락률을 조회하는 기능이 있다.
리스트를 모두 조회하여 상승률이 가장 높은 종목을 추출해보자!
def top_rank(start,end,market,number):
from pykrx import stock
stock_info_kospi = stock.get_market_price_change_by_ticker(fromdate=start, todate=end, market=market)
i=0
top_list=[]
while i <number:
top_name=stock_info_kospi.sort_values('등락률',ascending=False).head(number)['종목명'][i]
top_change_per=stock_info_kospi.sort_values('등락률',ascending=False).head(number)['등락률'][i]
list=[top_name, top_change_per]
top_list.append(list)
i+=1
if i==number:
return top_list
def rank(start,end,market,number,rank):
name=top_rank(start,end,market,number)[rank][0]
per=top_rank(start,end,market,number)[rank][1]
return (name, per)
for i in range(11):
# rank(시작,끝, KOSPI | KOSDAQ | All, 상위 몇위까지?, 상위 몇위 종목)
print(rank("20220101","20220620","ALL",10,i))
728x90
'나만의 프로그램' 카테고리의 다른 글
공공데이터 API를 활용한 데이터 크롤링 방법 (ex.경주마 성적정보) (0) | 2022.07.10 |
---|---|
[딥러닝] 딥러닝 기본 흐름도 (0) | 2022.06.30 |
주식 매매시뮬레이션게임 (with 파이썬) (0) | 2022.06.20 |
종목별 테마 크롤링 코드(with Naver 금융) (0) | 2022.06.19 |
주식 정보 불러와서 미래수익률 예측기 만들기 (with Pykrx) (0) | 2022.06.19 |
Comments