2016-10-21 8 views
1

저는 역사적인 가격을 얻기 위해 Yahoo Finance Python API를 사용하려고했지만 코드를 실행하려고 할 때마다 동일한 오류가 발생합니다. 그것이 내가 Jupyter 노트북 및 파이썬 3Yahoo Finance Python API JSON 오류?

를 사용하고, 도움이된다면

파이썬 코드

from yahoo_finance import Share 

name = Share('YHOO') 
temp = (name.get_historical('2014-04-25','2015-04-29')) 

print (temp) 

그리고 오류 메시지

> 
> JSONDecodeError       Traceback (most recent call 
> last) <ipython-input-1-65dd835a5e8b> in <module>() 
> ----> 1 from fetch import * 
> 
> /Users/peterbullard/SMP/fetch.py in <module>() 
>  3 
> ----> 4 name = Share('YHOO') 
>  5 temp = (name.get_historical('2014-04-25', '2015-04-29')) 
>  6 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/__init__.py 
> in __init__(self, symbol) 
>  176   self._table = 'quotes' 
>  177   self._key = 'symbol' 
> --> 178   self.refresh() 
>  179 
>  180  def _fetch(self): 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/__init__.py 
> in refresh(self) 
>  140 
>  141   """ 
> --> 142   self.data_set = self._fetch() 
>  143 
>  144 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/__init__.py 
> in _fetch(self) 
>  179 
>  180  def _fetch(self): 
> --> 181   data = super(Share, self)._fetch() 
>  182   if data['LastTradeDate'] and data['LastTradeTime']: 
>  183    data[u'LastTradeDateTimeUTC'] = edt_to_utc('{0} {1}'.format(data['LastTradeDate'], data['LastTradeTime'])) 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/__init__.py 
> in _fetch(self) 
>  132  def _fetch(self): 
>  133   query = self._prepare_query(table=self._table, key=self._key) 
> --> 134   data = self._request(query) 
>  135   return data 
>  136 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/__init__.py 
> in _request(self, query) 
>  116 
>  117  def _request(self, query): 
> --> 118   response = yql.YQLQuery().execute(query) 
>  119   try: 
>  120    _, results = response['query']['results'].popitem() 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/yahoo_finance-1.2.1-py3.5.egg/yahoo_finance/yql.py 
> in execute(self, yql, token) 
>  58 
>  59  self.connection.request('GET', PUBLIC_API_URL + '?' + urlencode({ 'q': yql, 'format': 'json', 'env': DATATABLES_URL })) 
> ---> 60  return simplejson.loads(self.connection.getresponse().read()) 
>  61 
>  62 def __del__(self): 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/simplejson/__init__.py 
> in loads(s, encoding, cls, object_hook, parse_float, parse_int, 
> parse_constant, object_pairs_hook, use_decimal, **kw) 
>  514    parse_constant is None and object_pairs_hook is None 
>  515    and not use_decimal and not kw): 
> --> 516   return _default_decoder.decode(s) 
>  517  if cls is None: 
>  518   cls = JSONDecoder 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/simplejson/decoder.py 
> in decode(self, s, _w, _PY3) 
>  368   if _PY3 and isinstance(s, binary_type): 
>  369    s = s.decode(self.encoding) 
> --> 370   obj, end = self.raw_decode(s) 
>  371   end = _w(s, end).end() 
>  372   if end != len(s): 
> 
> /Users/peterbullard/anaconda/lib/python3.5/site-packages/simplejson/decoder.py 
> in raw_decode(self, s, idx, _w, _PY3) 
>  398    elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': 
>  399     idx += 3 
> --> 400   return self.scan_once(s, idx=_w(s, idx).end()) 
> 
> JSONDecodeError: Expecting value: line 1 column 1 (char 0) 

: 여기 내 코드와 오류입니다 터미널에서 콘솔 로그입니다.

W 08:59:40.681 NotebookApp] Unrecognized JSON config file version, assuming version 1 [I 08:59:41.410 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found [I 08:59:41.459 NotebookApp] The port 8888 is already in use, trying another port. [I 08:59:41.765 NotebookApp] [nb_anacondacloud] enabled [I 08:59:41.768 NotebookApp] [nb_conda] enabled [I 08:59:41.821 NotebookApp] ✓ nbpresent HTML export ENABLED [W 08:59:41.821 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf' [I 08:59:41.825 NotebookApp] Serving notebooks from local directory: /Users/peterbullard [I 08:59:41.825 NotebookApp] 0 active kernels [I 08:59:41.825 NotebookApp] The Jupyter Notebook is running at: http://localhost:8889/ [I 08:59:41.825 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [I 08:59:53.346 NotebookApp] Kernel started: 92b75861-94a5-4002-9ab4-97988c0cebfe [W 08:59:53.365 NotebookApp] 404 GET /kernelspecs/Python%20[Root]/logo-64x64.png (::1) 11.76ms referer= http://localhost:8889/notebooks/SMP/Test.ipynb [I 08:59:55.917 NotebookApp] Kernel restarted: 92b75861-94a5-4002-9ab4-97988c0cebfe

+1

방금 ​​PIP (https://pypi.python.org/pypi/yahoo-finance/1.1.4)를 사용하여이 모듈을 설치했지만이 문제는 표시되지 않습니다. 그리고 파이썬 3도 사용하고 있습니다. 미안하다면 도움이되지 않습니다. –

답변

0

는 여기 https://pypi.python.org/pypi/yahoo-finance

그것은 말한다로부터의 지시를 따랐습니다 :

Yahoo! Finance backend is http://datatables.org/ . If this service is down or has network problems you will receive errors from group YQL*, eg. YQLQueryError.

그래서이 서비스는 밖으로 그리고 당신은 YQL 오류가 계속 이유입니다. 나는이 문제가 2016 년으로 거슬러 올라간다면 서비스가 잠시 중단 된 것으로 가정하고 있습니다.

YQL (Yahoo Query Language)을 사용해 볼 수 있습니다. 여기에 시작하기위한 페이지가 있습니다 https://developer.yahoo.com/yql/#python

관련 문제