mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 07:16:40 +00:00
#1 /close Percentage change of ticker now outputs
This commit is contained in:
parent
69e5342f74
commit
e14939c7c1
36
stockBot.py
36
stockBot.py
@ -50,24 +50,24 @@ def stockInfo(bot, update):
|
|||||||
|
|
||||||
message = 'The current stock price of ' + \
|
message = 'The current stock price of ' + \
|
||||||
name + ' is $**' + str(price) + '**'
|
name + ' is $**' + str(price) + '**'
|
||||||
# if change > 0:
|
if change > 0:
|
||||||
# newsMessage = newsMessage + ', the stock is currently **up' + change + '%**'
|
message = message + \
|
||||||
# elif change < 0:
|
', the stock is currently **up ' + str(change) + '%**'
|
||||||
# newsMessage = newsMessage + ', the stock is currently **down' + change + '%**'
|
elif change < 0:
|
||||||
# else:
|
message = message + \
|
||||||
# newsMessage = newsMessage + ", the stock hasn't shown any movement today."
|
', the stock is currently **down' + str(change) + '%**'
|
||||||
|
else:
|
||||||
|
message = message + ", the stock hasn't shown any movement today."
|
||||||
|
|
||||||
news = tickerInfo.stockNewsList(ticker)
|
news = tickerInfo.stockNewsList(ticker)
|
||||||
print(news)
|
|
||||||
for source in news:
|
for source in news:
|
||||||
print(source)
|
|
||||||
message = message + \
|
message = message + \
|
||||||
'\n[' + source + '](' + news[source] + ')'
|
'\n[' + source + '](' + news[source] + ')'
|
||||||
|
|
||||||
update.message.reply_text(
|
update.message.reply_text(
|
||||||
text=message, parse_mode=telegram.ParseMode.MARKDOWN)
|
text=message, parse_mode=telegram.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
else: # If news embed isnt called, print normal stock price
|
else: # If news isnt called, print normal stock price
|
||||||
tickerData = tickerInfo.tickerQuote(tickers)
|
tickerData = tickerInfo.tickerQuote(tickers)
|
||||||
for ticker in tickers:
|
for ticker in tickers:
|
||||||
ticker = ticker.upper()
|
ticker = ticker.upper()
|
||||||
@ -76,16 +76,16 @@ def stockInfo(bot, update):
|
|||||||
change = tickerData[ticker + 'Change']
|
change = tickerData[ticker + 'Change']
|
||||||
message = 'The current stock price of ' + \
|
message = 'The current stock price of ' + \
|
||||||
name + ' is $**' + str(price) + '**'
|
name + ' is $**' + str(price) + '**'
|
||||||
# change = 0
|
if change > 0:
|
||||||
|
message = message + ', the stock is currently **up ' + \
|
||||||
# if change > 0:
|
str(change) + '%**'
|
||||||
# move = ', the stock is currently **up' + change + '%**'
|
elif change < 0:
|
||||||
# elif change < 0:
|
message = message + ', the stock is currently **down ' + \
|
||||||
# move = ', the stock is currently **down' + change + '%**'
|
str(change) + '%**'
|
||||||
# else:
|
else:
|
||||||
move = ", the stock hasn't shown any movement today."
|
move = ", the stock hasn't shown any movement today."
|
||||||
update.message.reply_text(
|
update.message.reply_text(
|
||||||
text=message + move, parse_mode=telegram.ParseMode.MARKDOWN)
|
text=message, parse_mode=telegram.ParseMode.MARKDOWN)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user