1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 15:17:28 +00:00
This commit is contained in:
Anson Biggs 2020-10-02 18:35:01 -07:00
commit b3e628023b

View File

@ -179,14 +179,16 @@ Market data is provided by [IEX Cloud](https://iexcloud.io)
newsMessages = {} newsMessages = {}
for symbol in symbols: 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) response = r.get(IEXurl)
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()
newsMessages[symbol] = f"News for **{symbol.upper()}**:\n" if len(data):
for news in data: newsMessages[symbol] = f"News for **{symbol.upper()}**:\n\n"
message = f"\t[{news['headline']}]({news['url']})\n\n" for news in data:
newsMessages[symbol] = newsMessages[symbol] + message if news["lang"] == "en" and not news["hasPaywall"]:
message = f"*{news['source']}*: [{news['headline']}]({news['url']})\n"
newsMessages[symbol] = newsMessages[symbol] + message
else: else:
newsMessages[ newsMessages[
symbol symbol