HOME

Serverless Trading Automation System

AWS-Powered Architecture

By Anthony Govoni

Overview

This project is a modular, event-driven trading automation system built entirely on AWS serverless infrastructure. The system ingests real-time data, evaluates strategy conditions, and places trades in a scalable, secure, and cost-efficient environment. It is designed to execute trades based on dynamic market conditions without the need for persistent servers or manual oversight.

System Architecture & Detailed Build

1. Lambda-Driven Orchestration

The system is composed of multiple independently deployable AWS Lambda functions, each designed with single-responsibility principles. These functions communicate via JSON payloads, enabling clean modularization and stateless execution. Core Lambda workflows include:

  • Market holiday & open checks
  • Strategy evaluation based on price drops from 52-week highs
  • Purchase limit tracking
  • Trade execution via brokerage API

2. Configuration & Security via AWS Parameter Store

Sensitive data and configuration variables—such as API keys, thresholds, and quantity tiers—are stored securely in AWS SSM Parameter Store. This allows for:

  • Secure access controls
  • Easy updates across dev/stage/prod environments
  • Cleaner Lambda code via dynamic config injection

3. Trade History & Compliance with DynamoDB

A central DynamoDB table stores historical trade data, including:

  • Ticker symbols
  • Purchase timestamps
  • Monthly orders

A Global Secondary Index (GSI) enables real-time filtering and enforcement of trade constraints like "max 4 shares per month per stock."

4. Shared Logic with Lambda Layers

To avoid code duplication, a custom Lambda Layer includes:

  • Pandas for data manipulation
  • Utility functions (e.g., percent-from-high calculations, date parsing)
  • Consistent environment for all trading logic functions

5. Observability with Google Sheets

All trade decisions and system events are logged to Google Sheets using a webhook-style endpoint. This provides:

  • Real-time observability
  • Easy stakeholder access
  • Auditable logs for all trade activity

6. Real-Time Market Data via External APIs

Market data is pulled on-demand via secure API calls within Lambda functions. These requests are stateless and triggered only during active trading windows, optimizing costs and performance.

Goals

  • Fully automate trading decisions using programmable logic and real-time data.
  • Design a scalable, serverless system that minimizes operational overhead.
  • Track and limit monthly trades to remain within compliance boundaries.
  • Log all trade-related actions in a human-readable format.
  • Ensure secure handling of configuration data and credentials.

Findings

  • Loose coupling between components made it easy to isolate/fix issues in individual Lambda functions without impacting others.
  • Serverless architecture significantly reduces idle costs, as functions only incur charges during execution.
  • Google Sheets as a logging tool was surprisingly effective for quick insights and debugging.
  • DynamoDB GSIs proved critical in efficiently querying time-bound purchase data.

Insights & Lessons Learned

  • Real-time API dependencies must be handled defensively, with retry logic and clear error propagation between functions.
  • AWS Parameter Store is an ideal solution for managing credentials securely, especially in multi-environment pipelines.
  • A well-structured JSON payload contract between Lambda functions is crucial for maintainability and debugging.
  • Building reusable logic into Lambda Layers drastically reduces redundancy and simplifies updates.

Next Steps / Enhancements

  • Enhance strategy logic to incorporate moving averages, RSI, or other technical indicators.
  • Implement backtesting functionality using historical data to refine strategy thresholds.
  • Expand multi-stock support and portfolio-level risk management logic.
  • Add more robust error alerting via AWS SNS or Slack integrations.