mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 15:06:53 +00:00
Merge branch 'master' of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot into master
This commit is contained in:
commit
b3e628023b
12
functions.py
12
functions.py
@ -179,14 +179,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user