A pair of AWS Lambda functions to send an SMS message with the price and percent change of Bitcoin, Dogecoin, Ethereum Classic, and Ethereum. This pro

Damian-Sanchez / CryptoTextAlert

submited by
Style Pass
2021-06-17 21:30:03

A pair of AWS Lambda functions to send an SMS message with the price and percent change of Bitcoin, Dogecoin, Ethereum Classic, and Ethereum. This program uses AWS Lambda, AWS DynamoDB, Coinlayer Price API, and Twilio. (all use the free tiers)

The real-time crypto prices are sourced from Coinlayer. I tested over half a dozen crypto price API providers and Coinlayer was overall the best experience because of its generous free tier, a large library of supported cryptocurrencies, and quality of developer documentation. Get free API key here. (Affiliate Link)

Unlike stocks, cryptocurrency markets are open 24/7 so there is no 'open' price to compare real-time prices to and calculate a percent change in price. The solution to this problem is to get the price at midnight and use that as the cryptocurrency's 'open' price. The few API providers that use this solution to provide 'open' prices charge for premium usage, so I decided to implement this myself by making a second Lambda function called open.py to get the cryptocurrency price at midnight and store that value in a DynamoDB table to be used later by the main Lambda function called message.py to calculate the price percent change.

Using AWS EventBridge Cron expressions, set the open.py function to run at midnight and the message.py function at anytime that you want to receive price notifications.

Leave a Comment
Related Posts