Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

국고채수익율 (KR1YT=RR, KR10YT=RR, ...)을 가져오지 못합니다 #201

Open
godus1201 opened this issue Jan 17, 2024 · 3 comments

Comments

@godus1201
Copy link

godus1201 commented Jan 17, 2024

국고채수익율을 가져오지 못합니다
(KR1YT=RR, KR10YT=RR, ...)

df = fdr.DataReader('KR10YT=RR')
HTTP Error 404: Not Found - symbol "KR10YT=RR" not found or invalid periods
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\FinanceDataReader\data.py", line 85, in DataReader
return YahooDailyReader(codes, start, end).read()
File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\FinanceDataReader\yahoo\data.py", line 58, in read
return _yahoo_data_reader(self.symbol, self.exchange, self.start, self.end)

File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\FinanceDataReader\yahoo\data.py", line 42, in _yahoo_data_reader
df = df[['Open', 'High', 'Low', 'Adj Close', 'Volume']]
File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\pandas\core\frame.py", line 3511, in getitem
indexer = self.columns._get_indexer_strict(key, "columns")[1]
File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\pandas\core\indexes\base.py", line 5782, in _get_indexer_strict
self._raise_if_missing(keyarr, indexer, axis_name)
File "C:\Users\SHBY\Anaconda3\envs\py310_64\lib\site-packages\pandas\core\indexes\base.py", line 5842, in _raise_if_missing
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['Open', 'High', 'Low', 'Adj Close', 'Volume'], dtype='object')] are in the [columns]"

investing.com => yahoo finance 로 대체된 이후 위 티커는 값을 못가져오는 것 같은데.. 방법이 없을까요??

@godus1201 godus1201 changed the title investing.com 자료 가져오는데 문제가 있나요? 국고채수익율 (KR1YT=RR, KR10YT=RR, ...)을 가져오지 못합니다 Jan 17, 2024
@FinanceData
Copy link
Owner

현재는 채권 수익률은 yahoo finance에서 데이터를 가져오고 있으며,
미국 국채 수익률(US5YT, US10YT, US30YT)과 FRED의 미국국채데이터(FRED:DGS1, FRED:DGS2, FRED:DGS5 ... FRED:DGS30)만 지원하고 있습니다.

한국 국채 수익률 데이터는 제공하고 있지 못하고 있습니다.

조만간 한국거래소(KRX)의 채권수익률 데이터를 지원할 예정이며, 업데이트가 이루어지면 답글을 하도록 하겠습니다.

@ju-ing
Copy link

ju-ing commented Feb 8, 2024

Investing 모듈을 직접 불러와서 짜는 방식으로 우회하실 수 있습니다.

from datetime import datetime, timedelta
from FinanceDataReader.investing.data import InvestingDailyReader

end = datetime.now().strftime("%Y-%m-%d")
start = (datetime.now() - timedelta(20)).strftime("%Y-%m-%d")

reader = InvestingDailyReader(symbol="KR1YT=RR", start=start, end=end)
data = reader.read()
data
Close Open High Low Volume Change
Date
2024-01-19 3.300 3.300 3.300 3.300 0.0 0.0000
2024-01-20 3.300 3.300 3.300 3.300 0.0 0.0000
2024-01-21 3.300 3.300 3.300 3.300 0.0 0.0000
2024-01-22 3.300 3.300 3.300 3.300 0.0 0.0000
2024-01-23 3.297 3.300 3.300 3.297 0.0 -0.0009
2024-01-24 3.297 3.297 3.300 3.297 0.0 0.0000
2024-01-25 3.296 3.297 3.300 3.296 0.0 -0.0003
2024-01-26 3.303 3.296 3.303 3.296 0.0 0.0021
2024-01-29 3.316 3.315 3.316 3.315 0.0 0.0039
2024-01-30 3.310 3.310 3.311 3.310 0.0 -0.0018
2024-01-31 3.308 3.310 3.310 3.308 0.0 -0.0006
2024-02-01 3.322 3.308 3.330 3.308 0.0 0.0042
2024-02-02 3.313 3.322 3.322 3.310 0.0 -0.0027
2024-02-03 3.313 3.313 3.313 3.313 0.0 0.0000
2024-02-04 3.313 3.313 3.313 3.313 0.0 0.0000
2024-02-05 3.313 3.313 3.313 3.313 0.0 0.0000
2024-02-06 3.355 3.343 3.355 3.343 0.0 0.0127
2024-02-07 3.377 3.355 3.378 3.355 0.0 0.0066
2024-02-08 3.403 3.377 3.406 3.377 0.0 0.0077

@FinanceData
Copy link
Owner

FinanceData commented Mar 5, 2024

@ju-ing 님께서 놀라운 사용법을 알려주셨습니다. Colab에서 실행하는 경우 @ju-ing 님께서 알려주신 바와 같이 수행이 됩니다.

#166 등의 이슈 처럼 cloudflare 의 정책 문제로 클라이언트 IP에 따라 investing에서 크롤링이 불가합니다. (이 때문에 크롤링 대상을 yahoo로 변경하였습니다). 로컬PC (대한민국 국내 IP)의 경우 아래와 같은 페이지가 반환됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants