mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 15:06:53 +00:00
added comments for new features
This commit is contained in:
parent
7ad7d17e70
commit
aa31b0cfa7
@ -43,14 +43,16 @@ def news(bot, update):
|
||||
tickers = re.findall("[$](\w{1,4})", message)
|
||||
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
|
||||
|
||||
## Checks if a ticker was passed in
|
||||
if tickers == []:
|
||||
update.message.reply_text(
|
||||
"Please type a ticker after your command: /news $tsla"
|
||||
"Please type a ticker after your command with a dollar sign: /news $tsla"
|
||||
)
|
||||
else:
|
||||
tickerData = tickerInfo.tickerQuote(tickers)
|
||||
for ticker in tickers:
|
||||
ticker = ticker.upper()
|
||||
#Makes sure ticker exists
|
||||
if tickerData[ticker] == 1:
|
||||
name = tickerData[ticker + "Name"]
|
||||
price = tickerData[ticker + "Price"]
|
||||
@ -107,6 +109,7 @@ def stockInfo(bot, update):
|
||||
tickerData = tickerInfo.tickerQuote(tickers)
|
||||
for ticker in tickers:
|
||||
ticker = ticker.upper()
|
||||
#Makes sure ticker exists
|
||||
if tickerData[ticker] == 1:
|
||||
name = tickerData[ticker + "Name"]
|
||||
price = tickerData[ticker + "Price"]
|
||||
|
@ -3,6 +3,7 @@ import json
|
||||
|
||||
|
||||
def tickerQuote(tickers):
|
||||
"""Gathers information from IEX api on stock"""
|
||||
stockData = {}
|
||||
IEXURL = (
|
||||
"https://api.iextrading.com/1.0/stock/market/batch?symbols="
|
||||
@ -15,6 +16,8 @@ def tickerQuote(tickers):
|
||||
|
||||
for ticker in tickers:
|
||||
ticker = ticker.upper()
|
||||
|
||||
# Makes sure ticker exists before populating a dictionary
|
||||
if ticker in IEXData:
|
||||
stockData[ticker] = 1
|
||||
stockData[ticker + "Name"] = IEXData[ticker]["quote"]["companyName"]
|
||||
@ -31,6 +34,7 @@ def tickerQuote(tickers):
|
||||
|
||||
|
||||
def stockNewsList(ticker):
|
||||
"""Makes a bunch of strings that are links to news websites for an input ticker"""
|
||||
print("Gather News on " + ticker)
|
||||
news = {
|
||||
"Bravos": "https://bravos.co/" + ticker,
|
||||
@ -46,5 +50,6 @@ def stockNewsList(ticker):
|
||||
|
||||
|
||||
def stockLogo(ticker):
|
||||
"""returns a png of an input ticker"""
|
||||
logoURL = "https://g.foolcdn.com/art/companylogos/mark/" + ticker + ".png"
|
||||
return logoURL
|
||||
|
Loading…
x
Reference in New Issue
Block a user