mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 07:16:40 +00:00
Finishing touches to /stat
This commit is contained in:
parent
b3e628023b
commit
78b412ebff
4
bot.py
4
bot.py
@ -156,7 +156,7 @@ def intra(update, context):
|
||||
mpf.plot(
|
||||
df,
|
||||
type="renko",
|
||||
title=f"\nIntraday chart for ${symbol.upper()} on {datetime.date.today().strftime('%d, %b %Y')}",
|
||||
title=f"\n${symbol.upper()}",
|
||||
volume=True,
|
||||
style="yahoo",
|
||||
mav=20,
|
||||
@ -166,7 +166,7 @@ def intra(update, context):
|
||||
|
||||
update.message.reply_photo(
|
||||
photo=buf,
|
||||
caption=f"",
|
||||
caption=f"\nIntraday chart for ${symbol.upper()} on {datetime.date.today().strftime('%d, %b %Y')}",
|
||||
parse_mode=telegram.ParseMode.MARKDOWN,
|
||||
)
|
||||
|
||||
|
35
functions.py
35
functions.py
@ -78,15 +78,13 @@ Market data is provided by [IEX Cloud](https://iexcloud.io)
|
||||
|
||||
symbols = self.symbol_list
|
||||
symbols["Match"] = symbols.apply(
|
||||
lambda x: fuzz.ratio(search, f"{x['symbol']}".lower()),
|
||||
axis=1,
|
||||
lambda x: fuzz.ratio(search, f"{x['symbol']}".lower()), axis=1,
|
||||
)
|
||||
|
||||
symbols.sort_values(by="Match", ascending=False, inplace=True)
|
||||
if symbols["Match"].head().sum() < 300:
|
||||
symbols["Match"] = symbols.apply(
|
||||
lambda x: fuzz.partial_ratio(search, x["name"].lower()),
|
||||
axis=1,
|
||||
lambda x: fuzz.partial_ratio(search, x["name"].lower()), axis=1,
|
||||
)
|
||||
|
||||
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:
|
||||
data = response.json()
|
||||
infoMessages[
|
||||
symbol
|
||||
] = f"""
|
||||
Company Name: {data['companyName']}\n
|
||||
Market Cap: {data['marketcap']}
|
||||
52 Week (high-low):{data['week52high']}-{data['week52low']}
|
||||
Number of Employees: {data['employees']}
|
||||
Next Earnings Date: {data['nextEarningsDate']}
|
||||
Dividend Info:
|
||||
\tYield: {round(data['dividendYield'],4)*100}%
|
||||
\tNext Date: {data['nextDividendDate']}
|
||||
\tEx Date: {data['exDividendDate']}
|
||||
try:
|
||||
infoMessages[
|
||||
symbol
|
||||
] = f"""
|
||||
Company Name: {data['companyName']}
|
||||
Market Cap: {data['marketcap']:,}
|
||||
52 Week (high-low): {data['week52high']:,}-{data['week52low']:,}
|
||||
Number of Employees: {data['employees']:,}
|
||||
Next Earnings Date: {data['nextEarningsDate']}
|
||||
Price to Earnings: {data['peRatio']}
|
||||
Beta: {data['beta']:.3f}
|
||||
"""
|
||||
except KeyError:
|
||||
infoMessages[
|
||||
symbol
|
||||
] = f"Data for {data['companyName']} is not available. This could be due to them not announcing their earnings date."
|
||||
|
||||
else:
|
||||
infoMessages[
|
||||
symbol
|
||||
] = f"No information found for: {symbol}\nEither today is boring or the symbol does not exist."
|
||||
|
||||
return infoMessages
|
||||
return infoMessages
|
||||
|
Loading…
x
Reference in New Issue
Block a user