AWS Builder Center

NSE Cloud Trader: Building a Paper-Trading and Stock Analytics Platform on AWS

A serverless AWS project that analyzes NSE stock data, generates trading signals, and simulates paper trades without real-money risk.

Stock markets generate large volumes of price data every second, and traders need fast systems to collect, analyze, and act on that data. This project demonstrates how to build a cloud-based NSE stock market analytics and paper-trading system using AWS services such as EC2, S3, Lambda, DynamoDB, and CloudWatch.
The system collects NSE stock price data, stores it securely, calculates simple trading signals, runs a paper-trading engine, and sends alerts. It does not place real-money trades, making it suitable for learning, demos, and portfolio projects.
AWS is widely used for financial trading systems because it provides scalable compute, managed databases, low-latency networking, and monitoring tools. For example, INDmoney’s INDstocks platform uses AWS to deliver NSE and BSE price ticks in under 50 milliseconds and process orders in under 20 milliseconds at peak load.aws.amazon 

Project Overview

The project is called NSE Cloud Trader.
It performs the following tasks:
  • Fetches daily or intraday price data for selected NSE stocks.
  • Stores historical market data in Amazon S3.
  • Calculates technical indicators such as moving averages and RSI.
  • Generates simple BUY, SELL, or HOLD signals.
  • Simulates trades using a paper-trading wallet.
  • Stores orders, positions, and profit/loss in DynamoDB.
  • Sends alerts through Amazon SNS.
  • Displays a dashboard using a simple React frontend hosted on S3 and CloudFront.
This architecture follows the common algorithmic-trading pattern: a market-data adapter feeds a trading engine, which can connect to a broker or exchange adapter.aws.amazon 

Architecture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
NSE Data Source
|
v
AWS Lambda / EC2 Python Worker
|
+--> Amazon S3 (raw and processed market data)
|
+--> Amazon DynamoDB (stocks, signals, orders, portfolio)
|
+--> Amazon SNS (BUY/SELL alerts)
|
+--> API Gateway + Lambda (backend API)
|
+--> React Dashboard on S3 + CloudFront
|
+--> Amazon CloudWatch (logs, alarms, monitoring)

AWS Services Used

AWS ServicePurpose
EC2Runs the Python trading engine and scheduled data-fetch jobs
S3Stores raw CSV/JSON market data and processed datasets
DynamoDBStores stock metadata, signals, paper orders, and portfolio state
LambdaHandles lightweight API requests and event-based processing
API GatewayExposes REST APIs for the frontend
SNSSends email or mobile alerts for trading signals
CloudWatchMonitors logs, errors, Lambda failures, and system health
IAMProvides secure, least-privilege access between services
CloudFrontDelivers the React dashboard globally with low latency
AWS provides relational, non-relational, and time-series database options, making it suitable for storing financial OHLC market data at scale.link.springer 

Trading Strategy

For the first version, use a simple Moving Average Crossover strategy.

Rules

  • Calculate the 20-day moving average (MA20).
  • Calculate the 50-day moving average (MA50).
  • Generate a BUY signal when MA20 crosses above MA50.
  • Generate a SELL signal when MA20 crosses below MA50.
  • Otherwise, generate a HOLD signal.
This is not financial advice or a guaranteed profitable strategy. It is a beginner-friendly rule-based strategy used to demonstrate the complete cloud workflow.

Sample Python Logic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import pandas as pd

def generate_signal(df):
df["MA20"] = df["close"].rolling(window=20).mean()
df["MA50"] = df["close"].rolling(window=50).mean()

latest = df.iloc[-1]
previous = df.iloc[-2]

if previous["MA20"] <= previous["MA50"] and latest["MA20"] > latest["MA50"]:
return "BUY"

if previous["MA20"] >= previous["MA50"] and latest["MA20"] < latest["MA50"]:
return "SELL"

return "HOLD"
The Lambda or EC2 worker can run this logic daily after market data is updated.

Paper-Trading Engine

The paper-trading engine simulates trades without using a real broker account.
When a BUY signal is generated:
  1. Check available virtual cash.
  2. Buy a fixed quantity, for example 10 shares.
  3. Deduct the amount from the virtual wallet.
  4. Save the order in DynamoDB.
  5. Send an SNS notification.
When a SELL signal is generated:
  1. Check whether the stock is already held.
  2. Sell the held quantity at the current price.
  3. Add proceeds to the virtual wallet.
  4. Calculate realized profit or loss.
  5. Save the transaction and send an alert.

