Serverless Automation

About Me:

  • Techie | Author | Trainer | Mentor | Startups
  • Working as Engineering Lead at Unacademy
  • Authored internationally published book "Building Chatbots with Python", translated in Portuguese, Korean.
  • Avid Quora writer - Over a million views so far.
  • Guest speaker and hackathon lover.

Contents

1. Introduction to Lambda and its advantages over EC2
2. How to install packages in Lambda
3. Using Chartink + Lambda for Strategy Automation
4. Creating an API
5. Creating Cronjobs in Lambda

Problem

  • Not being able to take quick action
  • Emotions play
  • Strategies needs more time
  • Seamless execution
  • Cost and Productivity

Challenge

  • I know the strategy
  • I have manually backtested it or got it backtested.
  • I can write the pseudo code, may be using Chartink or TradingView using an interface
  • But I don't know how to automate or I can't sit all day in front of the system

Serverless Solution

Cost Perspective

  • 1M free requests per month and 400,000 GB-seconds of compute time per month for AWS Lambda
Price
Requests $0.20 per 1M requests
Duration $0.0000166667 for every GB-second

AWS Lambda

Average trading days: 21 * 6 hour/day = 126 hours
Average runtime: 800 ms ~1sec
126 hours= 126*3600 = 4,53,600 seconds

(126*3600*128)/1024 = 56,700 GB-seconds

 

56,700 GB-s - 400000 free tier GB-s = -343,300.00 GB-s

 

Lambda costs - With Free Tier (monthly): 0.00 USD

Let's do the maths

Number of Requests (per month) Price (per million)
First 300 million $1.00
300+ million $0.90
  • Amazon API Gateway free tier includes one million API calls per month for up to 12 months.
  • 5GB Data (ingestion, archive storage, and data scanned by Logs Insights queries)
  • $1.00 per million events

Productivity and Maintenance

Perspective

  • Setup cronjob with click of a button
  • Logging is a piece of cake
  • Search logs for history of your executions
  • Stopping execution using Throttle
  • Setup once and use forever

Why choose Serverless Lambda over EC2?

  • Highly reduced operational cost
  • Less complex to manage compared to VMs
  • Faster development time and productivity
  • Near zero maintenance

Running Code in Lambda

How to install packages in Lambda?
 

  • Layers let you keep your deployment package small, which makes development easier.
  • You can avoid errors that can occur when you install and package dependencies with your function code.

Layers

Creating webhook endpoint using API Gateway

  • Integrating API to Lambda
  • Receiving webhook request and processing in lambda
  • Calling API to place order in lambda

Running Cronjobs

Cron Expression Rules

Rate Expressions

A rate expression starts when you create the scheduled event rule, and then runs on its defined schedule.

Thank You.

Serverless Automation

By sumit12dec

Serverless Automation

  • 270