私はYahoo Finance Python APIを使用して過去の価格を取得しようとしていますが、コードを実行しようとするたびに同じエラーが発生します。それは私がJupyterノートブックとPython 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
私はこのモジュールをPIP(https://pypi.python.org/pypi/yahoo-finance/1.1.4)でインストールしましたが、この問題は表示されません。私はPython 3も使用しています。これが助けにならない場合は申し訳ありません。 –