adding missing files
This commit is contained in:
parent
5c2ec0a069
commit
f0f78a4ed0
24
GetDaily.py
24
GetDaily.py
|
|
@ -12,7 +12,7 @@ from smtplib import SMTP
|
||||||
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
config.read("/home/sebadmin/scripts/Stocks/testenv.txt")
|
||||||
emailp = config.get("config","test")
|
emailp = config.get("config","test")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,34 +21,46 @@ emailp = config.get("config","test")
|
||||||
#https://pypi.org/project/yfinance/
|
#https://pypi.org/project/yfinance/
|
||||||
|
|
||||||
|
|
||||||
data2 = yf.download("CRSR VTI VOO DIS UI TSLA TTWO VFV GME", period="1d")
|
data2 = yf.download("CRSR VTI VOO DIS UI TSLA TTWO GME INTC", period="1d")
|
||||||
#print(data2.tail(1))
|
#print(data2.tail(1))
|
||||||
#data2.head()
|
#data2.head()
|
||||||
Dayclose = data2["Close"].round(decimals=2)
|
Dayclose = data2["Close"].round(decimals=2)
|
||||||
|
Dayopen = data2["Open"].round(decimals=2)
|
||||||
|
|
||||||
|
|
||||||
recipients = ["sebastien.trudel@pirolian.com"]
|
recipients = ["sebastien.trudel@pirolian.com"]
|
||||||
emaillist = [elem.strip().split(',') for elem in recipients]
|
emaillist = [elem.strip().split(',') for elem in recipients]
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg["Subject"] = "Daily Stock report"
|
msg["Subject"] = "Daily Stock report"
|
||||||
msg["From"] = "strudel@pirolian.com"
|
msg["From"] = "trudel.sebastien@gmail.com"
|
||||||
|
|
||||||
|
|
||||||
html = """\
|
html = """\
|
||||||
<html>
|
<html>
|
||||||
<head></head>
|
<head>Close</head>
|
||||||
<body>
|
<body>
|
||||||
{0}
|
{0}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
""".format(Dayclose.to_html())
|
""".format(Dayclose.to_html())
|
||||||
|
|
||||||
|
html2 = """\
|
||||||
|
<html>
|
||||||
|
<head>Open</head>
|
||||||
|
<body>
|
||||||
|
{0}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""".format(Dayopen.to_html())
|
||||||
|
|
||||||
part1 = MIMEText(html, "html")
|
part1 = MIMEText(html, "html")
|
||||||
|
part2 = MIMEText(html2, "html")
|
||||||
msg.attach(part1)
|
msg.attach(part1)
|
||||||
|
|
||||||
context = ssl.create_default_context()
|
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
|
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:
|
with smtplib.SMTP_SSL("smtp.gmail.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.login("trudel.sebastien@gmail.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)
|
# 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)
|
||||||
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
#Get stock symbols in a file
|
||||||
|
#Get daily quote at end of day
|
||||||
|
#Send email
|
||||||
|
|
||||||
|
|
||||||
|
#Using yfinance from https://pypi.org/project/yfinance/
|
||||||
|
import yfinance as yf
|
||||||
|
import smtplib, ssl, sys, os, configparser
|
||||||
|
import sqlite3
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
from email.mime.application import MIMEApplication
|
||||||
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
from smtplib import SMTP
|
||||||
|
|
||||||
|
#Username/Password for email service, change location of the file
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
||||||
|
emailp = config.get("config","test")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Yfinance tests
|
||||||
|
#https://pypi.org/project/yfinance/
|
||||||
|
|
||||||
|
|
||||||
|
#Change these values for the desired tickers
|
||||||
|
data2 = yf.download("CRSR VTI VOO DIS UI TSLA TTWO GME", period="1d")
|
||||||
|
#Setup date format
|
||||||
|
Dayclose = data2["Close"].round(decimals=2)
|
||||||
|
|
||||||
|
#Email variables for multiple recipients use coma
|
||||||
|
recipients = ["sebastien.trudel@pirolian.com"]
|
||||||
|
emaillist = [elem.strip().split(',') for elem in recipients]
|
||||||
|
msg = MIMEMultipart()
|
||||||
|
msg["Subject"] = "Daily Stock report"
|
||||||
|
msg["From"] = "strudel@pirolian.com"
|
||||||
|
|
||||||
|
|
||||||
|
#Email format as HTML, using a table
|
||||||
|
html = """\
|
||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
<body>
|
||||||
|
{0}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""".format(Dayclose.to_html())
|
||||||
|
|
||||||
|
part1 = MIMEText(html, "html")
|
||||||
|
msg.attach(part1)
|
||||||
|
|
||||||
|
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)
|
||||||
|
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||||
|
|
||||||
|
|
||||||
|
#Put data in a sqlite database
|
||||||
|
#DB is dbstocks.sqlite, table is dailystocks, fields are date as text, ticker as text, test as text and price as int
|
||||||
|
try:
|
||||||
|
sqliteConnection = sqlite3.connect('dbstocks.sqlite')
|
||||||
|
cursor = sqliteConnection.cursor()
|
||||||
|
print("Successfully Connected to SQLite")
|
||||||
|
|
||||||
|
except sqlite3.Error as error:
|
||||||
|
print("Error while executing sqlite script", error)
|
||||||
|
|
||||||
|
cursor.execute('INSERT INTO dailystocks (date, ticker, price) VALUES(
|
||||||
|
|
||||||
|
#cursor.execute('SELECT * from dailystocks')
|
||||||
|
|
||||||
|
#rows = cursor.fetchall()
|
||||||
|
|
||||||
|
#for row in rows:
|
||||||
|
# print(row)
|
||||||
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#Get stock symbols in a file
|
#Get stock symbols in a file
|
||||||
#Get daily quote at end of day
|
#Get daily quote at end of day
|
||||||
#Send email, see Jupyter thing on other laptop for sending email
|
#Send email
|
||||||
|
|
||||||
|
|
||||||
|
#Using yfinance from https://pypi.org/project/yfinance/
|
||||||
import yfinance as yf
|
import yfinance as yf
|
||||||
import smtplib, ssl, sys, os, configparser
|
import smtplib, ssl, sys, os, configparser
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
@ -11,7 +12,7 @@ from email.mime.application import MIMEApplication
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
|
|
||||||
|
#Username/Password for email service, change location of the file
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
||||||
emailp = config.get("config","test")
|
emailp = config.get("config","test")
|
||||||
|
|
@ -22,11 +23,12 @@ emailp = config.get("config","test")
|
||||||
#https://pypi.org/project/yfinance/
|
#https://pypi.org/project/yfinance/
|
||||||
|
|
||||||
|
|
||||||
data2 = yf.download("CRSR VTI VOO DIS UI TSLA TTWO VFV GME", period="1d")
|
#Change these values for the desired tickers
|
||||||
#print(data2.tail(1))
|
data2 = yf.download("CRSR VTI VOO DIS UI TSLA TTWO GME", period="1d")
|
||||||
#data2.head()
|
#Setup date format
|
||||||
Dayclose = data2["Close"].round(decimals=2)
|
Dayclose = data2["Close"].round(decimals=2)
|
||||||
|
|
||||||
|
#Email variables for multiple recipients use coma
|
||||||
recipients = ["sebastien.trudel@pirolian.com"]
|
recipients = ["sebastien.trudel@pirolian.com"]
|
||||||
emaillist = [elem.strip().split(',') for elem in recipients]
|
emaillist = [elem.strip().split(',') for elem in recipients]
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
|
@ -34,6 +36,7 @@ msg["Subject"] = "Daily Stock report"
|
||||||
msg["From"] = "strudel@pirolian.com"
|
msg["From"] = "strudel@pirolian.com"
|
||||||
|
|
||||||
|
|
||||||
|
#Email format as HTML, using a table
|
||||||
html = """\
|
html = """\
|
||||||
<html>
|
<html>
|
||||||
<head></head>
|
<head></head>
|
||||||
|
|
@ -54,7 +57,8 @@ with smtplib.SMTP_SSL("smtppro.zoho.com", Email_Port, context=context) as server
|
||||||
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||||
|
|
||||||
|
|
||||||
|
#Put data in a sqlite database
|
||||||
|
#DB is dbstocks.sqlite, table is dailystocks, fields are date as text, ticker as text, test as text and price as int
|
||||||
try:
|
try:
|
||||||
sqliteConnection = sqlite3.connect('dbstocks.sqlite')
|
sqliteConnection = sqlite3.connect('dbstocks.sqlite')
|
||||||
cursor = sqliteConnection.cursor()
|
cursor = sqliteConnection.cursor()
|
||||||
|
|
@ -63,6 +67,8 @@ try:
|
||||||
except sqlite3.Error as error:
|
except sqlite3.Error as error:
|
||||||
print("Error while executing sqlite script", error)
|
print("Error while executing sqlite script", error)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#cursor.execute('SELECT * from dailystocks')
|
#cursor.execute('SELECT * from dailystocks')
|
||||||
|
|
||||||
#rows = cursor.fetchall()
|
#rows = cursor.fetchall()
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,28 @@
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
try:
|
||||||
|
sqliteConnection = sqlite3.connect('dbstocks.sqlite')
|
||||||
|
cursor = sqliteConnection.cursor()
|
||||||
|
print("Successfully Connected to SQLite")
|
||||||
|
|
||||||
|
except sqlite3.Error as error:
|
||||||
|
print("Error while executing sqlite script", error)
|
||||||
|
|
||||||
|
cursor.execute('SELECT * from dailystocks')
|
||||||
|
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#conn = sqlite3.connect('stocks_db.sqlite')
|
||||||
|
|
||||||
|
#cur = conn.cursor()
|
||||||
|
#selecttest = 'SELECT * from dailystocks'
|
||||||
|
#cur.execute('SELECT * from dailystocks')
|
||||||
|
#cur.execute('CREATE TABLE experiments (name VARCHAR, description VARCHAR)')
|
||||||
|
#conn.commit()
|
||||||
|
|
||||||
|
#conn.close()
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
||||||
|
[config]
|
||||||
|
test = adqnrpvyzqrwmcje
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
[config]
|
||||||
|
test = YfJ83hUDUA8X
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
[config]
|
||||||
|
mp = BJDFn1L5gVIKhWw1BUpGwwIhlvmzWu2TDFc6VN5B5gtQ
|
||||||
Loading…
Reference in New Issue