DHANALAKSHMI COLLEGE OF
ENGINEERING
MANIMANGALAM, TAMBARAM,
CHENNAI-601301
STOCKER: CLOUD BASED STOCK TRADING
PLATFORM
. WITH FLASK WITH AWS EC2
AND RDS A NAAN MUDHALVAN
PROJECT REPORT
Submitted By:
ANANDH.N (410722104009)
CHIRANJEEVI.B (410722104019)
DEEPAK KUMAR.K (410722104023)
GOWTHAM BALAJI.A (410722104037)
Project Reviewed By: NAGARAJ.D
Project Created Date: 13/NOV/2024
College Code: 4107
1
Team Name:NM2024TMID18280
2
TABLE OF CONTENTS:
CONTENTS:
1)Overview of Tools Used in the Project.................................3
2 ) Abstract..........................................................................................4
3).................................................Literature Survey
5
4)...............Existing and Proposed System with Code
6
5) Code Implementation7
6)......................................Architecture and Diagrams
10
7)..................................................Execution Results
11
8)...........................................................References
12
3
1)Overview of Tools Used in the Project:
Flask:
Flask is a lightweight Python web framework known for its flexibility,
minimalism, and ease of integration. Flask allows the development of
RESTful APIs and provides easy handling of HTTP requests, templating,
and routing. For Stocker,
Flask is used to manage the backend, handle user requests,
perform trading logic, and serve dynamic stock data.
AWS EC2 (Elastic Compute Cloud):
AWS EC2 is a scalable cloud service provided by Amazon that offers
secure,
resizable compute capacity in the cloud. EC2 instances are virtual
servers where the Flask application is deployed. This allows the
platform to be available to multiple users simultaneously, and
additional instances can be added if the application demands more
capacity.
AWS RDS (Relational Database Service):
AWS RDS provides a managed, scalable database service in the cloud. It
supports popular databases like MySǪL, PostgreSǪL, and Oracle. For Stocker,
RDS with MySǪL is used to store user data, stock prices, transaction history, and
portfolio details. RDS ensures data is available and secure, and can handle
requests from multiple instance
MySǪL Database:
MySǪL is a widely used relational database management system that supports
structured data storage, retrieval, and manipulation. MySǪL tables store
structured information such as user accounts, stock information, and portfolio
holdings, supporting complex queries and transactions.
Real-time Stock Data APIs (Alpha Vantage / Yahoo Finance):
APIs such as Alpha Vantage or Yahoo Finance are used to fetch real-time stock
data. These APIs allow Stocker to retrieve current stock prices, historical data,
and market trends, making it possible for users to view live data and make
4
informed decisions within the simulation.
5
2 ) Abstract:
This project report presents "Stocker," an innovative cloud-
based platform designed to simulate stock trading, enabling
users to explore and practice investment strategies using real-
time market data without risking actual capital. Stocker is
engineered with Flask, a robust Python web framework, and is
deployed on Amazon Web Services (AWS) EC2 for seamless
accessibility and high availability. User data, including
transaction history and portfolio information, is securely
stored on AWS RDS (Relational Database Service), ensuring
both the integrity and reliability of user data. The platform is
particularly aimed at beginner investors who wish to gain
practical experience in stock trading through realistic
simulations that reflect live market conditions.
Stocker is built to provide an interactive and engaging experience,
offering key features such as real-time stock price tracking
through integration with external APIs that fetch up-to-the-minute
market data. Users can engage in simulated buying and selling
of stocks, allowing them to develop trading
skills and confidence in a virtual environment. Through a user-
friendly
interface, Stocker enables users to manage virtual portfolios and
analyze their simulated trading performance over time. Each
transaction is securely logged in a database, allowing users to
review their past trades, understand market trends, and refine
their investment strategies without any financial exposure.
The platform incorporates comprehensive user authentication
protocols to ensure data privacy and account security.
Designed with scalability in mind, Stocker leverages cloud-
based architecture to support a growing user base while
maintaining performance and availability. With its
accessible design and emphasis on real-time data, Stocker
allows novice investors to familiarize themselves with stock
market dynamics, make
informed decisions based on real-world information, and
develop a deeper understanding of stock trading fundamentals
in a controlled, risk-free
6
setting.
The combination of cloud computing resources, real-time data
integration, and secure data storage positions Stocker as a
reliable, high-performance tool for beginners looking to gain
hands-on experience in stock trading.
7
3) Literature Survey:
Overview of Stock Trading Platforms:
Several cloud-based trading platforms like Robinhood,
Webull, and E*TRADE have become popular, providing
online and mobile trading
services. They utilize modern web technologies and cloud
infrastructure to provide real-time stock prices, secure
transactions, and easy access to market data.
Research in financial technology (fintech) shows that cloud
infrastructure is vital for handling the large volumes of data
required for real-time stock trading.
Simulation vs. Real Trading:
While traditional trading platforms allow live trading,
simulated platforms like TradingView allow users to practice
trading without financial risk.
These simulations are beneficial for users interested in
understanding the market and developing trading strategies
before engaging in live trading.
Cloud-Based Financial Applications:
Studies in cloud-based financial applications highlight the
importance of scalability, data security, and reliability. These
applications require robust
infrastructure and security practices to manage sensitive user
information, high-traffic loads, and complex data analysis. AWS
services like EC2 and
RDS offer the tools needed to meet these requirements.
This project draws from the architecture of cloud-based
trading platforms and financial applications to provide a
secure and scalable simulation experience. By leveraging
cloud infrastructure, Stocker can offer real-time trading
simulation with minimal operational complexity.
8
4) Existing and Proposed System with Code
Existing System
Limitations
Existing trading platforms focus primarily on live trading with real
money, which introduces financial risk for new users. Simulation
platforms are limited in availability and often require expensive
subscriptions. Additionally, most platforms have complex
architectures that can limit accessibility for novice
investors.
Proposed System
Stocker addresses these limitations by providing a simulated stock
trading environment based on real-time market data. Users can
register, log in, view stock information, and execute simulated
trades without financial risk. The
system uses Flask, AWS EC2, AWS RDS, and a stock data API to
create a secure, accessible, and user-friendly experience. The goal is
to give users a feel for the stock market while helping them build
trading strategies.
Features:
User Registration and Authentication.
Viewing Real-time Stock Prices.
Simulated Trading (Buying and Selling Stocks).
Portfolio Management.
9
To understand this project even better we would have to see some sample
codes.
5) Code Implementation:
Flask Application Setup ([Link]):
/*PYTHON
from flask import Flask, render_template, request, redirect,
url_for from flask_sqlalchemy import SǪLAlchemy
from config import
Config app = Flask(
name )
[Link].from_object(Confi
g) db = SǪLAlchemy(app)
@[Link]('/')
def index():
return
render_template('[Link]') if
name == " main ":
[Link](debug=True)
This code initializes the Flask app, sets up SǪLAlchemy for database
operations, and defines the home route.
Configuration for AWS RDS ([Link])
python
import os
class
10
Config:
11
SECRET_KEY = [Link]('SECRET_KEY') or 'your_secret_key'
SǪLALCHEMY_DATABASE_URI = [Link]('DATABASE_URL') or
'mysql+pymysql://username:password@hostname/dbname'
SǪLALCHEMY_TRACK_MODIFICATIONS = False
The configuration file sets environment variables, connects to the RDS
database, and configures the Flask application
Database Models ([Link])
from app import
db class
User([Link]):
id = [Link]([Link], primary_key=True)
username = [Link]([Link](64), unique=True,
nullable=False) email = [Link]([Link](120),
unique=True, nullable=False) password =
[Link]([Link](128), nullable=False)
portfolio = [Link]('Portfolio', backref='user',
lazy=True) class Stock([Link]):
id = [Link]([Link], primary_key=True)
symbol = [Link]([Link](10), unique=True,
nullable=False) name = [Link]([Link](50),
nullable=False)
price = [Link]([Link],
nullable=False) class Portfolio([Link]):
id = [Link]([Link], primary_key=True)
user_id = [Link]([Link], [Link]('[Link]'),
nullable=False) stock_id = [Link]([Link],
[Link]('[Link]'), nullable=False) quantity =
12
[Link]([Link], nullable=False)
13
User Registration and Login
from flask import Flask, render_template, request, redirect, url_for, flash
from [Link] import generate_password_hash, check_password_hash
from models import db, User
@[Link]('/register', methods=['GET', 'POST'])
def register():
if [Link] == 'POST':
username = [Link]['username']
email = [Link]['email']
password = generate_password_hash([Link]['password'])
user = User(username=username, email=email, password=password)
[Link](user)
[Link]()
flash('Registration successful!')
return redirect(url_for('login'))
return render_template('[Link]')
@[Link]('/login', methods=['GET', 'POST'])
def login():
if [Link] == 'POST':
email = [Link]['email']
password = [Link]['password']
user = [Link].filter_by(email=email).first()
if user and check_password_hash([Link], password):
flash('Login successful!')
return redirect(url_for('index'))
else:
flash('Invalid login credentials')
return render_template('[Link]')
14
6) Architecture and Diagrams:
System Architecture Diagram:
Use Case Diagram:
15
7) Execution Results
User Registration and Authentication
Stock Data Fetching
Simulated Trading
Data Storage and Retrieval
8) References
Flask Documentation.
16