Example DynamoDB Tables

Orders Table
AttributeExample
orderIdORD-2026-0001
symbolRELIANCE
actionBUY
quantity10
price2850.50
statusEXECUTED
timestamp2026-10-09T15:30:00Z
Portfolio Table
AttributeExample
symbolRELIANCE
quantity10
averageBuyPrice2850.50
currentPrice2890.00
unrealizedPnL395.00

Data Storage Design

Use S3 for raw historical data:
1
2
3
4
5
s3://nse-cloud-trader-raw/
symbol=RELIANCE/
year=2026/
month=10/
reliance_2026-10-09.csv
Use DynamoDB for fast access to current portfolio state, latest signals, and recent orders.
This separation keeps raw data inexpensive and scalable in S3 while allowing DynamoDB to serve low-latency application queries.

Backend API Example

The API Gateway exposes endpoints such as:
1
2
3
4
5
GET /stocks
GET /stocks/{symbol}/signals
GET /portfolio
GET /orders
POST /run-strategy
Example response:
1
2
3
4
5
6
7
8
{
"symbol": "RELIANCE",
"signal": "BUY",
"ma20": 2841.25,
"ma50": 2820.70,
"currentPrice": 2850.50,
"generatedAt": "2026-10-09T15:30:00Z"
}

Frontend Dashboard

Build a simple React dashboard with:
  • Stock search bar.
  • Current price and daily change.
  • Candlestick or line chart.
  • Latest BUY/SELL/HOLD signal.
  • Paper-trading wallet balance.
  • Open positions.
  • Order history.
  • Profit and loss summary.
Host the static React build in S3 and distribute it through CloudFront. API Gateway connects the dashboard to Lambda functions that read from DynamoDB.

Security Best Practices

  • Never hard-code API keys, broker credentials, or AWS access keys in code.
  • Store secrets in AWS Secrets Manager or Systems Manager Parameter Store.
  • Use IAM roles instead of long-term AWS access keys.
  • Restrict S3 bucket access using bucket policies.
  • Enable CloudTrail for auditing AWS API activity.
  • Use HTTPS through API Gateway and CloudFront.
  • Keep the project in paper-trading mode unless you fully understand SEBI, broker, and exchange compliance requirements.

Monitoring and Alerts

Use CloudWatch to monitor:
  • Lambda errors.
  • EC2 CPU and memory usage.
  • DynamoDB throttling.
  • S3 access errors.
  • API Gateway latency and 5XX errors.
  • Strategy-job success or failure.
Create a CloudWatch alarm that sends an SNS notification if the data-fetch job fails or if the trading engine stops running.

Deployment Steps

  1. Create an S3 bucket for raw and processed market data.
  2. Create DynamoDB tables for stocks, signals, orders, and portfolio.
  3. Create an IAM role with permissions only for the required services.
  4. Deploy a Python trading worker on EC2 or as a scheduled Lambda function.
  5. Store API keys and credentials in Secrets Manager.
  6. Create API Gateway endpoints backed by Lambda.
  7. Build the React dashboard and deploy it to S3 with CloudFront.
  8. Configure SNS email alerts.
  9. Set up CloudWatch dashboards and alarms.
  10. Test the complete flow using historical NSE data before enabling any live-data workflow.

Future Improvements

  • Add RSI, MACD, Bollinger Bands, and volume-based indicators.
  • Use Amazon SageMaker to train ML models for trend prediction or risk scoring.
  • Add backtesting using historical OHLCV data.
  • Store tick-level data using Amazon Timestream.
  • Add WebSocket support for near-real-time price updates.
  • Use AWS Step Functions to orchestrate the daily data pipeline.
  • Add user authentication with Amazon Cognito.
  • Add risk controls such as maximum daily loss, position limits, and stop-loss simulation.
AWS recommends combining data lakes, compute, and machine-learning services to build scalable investment decision-making systems. SageMaker can also be used to retrieve, analyze, visualize, and backtest trading strategies.aws.amazon+1

Conclusion

This project shows how AWS can power a complete NSE trading analytics platform: data ingestion, storage, signal generation, paper trading, alerts, APIs, and monitoring. It is an excellent cloud engineering and DevOps portfolio project because it combines Python, AWS infrastructure, databases, APIs, frontend development, and automation.
For a student project, keep it in paper-trading mode. Focus on building a reliable, secure, well-monitored cloud system rather than promising trading profits.

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article