Email notification
I finally bit the bullet and updated my previously hideous email notification!
You may find the updated email notification template here - alongside with the code.
Feel free to ping me if you are keen to be on the email list too.
~ Jirong
import smtplib, ssl
import datetime
import pandas as pd
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
#Format text
data = pd.read_csv('/home/jirong/Desktop/github/ETF_watchlist/Output/yahoo_crawled_data.csv')
data['Change_fr_52_week_high'] = round(100 * data['Change_fr_52_week_high'], 1)
data = data[['Name', 'Price', 'Change_fr_52_week_high']].head(20)
data.rename(columns={'Change_fr_52_week_high':'Change from 52 week high (%)'}, inplace=True)
results = data.to_html()
message = MIMEMultipart("alternative")
message["Subject"] = "ETF Watchlist"
message["From"] = "jironghuang88@gmail.com"
message["Bcc"] = ""
# Create the plain-text and HTML version of your message
html = """\
<html>
<head></head>
<body>
<p>Hey there!
<br><br>
<br>Pls click <a href="https://jironghuang.github.io/project/watch_list/">here</a> for a complete updated ETF watchlist.<br>
<br>For your convenience, I've also appended the top 20 tickers with greatest fall over last 52 week high (potentially cheap but you should triangulate with other sources)<br>
{0}
<br>This is part of my daily automated ETF dashboard + Email notification (weekly for email notification) and I thought you may be interested in it.<br>
<br>Do also check out my 'What is Low - Regression Approach' <a href="https://jironghuang.github.io/project/what-is-low-regression-approach/">here</a> to understand which are the markets that are under or overvalued.<br>
<br>If this irritates you too much, let me know and I can take you out of this mailing list:)<br>
<br>Regards,<br>
<br><br>
Jirong
</p>
</body>
</html>
""".format(data.to_html())
# Turn these into plain/html MIMEText objects
#part1 = MIMEText(text, "plain")
part2 = MIMEText(html, "html")
#part3 = MIMEText(results, "html")
# Add HTML/plain-text parts to MIMEMultipart message
# The email client will try to render the last part first
message.attach(part2)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("jironghuang88@gmail.com", "")
recipients = ["jironghuang88@gmail.com"]
server.sendmail("jironghuang88@gmail.com", recipients, message.as_string())