Building an AWS Trading System - Basic Lambda Function Operations (Part 7) (Python Tutorial)
Title image created with Cacoo.com
This post is part of a series of tutorials with the subject of building a scalable algorithmic trading system on the Amazon Web Services (AWS) cloud platform. Bear with me, as I’m learning AWS myself.
The advantage of using AWS is that it offers dozens of powerful, integrated software services that can be used to build a scalable, high-performance, low-cost production trading system.
In this post we are going to over basic operations on how to use the AWS Labmda functions, how to create a function, use it to download price data and store it in a bucket.
This story is solely for general information purposes, and should not be relied upon for trading recommendations or financial advice. Source code and information is provided for educational purposes only, and should not be relied upon to make an investment decision. Please review my full cautionary guidance before continuing.
Previous Tutorials
The following posts are suggested reading for this post to get you started:
Building an AWS Trading System - Registration & Environment Setup (Part 2)
Building an AWS Trading System - Basic EC2 Operations (Part 3)
Building an AWS Trading System - Basic S3 Operations (Part 4)
Building an AWS Trading System - Basic Aurora RDS Operations (Part 5)
Building an AWS Trading System - Basic DynamoDB Operations (Part 6)
Trade Ideas provides AI stock suggestions, AI alerts, scanning, automated trading, real-time stock market data, charting, educational resources, and more. Get a 15% discount with promo code ‘BOTRADING15’.
What is AWS Lambda?
In programming, a Lambda function is a small, inline piece of code used to perform a task with a very limited scope.
Similarly, Lambda is a AWS service that let’s you run functionality with a specific purpose, like a script or web service on the AWS computing platform.
The advantage of Lambda functions is that this service provides a scalable, available hardware architecture without having to explicitly provisioning and managing computing hardware.
The Lambda service supports a number of programming languages such as JavaScript, Python, Go, C# or Java.
The Lambda service is an essential tool for integrating AWS services. It can be triggered from AWS, perform the desired tasks and then initiate tasks on other AWS services.
In the context of building an automated trading system, the Lambda service can be used for a multitude of tasks, such as:
Price file imports to S3 or a database
News data imports to S3 or a database
News or financial information web scraping tasks
Data processing, transformation and consolidation tasks
System integration tasks between AWS services
Running trading bots
Building a web service backend for a web trading system, and many more.
What is Boto3?
AWS functionality can be accessed in different ways, e.g. AWS Console, AWS Command-line Interface (CLI), or different SDKs. In this series of tutorials we will be using the Boto3 library to interact with the different AWS services.
Boto3 is a Python SDK provided by Amazon to interface with services such as EC2, S3, Amazon Athena, etc.
Read more about Boto3 here.
Here the Boto3 AWS API documentation.
Here the Boto3 API documentation for Lambda.
Here a list of Lambda Boto3 examples.
Tutorial Overview
Here the tasks we are going to perform in this tutorial:
Create a Lambda Execution Role
Create a S3 bucket
Create a lambda function
Wait until the lambda function state is ‘Active’
Get the lambda function configuration
List all lambda functions
Invoke the lambda function
The function downloads Ethereum prices using the CoinAPI and stores them in the S3 bucket
Delete the lambda function
Delete the S3 bucket content
Delete the S3 bucket.