인프런 커뮤니티 질문&답변

ilhalm님의 프로필 이미지
ilhalm

작성한 질문수

파이썬(Python)으로 데이터 기반 주식 퀀트 투자하기 Part1

(2.6 reindex() 관련 예제) 2.4.3.2. 예제에서 df1 = fdr.DataReader("005930", '2018-01-02', '2018-10-30')를 실행하면 에러가 뜹니다.

해결된 질문

작성

·

382

0

교수님 안녕하세요? 수업 잘 듣고 있는 학생입니다.
 
2.4.3.2. 예제에서 df1 = fdr.DataReader("005930", '2018-01-02', '2018-10-30')를 실행하면 아래와 같이 에러가 뜨는데 에러에 대한 설명이 이해가 잘 안 되어서요. 설명부탁드리겠습니다. 감사합니다.
 
 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-155-4f798ac940a0> in <module>
      1 # 삼성전자
----> 2 df1 = fdr.DataReader("005930", '2018-01-02', '2018-10-30')

~\anaconda3\lib\site-packages\FinanceDataReader\data.py in DataReader(symbol, start, end, exchange, data_source)
     31     if (symbol[:5].isdigit() and exchange==None) or \
     32        (symbol[:5].isdigit() and exchange and exchange.upper() in ['KRX', '한국거래소']):
---> 33         return NaverDailyReader(symbol, start, end, exchange, data_source).read()
     34 
     35     # KRX-DELISTING

~\anaconda3\lib\site-packages\FinanceDataReader\naver\data.py in read(self)
     14     def read(self):
     15         url = 'https://fchart.stock.naver.com/sise.nhn?timeframe=day&count=6000&requestType=0&symbol='
---> 16         r = requests.get(url + self.symbol)
     17 
     18         data_list = re.findall('<item data=\"(.*?)\" />', r.text, re.DOTALL)

~\anaconda3\lib\site-packages\requests\api.py in get(url, params, **kwargs)
     74 
     75     kwargs.setdefault('allow_redirects', True)
---> 76     return request('get', url, params=params, **kwargs)
     77 
     78 

~\anaconda3\lib\site-packages\requests\api.py in request(method, url, **kwargs)
     59     # cases, and look like a memory leak in others.
     60     with sessions.Session() as session:
---> 61         return session.request(method=method, url=url, **kwargs)
     62 
     63 

~\anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    540         }
    541         send_kwargs.update(settings)
--> 542         resp = self.send(prep, **send_kwargs)
    543 
    544         return resp

~\anaconda3\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
    653 
    654         # Send the request
--> 655         r = adapter.send(request, **kwargs)
    656 
    657         # Total elapsed time of the request (approximately)

~\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    437         try:
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,
    441                     url=url,

~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    694             )
    695             if is_new_proxy_conn and http_tunnel_required:
--> 696                 self._prepare_proxy(conn)
    697 
    698             # Make the request on the httplib connection object.

~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _prepare_proxy(self, conn)
    962             conn.tls_in_tls_required = True
    963 
--> 964         conn.connect()
    965 
    966     def _new_conn(self):

~\anaconda3\lib\site-packages\urllib3\connection.py in connect(self)
    357         if self._is_using_tunnel():
    358             if self.tls_in_tls_required:
--> 359                 conn = self._connect_tls_proxy(hostname, conn)
    360                 tls_in_tls = True
    361 

~\anaconda3\lib\site-packages\urllib3\connection.py in _connect_tls_proxy(self, hostname, conn)
    498         # If no cert was provided, use only the default options for server
    499         # certificate validation
--> 500         return ssl_wrap_socket(
    501             sock=conn,
    502             ca_certs=self.ca_certs,

~\anaconda3\lib\site-packages\urllib3\util\ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls)
    430         )
    431     else:
--> 432         ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
    433     return ssl_sock
    434 

~\anaconda3\lib\site-packages\urllib3\util\ssl_.py in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname)
    472         return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
    473     else:
--> 474         return ssl_context.wrap_socket(sock)

~\anaconda3\lib\ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~\anaconda3\lib\ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
    995                                  "client mode")
    996         if context.check_hostname and not server_hostname:
--> 997             raise ValueError("check_hostname requires server_hostname")
    998 
    999         kwargs = dict(

ValueError: check_hostname requires server_hostname

답변 1

0

DeepingSauce님의 프로필 이미지
DeepingSauce
지식공유자

안녕하세요!

혹시 finance-datareader==0.9.1 로 같은 버전의 라이브러리를 설치를 하셨을까요?

jupyter노트북을 완전히 종료하고, anaconda prompt에서 pip install finance-datareader==0.9.1 실행 후 jupyter 재실행해서 확인해보시겠어요?



ilhalm님의 프로필 이미지
ilhalm
질문자

교수님 신속한 답변 감사드립니다. 말씀대로 anaconda prompt에서 pip install finance-datareader==0.9.1 실행 후 jupyter 재실행해 봤는데, 아래와 같이 됩니다. 무엇이 문제일까요..ㅠ

 

(base) C:\Users\Ilhalm\Desktop\python_class>pip install finance-datareader==0.9.1

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1108: The handshake operation timed out'))': /simple/finance-datareader/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1108: The handshake operation timed out'))': /simple/finance-datareader/

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1108: The handshake operation timed out'))': /simple/finance-datareader/

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1108: The handshake operation timed out'))': /simple/finance-datareader/

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1108: The handshake operation timed out'))': /simple/finance-datareader/

ERROR: Could not find a version that satisfies the requirement finance-datareader==0.9.1

ERROR: No matching distribution found for finance-datareader==0.9.1

ilhalm님의 프로필 이미지
ilhalm
질문자

교수님께서 앞 강의에서 !pip install -r requirements.txt를 통해 모든 library를 한꺼번에 설치하는 방법을 가르쳐주셔서 여기를 통해 다시 해봤는데, 아래와 같이 뜹니다. 판다스를 다시 깔아야 하는 건가요? 

 

ilhalm님의 프로필 이미지
ilhalm

작성한 질문수

질문하기