Stay up to date with latest cryptocurrency prices!Creating the Price CheckerStep 1: Setting up your code
All of the necessary files you will need are in the zip file located on the main page of my GitHub which can be found at the link below or here! Everything that is zipped in that file can be found in the folder labeled "crypto."
Download the zip file, and open up the Python file named "crypto.py" Here you can see I have a laid out a file with three cryptocurrencies, Bitcoin, Ethereum, and Litecoin. You can change these to whatever cryptocurrencies you'd like; however, they have to be on the CoinMarketCap page since I'm leveraging their API. To add an additional cryptocurrency, or change an existing one, you will have to specify the ticker name. So if you want text alerts on the coin Dash, you have to change the argument to the ticker method to say "Dash".
The only thing you MUST change is the phone number variable defined below.
This has to be changed to your 11 digit number (<country_code><area_code><number>). When you are finished editing the code to your liking, save it, and zip together all of the files that you just downloaded, excluding the zip file itself.
Sign into the AWS console, and select IAM from the security, identity, and compliance section. Select Roles from the left hand side, and select Create New Role. For the service role type, select AWS Lambda. Select AmazonSNSFullAccess and select AWSLambdaBasicExecutionRole from the list of provided policies. Name the role as you please, and hit create. In my example, I named it "crypto_role."
After creating your role, it's time to move to the function. Select Lambda from the Compute services on the Dashboard. Select "Create a Lambda function" from the main menu, and then select "blank function". You should be at a screen where you can configure your trigger.
Click on the empty box pointing to the Lambda logo, and select CloudWatch Event. We now want to create a new CloudWatch rule that will trigger our code at scheduled times. Select "Create new Rule" and name your rule as your please. For this example, I named it "CryptoTrigger." Now, decide how often you want a text message containing the prices of different cryptocurrencies. I want around 4 text messages a day, so I specified "rate(6 hours)" to specify every 6 hours. You can mess around with this parameter by using different rates or using specified Cron times. Select enable trigger and then hit next.
Name your lambda function as you please, and add a description. Select "Python 3.6" as the run time, and select "Upload a Zip file" as your code entry type. Important: Name the handler "<Python_file>.lambda_handler". So if you did not change the file name, it would be "crypto.lambda_handler." Under Role, select the name of the role you created earlier.
Open up advanced settings, and find where it says Timeout. Bump this up to 7 seconds just in case it takes a few seconds to fetch data from the API. Click next, and select Create Function.
Now that we have created our function, let's see if it works. Open up the function, and click test. It will ask you to configure a test event, but just go ahead and use the default one for now. Select Test. You should have an output like this in your Lambda Console, and if all went well, you should have a text message on your mobile device!