From aa31b0cfa73ba05256e21d03c28ebc7eab7ce575 Mon Sep 17 00:00:00 2001 From: Anson Date: Mon, 4 Feb 2019 14:42:06 -0700 Subject: [PATCH] added comments for new features --- stockBot.py | 5 ++++- tickerInfo.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/stockBot.py b/stockBot.py index f84ce4b..16363d1 100644 --- a/stockBot.py +++ b/stockBot.py @@ -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"] diff --git a/tickerInfo.py b/tickerInfo.py index c53143b..5eb9659 100644 --- a/tickerInfo.py +++ b/tickerInfo.py @@ -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