Skip to content

Commit 120d5df

Browse files
committed
start Stock trading alert SMS
1 parent 5b9f9ae commit 120d5df

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

StockTradingAlertSMS/main.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
from twilio.rest import Client
3+
import requests
4+
5+
STOCK = "TSLA"
6+
COMPANY_NAME = "Tesla Inc"
7+
account_sid = os.environ['TWILIO_ACCOUNT_SID']
8+
auth_token = os.environ['TWILIO_AUTH_TOKEN']
9+
news_api_key = os.environ['NEWSAPI_API_KEY']
10+
11+
12+
## STEP 1: Use https://www.alphavantage.co
13+
# When STOCK price increase/decreases by 5% between yesterday and the day before yesterday then print("Get News").
14+
15+
## STEP 2: Use https://newsapi.org
16+
# Instead of printing ("Get News"), actually get the first 3 news pieces for the COMPANY_NAME.
17+
news_response = requests.get(f"https://newsapi.org/v2/top-headlines?q=tesla&apiKey={news_api_key}")
18+
print(news_response.json())
19+
20+
## STEP 3: Use https://www.twilio.com
21+
# Send a seperate message with the percentage change and each article's title and description to your phone number.
22+
# client = Client(account_sid, auth_token)
23+
# message = client.messages.create(
24+
# from_='+',
25+
# body='Hi there',
26+
# to='+'
27+
# )
28+
# print(message.sid)
29+
30+
#Optional: Format the SMS message like this:
31+
"""
32+
TSLA: 🔺2%
33+
Headline: Were Hedge Funds Right About Piling Into Tesla Inc. (TSLA)?.
34+
Brief: We at Insider Monkey have gone over 821 13F filings that hedge funds and prominent investors are required to file by the SEC The 13F filings show the funds' and investors' portfolio positions as of March 31st, near the height of the coronavirus market crash.
35+
or
36+
"TSLA: 🔻5%
37+
Headline: Were Hedge Funds Right About Piling Into Tesla Inc. (TSLA)?.
38+
Brief: We at Insider Monkey have gone over 821 13F filings that hedge funds and prominent investors are required to file by the SEC The 13F filings show the funds' and investors' portfolio positions as of March 31st, near the height of the coronavirus market crash.
39+
"""
40+

0 commit comments

Comments
 (0)