Serverless Webhook-to-Broker Execution

TradingView Paper Trading Automation

Built a paper-first AWS serverless execution path: TradingView strategy alerts hit API Gateway, a receiver Lambda validates and queues the signal, SQS buffers processing, a processor Lambda applies deterministic risk gates and idempotency checks, DynamoDB records redacted signal and order events, Secrets Manager isolates webhook and Alpaca paper credentials, and the Alpaca adapter submits paper orders only.

60 Test Suite

Challenge

TradingView can generate strategy alerts, but a direct webhook-to-broker path is too brittle for serious paper trading. The execution lane needs payload validation, replay protection, risk controls, audit history, secret isolation, and a live-trading lock before any broker API is allowed to receive an order.

Solution

Built a paper-first AWS serverless execution path: TradingView strategy alerts hit API Gateway, a receiver Lambda validates and queues the signal, SQS buffers processing, a processor Lambda applies deterministic risk gates and idempotency checks, DynamoDB records redacted signal and order events, Secrets Manager isolates webhook and Alpaca paper credentials, and the Alpaca adapter submits paper orders only.

Impact Metrics

60
Test Suite
tests
PAPER
Execution Mode
only
1
Broker Smoke
accepted order
100%
AWS Pattern
serverless

Results

  • End-to-end AWS smoke test submitted one Alpaca paper order with accepted broker status
  • 60-test local suite covers payload contracts, risk gates, broker adapters, Lambda handlers, and CloudFormation assets
  • CloudFormation template builds the AWS stack with API Gateway, Lambda, SQS, DynamoDB, Secrets Manager, IAM, CloudWatch, and S3 artifact flow
  • Live trading remains locked by design; broker adapter rejects live mode and non-paper Alpaca endpoints
  • TradingView setup guide and Pine strategy starter make the paper alert path reproducible

Business Impact

Demonstrates production-minded automation for a high-risk domain: event-driven AWS infrastructure, deterministic safety controls, broker abstraction, and paper trading proof without enabling real-money execution.

Architecture

TradingView to AWS Paper Trading LaneTradingViewPine alertAPI GatewaywebhookReceiverLambdaSQSbuffer + DLQProcessorrisk gateAlpacapaper APISecrets Managerwebhook + Alpaca paper keysDynamoDBidempotency + order auditCloudWatchlogs + alarm visibilityLive trading locked; PAPER mode onlyCloudFormation • Python Lambda • 60 tests • accepted Alpaca paper smoke

Portfolio POC uses paper trading only. The live path is intentionally unavailable until a separate live-readiness review, explicit approvals, stronger observability, and broker account controls are added.

Paper-First Execution Lane

A proven approach combining statistical rigor, automation, and AWS best practices.

1

Webhook Contract

TradingView Pine emits a structured JSON payload with symbol, action, quantity, mode, nonce, timestamp, and shared webhook secret.

2

AWS Ingestion

API Gateway and receiver Lambda validate request shape, redact sensitive values, and enqueue valid signals into SQS for asynchronous processing.

3

Risk + Idempotency

Processor Lambda checks kill switch, allowed symbols, max notional, stale timestamps, duplicate nonces, and explicit paper/live boundaries before broker submission.

4

Broker + Audit

Alpaca paper adapter submits paper orders only, then records broker outcomes in DynamoDB with CloudWatch visibility for operational review.

Screenshots

TradingView webhook AWS paper trading architecture diagram
Full AWS paper-trading architecture exported from the project README.
Sanitized build and test validation screenshot
Sanitized validation evidence showing the local build, test, and paper smoke results.

Scale & Scope

60
Validation
local tests - build, template, payload, risk, broker, and Lambda coverage
AWS
AWS Components
serverless stack - API Gateway, Lambda, SQS, DynamoDB, Secrets Manager
PAPER
Broker Mode
broker path - one accepted Alpaca paper smoke order

Technology Stack

  • TradingView Pine Script strategy alerts
  • AWS API Gateway HTTP API
  • AWS Lambda with Python
  • Amazon SQS and dead-letter queue
  • Amazon DynamoDB audit and idempotency tables
  • AWS Secrets Manager and IAM
  • AWS CloudFormation and S3 artifacts
  • Alpaca Paper Trading API

Need a similar solution?

Let's replicate this success within your organization with a tailored engagement plan.