-
Notifications
You must be signed in to change notification settings - Fork 0
/
volumeTrackerEmailNotif.py
59 lines (38 loc) · 1.19 KB
/
volumeTrackerEmailNotif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import yfinance as fy
import pandas as pd
import smtplib
import time
sender_email = "redacted"
rec_email = "redacted"
password = "redacted"
message = ""
m = ""
df = pd.read_csv('/Users/juliustranquilli/desktop/companylist.csv')
print(df['Symbol'])
upSymbols = []
for stock in df['Symbol']:
stock = stock.upper()
if '^' in stock: #ignoring formatting problems in the .csv file
pass
else:
try:
time.sleep(0.25)
stock_info = fy.Ticker(stock)
history = stock_info.history(period="5d")
prevAverageVol = history['Volume'].iloc[1:4:1].mean()
#third value in iloc call is just increment of 1
today_vol = history['Volume'][-1]
if (today_vol > prevAverageVol * 3) :
upSymbols.append(stock)
except:
pass
for i in range(len(upSymbols)):
message += upSymbols[i]
message += " , "
print(upSymbols)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, password)
print("Login success")
server.sendmail(sender_email, rec_email, message)
print("Email has been sent to", rec_email)