stock.get_market_ohlcv / 'OverflowError: Python int too large to convert to C long 오류
Opened this issue · 4 comments
emoochin commented
stock.get_market_ohlcv('20220924', '20240223', '032800') # 판타지오 032800
위 코드 실행 시 'OverflowError: Python int too large to convert to C long 오류가 발생합니다.
특이한 점은 데이터 조회 일자에 따라 오류가 발생하기도 하고 정상 동작하기도 합니다.
금일 실행 기준으로,
- 20220924 이전의 데이터에 대해 조회하면 에러가 발생합니다.
- stock.get_market_ohlcv('20220925', '20240223', '032800') 이런 식으로 20220925 이후의 날짜에 대해 조회하면 정상 동작합니다.
코드 실행 환경은 아래와 같습니다.
- 윈도우 10
- anaconda 가상 환경
- 가상 환경 파이썬 버전 3.9.19
해결법을 찾지 못하여 문의 드립니다.
mr-yoo commented
모듈 버전을 확인해 주세요.
import pykrx
print(pykrx.__version__)
현재 최신은 1.0.46
입니다. 과거 버전이라면 업데이트 해 주시구요.
pip install -U pykrx
Yukariko commented
Traceback (most recent call last):
File "/Users/yukariko/git/trading/database.py", line 10, in <module>
df = stock.get_market_ohlcv("20110101", "20110201", ticker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pykrx/stock/stock_api.py", line 189, in get_market_ohlcv
return get_market_ohlcv_by_date(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pykrx/stock/stock_api.py", line 231, in get_market_ohlcv_by_date
df = naver.get_market_ohlcv_by_date(fromdate , todate, ticker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pykrx/website/naver/wrap.py", line 28, in get_market_ohlcv_by_date
df = df.astype(np.int32)
^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/generic.py", line 6643, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/internals/managers.py", line 430, in astype
return self.apply(
^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/internals/managers.py", line 363, in apply
applied = getattr(b, f)(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/internals/blocks.py", line 758, in astype
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/dtypes/astype.py", line 237, in astype_array_safe
new_values = astype_array(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/dtypes/astype.py", line 182, in astype_array
values = _astype_nansafe(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yukariko/.venv/lib/python3.12/site-packages/pandas/core/dtypes/astype.py", line 133, in _astype_nansafe
return arr.astype(dtype, copy=True)
OverflowError: Python integer 3929287705 out of bounds for int32
trace 첨부합니다.