diff --git a/GetDaily.py b/GetDaily.py index 71ea928..fc9d9e3 100644 --- a/GetDaily.py +++ b/GetDaily.py @@ -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 = """\ + + + + {0} + + +""".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 password") + server.sendmail("strudel@pirolian.com", "sebastien.trudel@pirolian.com", Body_of_Email) # This statement is of the form: server.sendmail(, , Body_of_Email) + + + diff --git a/README.md b/README.md index 4a36216..3200ca3 100644 --- a/README.md +++ b/README.md @@ -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