Skip to content

Commit

Permalink
Remove iex code from ticker plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmaguire committed Jul 7, 2023
1 parent 9d2588d commit 439f7de
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions plugins/ticker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ def _populate(self, year):
# Class populated with NYSE holidays
HOLIDAYS = NYSEHolidays()

# IEX API Endpoint
IEX_QUOTE_API_URL = "https://cloud.iexapis.com/stable/stock/{symbol}/quote?token={token}" # noqa: E501

# TwelveData API Endpoint
TD_QUOTE_API_URL = "https://api.twelvedata.com/quote?symbol={symbol}&apikey={token}" # noqa: E501

Expand Down Expand Up @@ -335,10 +332,6 @@ def do_predictions(self):
for symbol in predicted_symbols:
try:
data = yield self.get_daily(symbol)

# this is not 100% accurate as to the value at open... it's
# just a value close to the open, iex cloud doesn't let us get
# at the true open without paying
actual = data['price']
except Exception:
self.logger.exception(
Expand Down Expand Up @@ -630,29 +623,5 @@ def make_td_request(self, symbol):
self.logger.error("{}, with data: {}".format(e, data))
raise

@defer.inlineCallbacks
def make_iex_request(self, symbol):
url = IEX_QUOTE_API_URL.format(
symbol=symbol,
token=self.config["api_key"],
)
r = yield deferToThread(requests.get, url)
data = r.json()

try:
price = float(data['latestPrice'])
previous_close = float(data['previousClose'])
change_percent = ((price - previous_close) / previous_close) * 100
return ({'symbol': data['symbol'],
'companyName': data['companyName'],
'exchange': data['primaryExchange'],
'price': price,
'previous close': previous_close,
'change': change_percent,
})
except KeyError as e:
self.logger.error("{}, with data: {}".format(e, data))
raise


entrypoint = TickerPlugin

0 comments on commit 439f7de

Please sign in to comment.