tirthajyoti / Finance-with-Python

Financial data analytics with Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP Error

ClarkCooper opened this issue · comments

Hi There,

Love the insightful article and code. I am having an issue with 'apple_dict=f.build_dict('AAPL')' I keep getting this error msg
HTTPError Traceback (most recent call last)
in
----> 1 apple_dict=f.build_dict('AAPL')

~/Finance-with-Python/financeAPI/financeAPI.py in build_dict(self, symbol)
117 return None
118
--> 119 self.profile_data_(symbol)
120 self.metrics_data_(symbol)
121 self.ratios_data_(symbol)

~/Finance-with-Python/financeAPI/financeAPI.py in profile_data_(self, symbol)
51
52 url = "https://financialmodelingprep.com/api/v3/"+'?apikey='+self.key
---> 53 response = urlopen(url)
54 data = response.read().decode("utf-8")
55 self.profile = json.loads(data)

~/anaconda3/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):

~/anaconda3/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
529 for processor in self.process_response.get(protocol, []):
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
533 return response

~/anaconda3/lib/python3.8/urllib/request.py in http_response(self, request, response)
638 # request was successfully received, understood, and accepted.
639 if not (200 <= code < 300):
--> 640 response = self.parent.error(
641 'http', request, response, code, msg, hdrs)
642

~/anaconda3/lib/python3.8/urllib/request.py in error(self, proto, *args)
567 if http_err:
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570
571 # XXX probably also want an abstract factory that knows when it makes

~/anaconda3/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
500 for handler in handlers:
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:
504 return result

~/anaconda3/lib/python3.8/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
647 class HTTPDefaultErrorHandler(BaseHandler):
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650
651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 400:

Can someone advise how to resolve