1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 07:16:40 +00:00

Updated news command #27

This commit is contained in:
Anson 2020-09-09 12:19:46 -07:00
parent e603c5345a
commit 7090da8fea

View File

@ -177,14 +177,16 @@ Market data is provided by [IEX Cloud](https://iexcloud.io)
newsMessages = {}
for symbol in symbols:
IEXurl = f"https://cloud.iexapis.com/stable/stock/{symbol}/news/last/3?token={self.IEX_TOKEN}"
IEXurl = f"https://cloud.iexapis.com/stable/stock/{symbol}/news/last/5?token={self.IEX_TOKEN}"
response = r.get(IEXurl)
if response.status_code == 200:
data = response.json()
newsMessages[symbol] = f"News for **{symbol.upper()}**:\n"
for news in data:
message = f"\t[{news['headline']}]({news['url']})\n\n"
newsMessages[symbol] = newsMessages[symbol] + message
if len(data):
newsMessages[symbol] = f"News for **{symbol.upper()}**:\n\n"
for news in data:
if news["lang"] == "en" and not news["hasPaywall"]:
message = f"*{news['source']}*: [{news['headline']}]({news['url']})\n"
newsMessages[symbol] = newsMessages[symbol] + message
else:
newsMessages[
symbol