1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-22 22:21:33 +00:00

Switched to black formatter

This commit is contained in:
2019-02-02 01:52:34 +00:00
parent b7663ae097
commit 027d45b6f2
2 changed files with 65 additions and 51 deletions

View File

@@ -4,39 +4,40 @@ import json
def tickerQuote(tickers):
stockData = {}
IEXURL = 'https://api.iextrading.com/1.0/stock/market/batch?symbols=' + \
",".join(tickers) + '&types=quote'
print('Gathering Quote from ' + IEXURL)
IEXURL = (
"https://api.iextrading.com/1.0/stock/market/batch?symbols="
+ ",".join(tickers)
+ "&types=quote"
)
print("Gathering Quote from " + IEXURL)
with urllib.request.urlopen(IEXURL) as url:
IEXData = json.loads(url.read().decode())
for ticker in tickers:
ticker = ticker.upper()
stockData[ticker + 'Name'] = IEXData[ticker]['quote']['companyName']
stockData[ticker + 'Price'] = \
IEXData[ticker]['quote']['latestPrice']
stockData[ticker +
'Change'] = IEXData[ticker]['quote']['changePercent'] * 100
stockData[ticker + 'Image'] = stockLogo(ticker)
print('Quote Gathered')
stockData[ticker + "Name"] = IEXData[ticker]["quote"]["companyName"]
stockData[ticker + "Price"] = IEXData[ticker]["quote"]["latestPrice"]
stockData[ticker + "Change"] = IEXData[ticker]["quote"]["changePercent"] * 100
stockData[ticker + "Image"] = stockLogo(ticker)
print("Quote Gathered")
return stockData
def stockNewsList(ticker):
print('Gather News on ' + ticker)
print("Gather News on " + ticker)
news = {
'Bravos': 'https://bravos.co/' + ticker,
'Seeking Alpha': 'https://seekingalpha.com/symbol/' + ticker,
'MSN Money': 'https://www.msn.com/en-us/money/stockdetails?symbol=' + ticker,
'Yahoo Finance': 'https://finance.yahoo.com/quote/' + ticker,
'Wall Street Journal': 'https://quotes.wsj.com/' + ticker,
'The Street': 'https://www.thestreet.com/quote/' + ticker + '.html',
'Zacks': 'https://www.zacks.com/stock/quote/' + ticker
"Bravos": "https://bravos.co/" + ticker,
"Seeking Alpha": "https://seekingalpha.com/symbol/" + ticker,
"MSN Money": "https://www.msn.com/en-us/money/stockdetails?symbol=" + ticker,
"Yahoo Finance": "https://finance.yahoo.com/quote/" + ticker,
"Wall Street Journal": "https://quotes.wsj.com/" + ticker,
"The Street": "https://www.thestreet.com/quote/" + ticker + ".html",
"Zacks": "https://www.zacks.com/stock/quote/" + ticker,
}
print('News gathered.')
print("News gathered.")
return news
def stockLogo(ticker):
logoURL = 'https://g.foolcdn.com/art/companylogos/mark/' + ticker + '.png'
logoURL = "https://g.foolcdn.com/art/companylogos/mark/" + ticker + ".png"
return logoURL