This commit is contained in:
Sebastien Trudel 2020-12-23 09:23:32 -05:00
parent 8aab42baac
commit fd6bf64942
2 changed files with 59 additions and 3 deletions

View File

@ -4,11 +4,67 @@
import yfinance as yf
import smtplib, ssl, sys, os, configparser
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
#print(os.environ['your_env_variable'])
#sys.path.append(os.path.abspath("c:/users/seb"))
#import pythonmodule.Module1.testenv
config = configparser.ConfigParser()
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
emailp = config.get("config","test")
#Yfinance tests
#https://pypi.org/project/yfinance/
data2 = yf.download(" CRSR VTI VOO DIS", period="1d")
print(data2.tail())
data2 = yf.download("CRSR VTI VOO DIS", period="1d")
print(data2.tail(1))
data2.head()
Body_of_Email = """\
Subject: Daily Stock Report
Daily stock report:
""" + data2.to_html() + """\
Sincerely,
Your Computer"""
msg = MIMEMultipart()
msg["Subject"] = "Daily Stock report"
msg["From"] = "strudel@pirolian.com"
html = """\
<html>
<head></head>
<body>
{0}
</body>
</html>
""".format(data2.to_html())
part1 = MIMEText(html, "html")
msg.attach(part1)
server = smtplib.SMTP("smtppro.zoho.com", 465)
server.sendmail(msg["From"], emaillist , msg.as_string())
context = ssl.create_default_context()
Email_Port = 465 # If you are not using a gmail account, you will need to look up the port for your specific email host
with smtplib.SMTP_SSL("smtppro.zoho.com", Email_Port, context=context) as server:
server.login("strudel@pirolian.com", emailp) # This statement is of the form: server.login(<Your email>, "Your email password")
server.sendmail("strudel@pirolian.com", "sebastien.trudel@pirolian.com", Body_of_Email) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)

View File

@ -4,7 +4,7 @@
Stock data manipulation with Python test.
# Project 1:
## Get data at the end of the day for a list of stocks and send email at end of day with prices, maybe other info.
# Get data at the end of the day for a list of stocks and send email at end of day with prices, maybe other info.
* Get data for stocks
* Send by email