1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 15:17:28 +00:00

Finishing touches to /stat

This commit is contained in:
Anson 2020-10-10 21:35:11 -07:00
parent b3e628023b
commit 78b412ebff
2 changed files with 20 additions and 19 deletions

4
bot.py
View File

@ -156,7 +156,7 @@ def intra(update, context):
mpf.plot( mpf.plot(
df, df,
type="renko", type="renko",
title=f"\nIntraday chart for ${symbol.upper()} on {datetime.date.today().strftime('%d, %b %Y')}", title=f"\n${symbol.upper()}",
volume=True, volume=True,
style="yahoo", style="yahoo",
mav=20, mav=20,
@ -166,7 +166,7 @@ def intra(update, context):
update.message.reply_photo( update.message.reply_photo(
photo=buf, photo=buf,
caption=f"", caption=f"\nIntraday chart for ${symbol.upper()} on {datetime.date.today().strftime('%d, %b %Y')}",
parse_mode=telegram.ParseMode.MARKDOWN, parse_mode=telegram.ParseMode.MARKDOWN,
) )

View File

@ -78,15 +78,13 @@ Market data is provided by [IEX Cloud](https://iexcloud.io)
symbols = self.symbol_list symbols = self.symbol_list
symbols["Match"] = symbols.apply( symbols["Match"] = symbols.apply(
lambda x: fuzz.ratio(search, f"{x['symbol']}".lower()), lambda x: fuzz.ratio(search, f"{x['symbol']}".lower()), axis=1,
axis=1,
) )
symbols.sort_values(by="Match", ascending=False, inplace=True) symbols.sort_values(by="Match", ascending=False, inplace=True)
if symbols["Match"].head().sum() < 300: if symbols["Match"].head().sum() < 300:
symbols["Match"] = symbols.apply( symbols["Match"] = symbols.apply(
lambda x: fuzz.partial_ratio(search, x["name"].lower()), lambda x: fuzz.partial_ratio(search, x["name"].lower()), axis=1,
axis=1,
) )
symbols.sort_values(by="Match", ascending=False, inplace=True) symbols.sort_values(by="Match", ascending=False, inplace=True)
@ -238,23 +236,26 @@ Market data is provided by [IEX Cloud](https://iexcloud.io)
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()
infoMessages[ try:
symbol infoMessages[
] = f""" symbol
Company Name: {data['companyName']}\n ] = f"""
Market Cap: {data['marketcap']} Company Name: {data['companyName']}
52 Week (high-low):{data['week52high']}-{data['week52low']} Market Cap: {data['marketcap']:,}
Number of Employees: {data['employees']} 52 Week (high-low): {data['week52high']:,}-{data['week52low']:,}
Next Earnings Date: {data['nextEarningsDate']} Number of Employees: {data['employees']:,}
Dividend Info: Next Earnings Date: {data['nextEarningsDate']}
\tYield: {round(data['dividendYield'],4)*100}% Price to Earnings: {data['peRatio']}
\tNext Date: {data['nextDividendDate']} Beta: {data['beta']:.3f}
\tEx Date: {data['exDividendDate']}
""" """
except KeyError:
infoMessages[
symbol
] = f"Data for {data['companyName']} is not available. This could be due to them not announcing their earnings date."
else: else:
infoMessages[ infoMessages[
symbol symbol
] = f"No information found for: {symbol}\nEither today is boring or the symbol does not exist." ] = f"No information found for: {symbol}\nEither today is boring or the symbol does not exist."
return infoMessages return infoMessages