addisonlynch / iexfinance

Python SDK for IEX Cloud
https://addisonlynch.github.io/iexfinance
Apache License 2.0
649 stars 136 forks source link

After installing iex, the tutorial does not work. Please help. I'm coding an important student project. #28

Closed Fabelsady closed 6 years ago

Fabelsady commented 6 years ago

from iexfinance import IexFinance as iex

aapl = iex("aapl")

JSONDecodeError Traceback (most recent call last)

in () 1 from iexfinance import Share ----> 2 tsla = Share('TSLA') 3 print(tsla.get_open()) 4 print(tsla.get_price()) ~\Anaconda3\lib\site-packages\iexfinance\__init__.py in __init__(self, symbol, **kwargs) 37 self.IEX_ENDPOINT_NAME = 'stock/{0}/batch'.format(self.symbol) 38 super(Share, self).__init__(self.key, self.symbolList, **kwargs) ---> 39 self.data_set = self.refresh() 40 41 ~\Anaconda3\lib\site-packages\iexfinance\__init__.py in refresh(self) 41 42 def refresh(self): ---> 43 data = super(Share, self)._fetch() 44 self.data_set = data[self.symbol] 45 return data[self.symbol] ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _fetch(self) 178 def _fetch(self): 179 if self._default_options(): --> 180 return self._fetch_default_options() 181 else: 182 data_set = dict.fromkeys(self.symbolList, {}) ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _fetch_default_options(self) 164 eps = list(self._ENDPOINTS.keys()) 165 query = self._prepare_query(eps) --> 166 response = self._executeIEXQuery(query) 167 if self._key == "Share": 168 response = {self.symbol : response} ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _executeIEXQuery(cls, url) 129 pass 130 return cls._validate_response(r) --> 131 return _api_call(cls, url) 132 133 @classmethod ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _api_call(cls, url) 128 except requests.exceptions.RequestException as e: 129 pass --> 130 return cls._validate_response(r) 131 return _api_call(cls, url) 132 ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _validate_response(response) 108 raise IEXSymbolError(self.symbolList[0]) 109 --> 110 json_response = response.json() 111 if not json_response: 112 raise IEXQueryError() ~\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 890 # used. 891 pass --> 892 return complexjson.loads(self.text, **kwargs) 893 894 @property ~\Anaconda3\lib\site-packages\simplejson\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw) 516 parse_constant is None and object_pairs_hook is None 517 and not use_decimal and not kw): --> 518 return _default_decoder.decode(s) 519 if cls is None: 520 cls = JSONDecoder ~\Anaconda3\lib\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): ~\Anaconda3\lib\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) In [16]: from iexfinance import IexFinance as iex aapl = iex("aapl") >>> aapl.get_price() File "", line 3 >>> aapl.get_price() ^ SyntaxError: invalid syntax In [17]: >>> from iexfinance import IexFinance as iex ​ >>> aapl = iex("aapl") --------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) in () 1 from iexfinance import IexFinance as iex 2 ----> 3 aapl = iex("aapl") ~\Anaconda3\lib\site-packages\iexfinance\__init__.py in IexFinance(symbol, **kwargs) 12 raise ValueError("Please input a symbol or list of symbols") 13 else: ---> 14 inst = Share(symbol, **kwargs) 15 elif type(symbol) is list: 16 if not symbol: ~\Anaconda3\lib\site-packages\iexfinance\__init__.py in __init__(self, symbol, **kwargs) 37 self.IEX_ENDPOINT_NAME = 'stock/{0}/batch'.format(self.symbol) 38 super(Share, self).__init__(self.key, self.symbolList, **kwargs) ---> 39 self.data_set = self.refresh() 40 41 ~\Anaconda3\lib\site-packages\iexfinance\__init__.py in refresh(self) 41 42 def refresh(self): ---> 43 data = super(Share, self)._fetch() 44 self.data_set = data[self.symbol] 45 return data[self.symbol] ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _fetch(self) 178 def _fetch(self): 179 if self._default_options(): --> 180 return self._fetch_default_options() 181 else: 182 data_set = dict.fromkeys(self.symbolList, {}) ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _fetch_default_options(self) 164 eps = list(self._ENDPOINTS.keys()) 165 query = self._prepare_query(eps) --> 166 response = self._executeIEXQuery(query) 167 if self._key == "Share": 168 response = {self.symbol : response} ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _executeIEXQuery(cls, url) 129 pass 130 return cls._validate_response(r) --> 131 return _api_call(cls, url) 132 133 @classmethod ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _api_call(cls, url) 128 except requests.exceptions.RequestException as e: 129 pass --> 130 return cls._validate_response(r) 131 return _api_call(cls, url) 132 ~\Anaconda3\lib\site-packages\iexfinance\iexretriever.py in _validate_response(response) 108 raise IEXSymbolError(self.symbolList[0]) 109 --> 110 json_response = response.json() 111 if not json_response: 112 raise IEXQueryError() ~\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 890 # used. 891 pass --> 892 return complexjson.loads(self.text, **kwargs) 893 894 @property ~\Anaconda3\lib\site-packages\simplejson\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw) 516 parse_constant is None and object_pairs_hook is None 517 and not use_decimal and not kw): --> 518 return _default_decoder.decode(s) 519 if cls is None: 520 cls = JSONDecoder ~\Anaconda3\lib\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): ~\Anaconda3\lib\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)
jamesliusongyu commented 6 years ago

help im facing this problem too

addisonlynch commented 6 years ago

It's due to changes from the provider (see #23). Will be fixed by the end of the week (see #19). Sorry about this. Also, the top-level function IexFinance is now Stock and can be imported as such. All will be in the docs for new release

Temporary fix is to use the dev version (current master branch):

install: see readme after installing:

from iexfinance import Stock

aapl = Stock("AAPL")
aapl.get_price()
Fabelsady commented 6 years ago

Dear Addison,

When I tried to download the developer version using the code pip install git+https://github.com/addisonlynch/iexfinance.git

I got an error too : Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/addisonlynch/iexfinance.git C:\Users\Surface\AppData\Local\Temp\pip-1046woj_-build Cannot find command 'git'

I keyed in the command in anaconda prompt.

Please help and thank you for your assistance.

Cheers, Wendy

From: Addison Lynch [mailto:notifications@github.com] Sent: Thursday, 8 February 2018 5:25 PM To: addisonlynch/iexfinance iexfinance@noreply.github.com Cc: #LEE HUI WEN WENDY# WLEE041@e.ntu.edu.sg; Author author@noreply.github.com Subject: Re: [addisonlynch/iexfinance] After installing iex, the tutorial does not work. Please help. I'm coding an important student project. (#28)

It's due to changes from the provider (see #23https://github.com/addisonlynch/iexfinance/issues/23). Will be fixed by the end of the week (see #19https://github.com/addisonlynch/iexfinance/issues/19). Sorry about this. Also, the top-level function IexFinance is now Stock and can be imported as such. All will be in the docs for new release

Temporary fix is to use the dev version (current master branch):

install: see readmehttps://github.com/addisonlynch/iexfinance after installing:

from iexfinance import Stock

aapl = Stock("AAPL")

aapl.get_price()

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/addisonlynch/iexfinance/issues/28#issuecomment-364051574, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AijJjgFGTTF7k5LxJ9G-DMv3mA4aG8Ubks5tSr1ngaJpZM4R8dWy.

addisonlynch commented 6 years ago

RLS 0.3.0 (2/17/18) repairs these issues