A serverless project that follows a stock trading algorithm and uses scheduled functions to save data to DynamoDB and send emails through Mailgun.

View on Github



This project calculates Bittman trading algorithm trading points on Wednesday evenings, and then uses them to calculate the actual triggers based on the morning open price on Thursday.


This project implements the algorithm using the Serverless framework and sends emails through Mailgun. On Wednesday after market close, the calculateVolatility Lambda function runs and stores the data into DynamoDB. On Thursday at market open, the calculateTriggers Lambda function runs and sends emails with the trigger points calculated from the market open price.


$ npm install serverless -g


The project requires an active Mailgun account to send emails. Insert your mailgun API key and domain into the configuration file common/config.js. Also you will insert email addresses here.

const config = {};
config.mailgun = {
    apiKey: 'key-xxxxxxxxxx',
    domain: ''
config.emails = [
    'Rahul <>'
module.exports = config;


First, install the npm dependencies:

$ npm install

Deploy the functions to AWS:

$ sls deploy

The functions have GET endpoints tied to them just so they can be tested, but the functions are meant to be run on the schedule provided.


To debug serverless functions, you can use the following command:

$ sls logs -f <FUNCTION_NAME> -t

This will give a tailing log output of the function and provides stack traces of errors.