A platform for monitoring and assessing various trading activities.
Daily reports triggered 15 minutes before the market opens using an AWS State Machine.
Portfolio data are stored in DynamoDB. The reports are saved as PDFs (for 7 days) and accessible via a link sent in an email (expires in 24 hours).
This Python project is meant to assist my option-trading endeavors using TD Ameritrade.
- Python 3.8 (due to limitations of TDA package and AWS Lambda)
- TD Ameritrade API key and account id: https://developer.tdameritrade.com
- Alphavantage API key: https://www.alphavantage.co/support/#api-key
- OpenAI API key: https://platform.openai.com/account/api-keys
- Serper API key: https://serper.dev/signup
- Finviz API token: https://elite.finviz.com/api_explanation.ashx
- Set up Telegram bot Set Up Telegram
- IAM_ACCESS_KEY_ID and IAM_SECRET_ACCESS_KEY
- GOOGLE_API_KEY and GOOGLE_CSE_ID
- Open Telegram: Start a chat with the BotFather, Telegram's bot for creating and managing bots.
- Create a New Bot: Send the
/newbot
command to BotFather. - Set Up Bot: Follow the prompts from BotFather to name your bot and set a username. The username must end in 'bot' (e.g.,
my_alert_bot
). - Get the Token: After creating the bot, BotFather will give you a token. This token is your bot's API key and is used to authenticate your requests.
- Start a Chat with Your Bot: Find your bot on Telegram (using the username you set) and start a chat.
- Find Your User ID: Use a service like the
userinfobot
on Telegram to find out your Telegram user ID.
- Save Alphavantage API key to .env as
ALPHAVANTAGE_API_KEY
for local usage. Save the key to AWS System Manager->Parameter Store asALPHAVANTAGE_API_KEY
for AWS Lambda usage. - Set Up Amazon Simple Email Service.
- Store from email in AWS System
Manager->Parameter as
FROM_EMAIL
. Store to emails in AWS System Manager->Parameter as a stringList namedTO_EMAILS
. Use commas to separate emails, no spaces. - Build and deploy using SAM, must specify Docker context
DOCKER_ENDPOINT
. Follow [these](https://github. com/aws/aws-sam-cli/issues/4329#issuecomment-1732670902) instructions to determine location of host.DOCKER_HOST=DOCKER_ENDPOINT sam build --use-container -t template.yaml DOCKER_HOST=DOCKER_ENDPOINT sam deploy --guided
- Test the API using body and supplying the API key in the header (generated by SAM):
{ "report_type": "stock_analysis", "send_email": true, "symbol": "MSFT" }