sharebook-kr / pykrx

KRX 주식 정보 스크래핑
693 stars 240 forks source link

get_business_days #48

Closed shinyh99 closed 3 years ago

shinyh99 commented 3 years ago

pykrx/stock/api.py의 get_business_days에서 month를 12월 넣으면 오류가 발생합니다.

year 2020, month 12로 입력시, strt = 20201201 last = 20201301의 값을 get_market_ohlcv_by_date에 입력해서 오류가 나네요.

month를 1~12월로 검증하는 로직이 필요해 보입니다!

좋은 패키지 감사합니다. def get_business_days(year: int, mon: int) -> list: strt = "{}{:02d}01".format(year, mon) last = "{}{:02d}01".format(year, mon+1) df = get_market_ohlcv_by_date(strt, last, "000020")

mr-yoo commented 3 years ago

https://github.com/sharebook-kr/pykrx/commit/a95fa72e53d237ac58ef8a047e96217c43f97673 에서 reporting 해주신 내용 수정했습니다. 코드는 merge 됐고 pykrx 모듈은 다른 이슈와 함께 일주일 내에 배포될 예정입니다.

사용하지 않을 거라고 생각해서 get_business_days 함수를 제거할 예정이었는데 사용하시는 것 같아 기능을 추가했습니다. 이름을 좀 더 구체화해서 업데이트 했습니다.

# 다음은 지정한 월의 영업일을 반환합니다.
stock.get_previous_business_days(year=2020, month=12)

# 다음은 날짜를 지정해서 영업일을 구합니다. 
stock.get_previous_business_days(fromdate="20200101", todate="20200115")

기존의 로직도 사용할 수는 있지만 추후 제거될 예정입니다.

days = stock.get_business_days(2020, 12)
print(days)