0% found this document useful (0 votes)
104 views

DBMS Project

The document describes a stock market management system that allows users to view historical stock data, make investment decisions, and manage their portfolios. It aims to provide an efficient and user-friendly platform for tracking stocks, automating trades, analyzing markets, and optimizing performance.

Uploaded by

Karthik Dasari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

DBMS Project

The document describes a stock market management system that allows users to view historical stock data, make investment decisions, and manage their portfolios. It aims to provide an efficient and user-friendly platform for tracking stocks, automating trades, analyzing markets, and optimizing performance.

Uploaded by

Karthik Dasari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

STOCK MARKET MANAGEMENT SYSTEM

Submitted by

ABHIGNA PENUBARTHI [RA2111047010169]


SHAFFIN REYODS SURESH STEFIN [RA2111047010177]

Under the Guidance of

DR. BABU RAJENDRAN

Assistant Professor, Department of Computational Intelligence

In partial satisfaction of the requirements for the degree of

BACHELORS OF TECHNOLOGY
In
ARTIFICIAL INTELLIGENCE

SCHOOL OF COMPUTING
COLLEGE OF ENGINEERING AND TECHNOLOGY
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
KATTANKULATHUR - 603203

April 2023

1
SRM INSTITUTION OF SCIENCE AND TECHNOLOGY
KATTANKULATHUR-603203

BONAFIDE CERTIFICATE

Certified that this Course Project report titled “STOCK MARKET


MANAGEMENT SYSTEM” is the bonafide work done by ABHIGNA
PENUBARTHI [RA2111047010169], SHAFFIN REYODS SURESH STEFIN
[RA2111047010177] of II Year/ IV Sem BTech (AI) who carried out under my
supervision for the course 18AIC207J - Database Management Systems for
Artificial Intelligence. Certified further, that to the best of my knowledge the work
reported herein does not form part of any other work.

SIGNATURE SIGNATURE
FACULTY IN-CHARGE HEAD OF THE DEPARTMENT
Dr. Babu Rajendran Dr. R Annie Uthra
Assistant Professor, Professor and Head,
Department of Computational Intelligence Department of Computational Intelligence,
SRM Institute of Science and Technology SRM Institute of Science and Technology
Kattankulathur Campus, Chennai Kattankulathur Campus, Chennai

2
ABSTRACT

Stock Market System is a system which enables individuals and


organizations to trade shares and company stocks in the stock markets. It
enables everyone to invest their money and manage and maintain their
individual portfolios. It is a user-friendly system which makes it easy to
trade, find and invest in new companies which may interest them. We
can also see the historical prices through the system including the
companies open, high, close etc. on the Nifty 50 stock market which I
have used as a base for this project. The system also allows us to trade
and sell different stocks.

3
TABLE OF CONTENTS

ABSTRACT 3

LIST OF FIGURES 6

LIST OF TABLES 7
ABBREVIATIONS 8

Chapter No. Title

1 INTRODUCTION 9
1.1 Introduction

1.2 Problem Statement

1.3 Objectives

1.4 Scope and Applications

1.5 Software Requirements Specification

1.6 Software Used

2 LITERATURE SURVEY 13
2.1 Existing System

2.2 Comparison of Existing vs Proposed System

3 SYSTEM ARCHITECTURE AND DESIGN 15


3.1 System Design

3.2 ER Diagram

3.3 Relational Schema

3.4 Description of Tables

4
4 MODULES AND FUNCTIONALITIES 22
4.1 Overview

5 CODING AND TESTING 24


5.1 Code

5.2 Triggers & Stored Procedures

5.3 System Testing

6 RESULTS AND DISCUSSIONS 35


6.1 Result

6.2 Snapshots

7 CONCLUSION AND FUTURE ENHANCEMENT 40

8 REFERENCES 41

5
LIST OF FIGURES

Figure No. Figure Name Page No.

3.1 JSP Architecture 15

3.2 Enhanced ER diagram of Stock Market System 17

3.3 ER diagram of Stock Market System 18

3.4 Schema diagram 19

6
LIST OF TABLES

Figure No. Table Name Page No.

1 Users 20

2 Bank 20

3 Companies 20

4 Price 20

5 Investments 20

6 Profits 21

7
ABBREVIATIONS

SQL - Structured Query Language

DB - DataBase

UI - User Interface

8
CHAPTER 1

INTRODUCTION
1.1 OVERVIEW

“Stock Market System” is designed to help invest and trade in stocks, shares and
currencies on the international stock market system. It enables us to view all the historical
data on the companies present in the stock market and make smart investments decisions.

It also enables us to view and trade on the current investments made by customer and
thus help them decide whether to trade and sell those stocks or to buy any more stocks.
It also allows them to view their total profits and loss made on the stock markets.

1.2 PROBLEM STATEMENT

The main aim of “Stock Market System” is to make and easy interface for bankers,
investors and businesses to make systematic decisions on the stock market and help them
invest in the stocks of their choice.

1.3 OBJECTIVES

• Efficient stock tracking: The system should be able to track the prices and movements of
various stocks in real-time, enabling users to make informed investment decisions.

• Portfolio management: The system should enable users to manage their stock portfolios,
including buying and selling stocks, setting stop-loss and take-profit levels, and tracking
their overall portfolio performance.

• Automated trading: The system could be designed to enable automated trading based on
pre-defined rules and algorithms, reducing the need for manual intervention.

• Risk management: The system should include tools for managing risk, such as setting
risk thresholds and tracking exposure to specific stocks or sectors.

• Reporting and analysis: The system should generate reports and analysis that enable users
to track their performance, identify trends, and make informed decisions.

9
• Security and reliability: The system should be designed with robust security measures to
protect user data and prevent unauthorized access, and should be reliable and stable to
ensure continuous operation.

• User-friendly interface: The system should have a user-friendly interface that is easy to
navigate, with clear and concise information presented in a visually appealing way.

• Customization: The system should allow users to customize their settings and
preferences, tailoring the system to their specific needs and preferences.

• By meeting these objectives, a stock market management system can help investors make
informed decisions, manage risk, and optimize their portfolio performance.

1.4 SCOPE AND APPLICATIONS

The scope and application for a stock market management system are vast, as such a system can
be used by a range of investors and market participants. Some of the key areas where a stock
market management system can be applied include:

• Individual investors: A stock market management system can help individual investors
manage their stock portfolios and make informed investment decisions.
• Fund managers: Fund managers can use such a system to manage the investments of their
clients, monitor their portfolios, and track performance.
• Investment banks: Investment banks can use a stock market management system to
analyze market trends, develop investment strategies, and execute trades on behalf of
clients.
• Stock brokers: Stock brokers can use such a system to manage their clients' portfolios,
provide investment advice, and execute trades.
• Market analysts: Market analysts can use a stock market management system to analyze
market trends, track company performance, and make predictions about future market
movements.
• Regulators: Stock market management systems can also be used by regulators to monitor
market activity, detect fraud, and ensure compliance with regulatory requirements.

The scope of a stock market management system can also extend to various asset classes,
including equities, fixed income, commodities, and derivatives. The system can be designed to

10
handle a range of trading strategies, including long-term investing, swing trading, and day
trading.

1.5 SOFTWARE REQUIREMENTS SPECIFICATION

□ IDE - NetBeans 8.2


□ Web Browser – Firefox 50 or later, Google Chrome – 60 or later
□ Database support -
MySQL 5.7o MySQL
Server 5.7
o MySQL Shell 1.0.10
o MySQL Workbench
□ Operating system – Windows 7 / Ubuntu 16.04
□ JDK 1.8
□ Server deployment - Tomcat server / Glassfish Server

1.6 SOFTWARE USED

□ HTML is used for the front end design. It provides a means to structure text based
information in a document. It allows users to produce web pages that include text,
graphics and hyperlinks.
□ CSS (Cascading Style Sheets) is a style sheet language used for describing the
presentation of a document written in a markup language. Although most often
usedto set the visual style of web pages and user interfaces written in HTML and
XHTML,the language can be applied to any XML document.
□ Java Server pages is a simple yet powerful technology for creating and maintaining
dynamic-content web pages. It is based on the Java programming language. It can be
thought of as an extension to servlet because it provides more functionality than
servlet A JSP page consists of HTML tags and JSP tags. The jsp pages are easier to
maintain than servlet because we can separate designing and development.
□ We require a JDBC connection between the front end and back end components to
write to the database and fetch required data.

11
➢ MySQL :

MySQL is an open-source relational database management system (RDBMS). A relational


database organizes data into one or more data tables in which data types may be related to each
other; these relations help structure the data. SQL is a language programmers use to create,
modify and extract data from the relational database, as well as control user access to the
database. In addition to relational databases and SQL, an RDBMS like MySQL works with an
operating system to implement a relational database in a computer’s storage system, manages
users, allows for network access and facilitates testing database integrity and creation of
backups.

12
CHAPTER 2

LITERATURE SURVEY

2.1 EXISTING SYSTEM

The existing systems for stock market management vary widely in terms of their complexity and
functionality. Some of the most common systems include:

• Online trading platforms: These are web-based applications that enable investors to trade
stocks and other securities online. Examples of popular trading platforms include
E*TRADE, Robinhood, and TD Ameritrade.

• Portfolio management tools: These are software applications designed to help investors
manage their stock portfolios. They can track performance, analyze market trends, and
provide investment advice. Examples of popular portfolio management tools include
Personal Capital, Betterment, and Wealthfront.

• Market data providers: These are companies that provide real-time market data, news,
and analysis to investors. Examples of popular market data providers include Bloomberg,
Thomson Reuters, and Morningstar.

• Trading algorithms: These are automated trading systems that use pre-defined rules and
algorithms to execute trades. They can be used for a range of trading strategies, including
high-frequency trading, swing trading, and quantitative trading.

• Trading bots: These are automated software applications that use artificial intelligence
and machine learning to analyze market data and execute trades. They can be used for a
range of trading strategies and are becoming increasingly popular in the cryptocurrency
markets.

• Regulatory reporting systems: These are software applications used by regulators to


monitor market activity, detect fraud, and ensure compliance with regulatory
requirements. Examples of popular regulatory reporting systems include FINRA's Order
Audit Trail System (OATS) and the SEC's Market Information Data Analytics System
(MIDAS).

13
2.2 COMPARISON OF EXISTING VS PROPOSED SYSTEM

Some of the key differences between existing and proposed stock market management systems
include:

• Accessibility: Existing systems can be complex and difficult to use, requiring significant
expertise and knowledge of the markets. New systems aim to simplify the investment
process and make it more accessible to a wider range of investors.
• Automation: New systems are often based on new technologies such as artificial
intelligence, machine learning, and blockchain, and they aim to automate many aspects of
the investment process. This can lead to more efficient and accurate investment decisions.
• Cost: Existing systems can be expensive to use, with high fees for trading and managing
portfolios. New systems often aim to reduce costs by using automation and lower fees for
trades.
• Security: New systems are often based on blockchain technology, which provides a high
level of security and transparency. This can help to reduce fraud and increase investor
confidence.

14
CHAPTER 3

SYSTEM ARCHITECTURE AND DESIGN


3.1 SYSTEM DESIGN

The web server needs a JSP engine, i.e., a container to process JSP pages. The
JSP container is responsible for intercepting requests for JSP pages. A JSP
container works with the Web server to provide the runtime environment and
other services a JSP needs. It knows how to understand the special elements
that are part of JSPs. This server will act as a mediator between the client
browser and a database.
The following diagram shows the JSP architecture.

Fig. 3.1: JSP Architecture

Three-tier Client / Server database architecture is commonly used architecture


for web applications. Intermediate layer called Application server or Web
Server stores the web connectivity software and the business logic (constraints)
part of application used to access the right amount of data from the database
server. This layer acts like medium for sending partially processed data
between the database server and the client. Database architecture focuses on
the design, development, implementation and maintenance of computer
programs that store and organize information for businesses, agencies and
institutions. A database architect develops and implements software to meet
the needs of users. Several types of databases, including relational or
multimedia, may be created. Additionally, database architects may use one of
several languages to create databases, such as structured query language.

15
3.2 ENTITY RELATIONSHIP DIAGRAM

An entity–relationship model is usually the result of systematic analysis to define and


describe what is important to processes in an area of a business.

An E-R model does not define the business processes; it only presents a business data
schema in graphical form. It is usually drawn in a graphical form as boxes (entities) that
are connected by lines (relationships) which express the associations and dependencies
between entities.

Entities may be characterized not only by relationships, but also by additional properties
(attributes), which include identifiers called "primary keys". Diagrams created to
represent attributes as well as entities and relationships may be called entity-attribute-
relationship diagrams, rather than entity-relationship models.

An ER model is typically implemented as a database. In a simple relational database


implementation, each row of a table represents one instance of an entity type, and each
field in a table represents an attribute type. In a relational database a relationship between
entities is implemented by storing the primary key of one entity as a pointer or "foreign
key" in the table of another entity.

There is a tradition for ER/data models to be built at two or three levels of abstraction.
Note that the conceptual-logical-physical hierarchy below is used in other kinds of
specification, and is different from the three schema approach to software engineering.
While useful for organizing data that can be represented by a relational structure, an
entity-relationshipdiagram can't sufficiently represent semi-structured or unstructured
data, and an ER Diagramis unlikely to be helpful on its own in integrating data into a
pre-existing information system.

Cardinality notations define the attributes of the relationship between the entities.
Cardinalities can denote that an entity is optional.

16
Fig. 3.2: Enhanced ER diagram of Stock Market System

17
Fig. 3.3: ER diagram of Stock Market System

18
3.3 RELATIONAL SCHEMA

The term "schema" refers to the organization of data as a blueprint of how the database
is constructed. The formal definition of a database schema is a set of formulas called
integrity constraints imposed on a database. A relational schema shows references
among fields in thedatabase. When a primary key is referenced in another table in the
database, it is called a foreign key. This is denoted by an arrow with the head pointing
at the referenced key attribute. A schema diagram helps organize values in the database.
The following diagram shows the schema diagram for the database.

19
3.4 DESCRIPTION OF TABLES

The database consists of six tables:


1. Users: It stores the user details.
□ User_id: Unique user id done by auto increment.
□ Name: Name of the user.
□ Phone: Phone number of the user.
□ Email: Email id of the user.
□ Password: Password associated with user to login into system
□ Bank: Bank name associated with user

2. Bank: It stores the financial details of the users.


□ User_id: Foreign key of user associated with the bank
□ Bank Name Bank of the user.
□ Current_money: Current money held by user in the stock
marketplatform.

3. Companies: Stores the companies registered with the stock market


□ Company_name: Name of the company.
□ Industry: Name of the seed.
□ Symbol: Unique symbol of the company used to trade shares.
□ Series: Whether it is equity or mutual fund etc.
□ ISIN_Code: International code of the company.

4. Price: It stores the prices of the company across various times.


□ Symbol: Unique Symbol of the company
□ Time: Date of the info
□ Open: The opening price on particular day.
□ Close: The closing price on particular day.
□ High: The highest price on particular day.
□ Low: The lowest price on particular day.
□ Volume: The total volume traded on the day

5. Investments: It stores the current investments held by the customer


□ User_id: Unique identification of user who bought the shares.
□ Symbol: Company of which shares were bought
□ Volume: Total volume of shares bought.
□ Price_bought: Price at which the stock was bought
□ Time: Time of the investment

20
6. Profits: It stores the total profit/loss data after stock sale.
□ User_id :Unique identification number given to the user.
□ Symbol: Company of which shares were bought
□ Volume: Total volume of shares bought.
□ Price_bought: Price at which the stock was bought
□ Price_sold: Price at which the stock was sold
□ Time: Time of the selling
□ Date_bought: Date at which stock was bought
□ Date_sold: Date at which stock was sold
□ Totalpl: Total profit/loss made from selling.

21
CHAPTER 4

MODULES AND FUNCTIONALITIES


4.1 OVERVIEW

A stock market management system can involve various modules and


functionalities depending on the specific needs of the system. However, some
common modules and functionalities that can be included in a stock market
management system are:

• User Management: This module enables users to create and manage their
accounts, login, and access different functionalities of the system based on
their roles and permissions.

• Market Data: This module includes real-time and historical market data,
such as stock prices, indices, and news feeds. It may also include tools for
analyzing the data and generating reports.

• Portfolio Management: This module allows users to create and manage their
portfolios, including buying and selling stocks, tracking performance, and
generating reports. It may also include features such as risk management,
asset allocation, and tax optimization.

• Trading: This module provides users with tools for executing trades, such as
placing orders, monitoring trade execution, and managing open positions.

• Analytics: This module provides users with advanced analytical tools for
predicting market trends, identifying opportunities and risks, and optimizing
investment strategies. This module can include features such as machine
learning algorithms, data visualization, and statistical analysis.

• Risk Management: This module allows users to manage risks associated


with their investments, including market risks, credit risks, and operational

22
risks. It may include features such as portfolio stress testing, scenario
analysis, and risk reporting.

• Compliance: This module ensures that the system complies with regulatory
requirements and internal policies. It may include features such as audit
trails, compliance reporting, and anti-money laundering checks.

23
CHAPTER 5

CODING AND TESTING

5.1 CODE

5.1.1 Login: Login for the new user.


<%
String userid =
request.getParameter("email");String
pwd = request.getParameter("pwd");
String username;
String query = "select * from users where
email=?"; PreparedStatement psm =
con.prepareStatement(query);
psm.setString(1,userid);
ResultSet rs=psm.executeQuery();

if (rs.next()) {

String entpass =
rs.getString("password");String
cipher = entpass.substring(12);
BASE64Decoder decoder = new
BASE64Decoder();try {
String decoded = new
String(decoder.decodeBuffer(cipher));if
(decoded.equals(pwd))
{
username = rs.getString(3);
session.setAttribute("userid",
rs.getString("user_id"));
session.setAttribute("username", username);
response.sendRedirect("stocks/index.jsp");

24
}
else {
%>

<p class="text-info text-center">Invalid Password, Go Back and try again!

5.1.2 Companies List: List of all companies in nifty 50


<tbody class="table-big">
<%
ResultSet rs;
rs = st.executeQuery("select * from
Companies");while(rs.next())
{
<b>"+rs.getString("Company_name")+"</b></a></td>");
out.println("<td>"+rs.getString("Industry")+"</td>");
out.println("<td>"+rs.getString("symbol")+"</td>");
out.println("<td>"+rs.getString("Series")+"</td>");
out.println("<td>"+rs.getString("ISIN_code")+"</td>");
out.println("</tr>");
}
%>
</tbody>

5.1.3 Latest Price: List of latest price of companies in nifty 50


<tbody class="table-big">
<%
ResultSet rs;

rs = st.executeQuery("select P.* from Price P ORDER BY P.time DESC, P.symbol


ASC LIMIT 48;");
while(rs.next())

25
{
out.println("<tr>");
out.println("<td><b>"+rs.getString("symbol")
"</b></td>");
out.println("<td>"+rs.getString("open")+"</td");
out.println("<td>"+rs.getString("high")+"</td>");
out.println("<td>"+rs.getString("low")+"</td>");
out.println("<td>"+rs.getString("close")+"</td>");

</tbody>

5.1.4 Historical Price: Retrieve the price of stocks between 2 selected periods:
ResultSet rs;
rs = st.executeQuery("SELECT * FROM Price WHERE time >= '"+from+"' AND time
<='"+to+"' AND symbol ='"+stock+"' LIMIT 31");

if(rs.next())
{
String ctime = rs.getString("time");
String test[] = (ctime.split("-"));
String test2 = "new Date("+test[0]+","+(Integer.parseInt(test[1])-1)+","+test[2]+" )";

data+=rs.getString(type);
data3+="{ x : "+test2+" ,y : "+rs.getString(type)+"}";
data2+=rs.getString("time");
out.println("<tr>");
out.println("<td>"+rs.getString("time")+"</td>");
out.println("<td>"+rs.getString("open")+"</td>");
out.println("<td>"+rs.getString("high")+"</td>");
out.println("<td>"+rs.getString("low")+"</td>");

26
out.println("<td>"+rs.getString("close")+"</td>");
out.println("<td>"+rs.getString("volume")+"</td>");
out.println("</tr>");

while(rs.next())
{
me = rs.getString("time"); String
t test21[] = (ctime.split("-"));
i String test22 = "new
Date("+test21[0]+","+(Integer.parseInt(test21[1])-

data3+=",{ x : "+test22+" ,y : "+rs.getString(type)+"}";

data2+=rs.getString("time");
out.println("<tr>");
out.println("<td>"+rs.getString("time")+"</td>");
out.println("<td>"+rs.getString("open")+"</td>");
out.println("<td>"+rs.getString("high")+"</td>");
out.println("<td>"+rs.getString("low")+"</td>");
out.println("<td>"+rs.getString("close")+"</td>");
out.println("<td>"+rs.getString("volume")+"</td>");
out.println("</tr>");
}
}
else
{
out.println("<h2> No such stocks available between the dates you had entered
</h2>");
}

27
5.1.5 Buying Stocks: JSP Code to buy any new stocks
String uid = (String)request.getSession().getAttribute("userid");

float money=0;
rs = st.executeQuery("select current_money from bank WHERE
user_id="+uid+";"); if(rs.next())
money = Float.valueOf(rs.getString("current_money"));

rs = st.executeQuery("select * from Price WHERE symbol = '"+


request.getParameter("stock") + "' AND time >= '"+request.getParameter("date")+"'
ORDER BY time ASC LIMIT 1;");
if(rs.next())
{
float prices = Float.valueOf(rs.getString("close"));
int volume =
Integer.parseInt(request.getParameter("volume"));
String date = rs.getString("time");
float sale =
volume*prices;
if(sale>money)
{
out.println("<h2> Sorry, you have insufficient balance to buy the stocks</h2>");
}
else
{
out.println("Date is :"+date);
ResultSet sp = st.executeQuery("select * from investments WHERE
symbol='"+request.getParameter("stock")+"' AND user_id = '"+uid+"' AND time='"+date+"';");
if(sp.next())
{

28
PreparedStatement ps = null;

String sql="Update investments set volume = volume +


"+volume+" WHERE user_id='"+uid+"' AND time='"+date+"'";
ps = con.prepareStatement(sql); int i
= ps.executeUpdate();

}
else
{
CallableStatement cstat = con.prepareCall("{call buy (?,?,?,?,?)}");
cstat.setString(1, uid);
cstat.setString(2, request.getParameter("stock"));
cstat.setString(3, String.valueOf(volume));
cstat.setString(4, String.valueOf(prices));

5.1.6 Selling Stocks: JSP Code to sell any stocks which user might have
ResultSet rs;
String uid =
(String)request.getSession().getAttribute("userid
");; String buydate =
request.getParameter("buydate");
String selldate =
request.getParameter("selldate");
float money=0,sell_sale=0;
rs = st.executeQuery("select current_money from bank WHERE
user_id="+uid+";"); rs.next();
money = Float.valueOf(rs.getString("current_money"));

29
ResultSet sellrs = st.executeQuery("select * from Price WHERE
symbol='"+request.getParameter("stock")+"' AND time >= '"+selldate+"'
ORDER BY time ASC LIMIT 1;");
if(sellrs.next())
{
float prices1 = Float.valueOf(sellrs.getString("close"));
int volume1 =
Integer.parseInt(request.getParameter("volum
e")); String sell_date =
sellrs.getString("time");
sell_sale = volume1*prices1;

ResultSet buyrs = st.executeQuery("select * from investments WHERE


symbol='"+request.getParameter("stock")+"' AND time = '"+buydate+"'
ORDER BY time ASC LIMIT 1;");
if(buyrs.next())
{
int volume2 =
Integer.parseInt(buyrs.getString("volume"));
String buy_date = buyrs.getString("time");
float buy_Price = buyrs.getFloat("price_bought");
float buy_sale = buyrs.getFloat("price_bought") * volume1;

if(volume1 > volume2)


out.println("<h2> You can't sell stocks more than the volume you have
</h2>");
else
{
float total_pl = sell_sale - buy_sale;
t.setString(5, String.valueOf(date));
ResultSet sp2 = cstat.executeQuery();

30
}
if(volume1 == volume2)
{
PreparedStatement ps = null;
//out.println("DELETE FROM investments WHERE
user_id='"+uid+"' ANDsymbol='"+request.getParameter("stock")+"' AND time =
'"+buydate+"'");
String sql="DELETE FROM
investments WHERE
symbol='"+request.getParameter("stock")+"' AND time =
'"+buydate+"'";
ps =
con.prepareStatement(sql); int
i = ps.executeUpdate();
}
else
{
PreparedStatement ps = null;
String sql="Update investments set volume = volume -
"+volume1+" WHERE user_id='"+uid+"' AND time='"+buydate+"' AND
symbol = '"+request.getParameter("stock")+"'";
ps =
con.prepareStatement(sql); int
i = ps.executeUpdate();
}

CallableStatement cstat = con.prepareCall("{call sell


(?,?,?,?,?,?,?,?,?)}"); cstat.setString(1, uid);
cstat.setString(2,
request.getParameter("stock"));
cstat.setString(3, String.valueOf(volume1));

31
cstat.setString(4, String.valueOf(buy_Price));
cstat.setString(5, String.valueOf(prices1));
cstat.setString(6,
String.valueOf(java.time.LocalDate.now()));
cstat.setString(7, String.valueOf(buydate));
cstat.setString(8,
String.valueOf(sell_date));
cstat.setString(9,
String.valueOf(total_pl)); ResultSet sp2
= cstat.executeQuery();

PreparedStatement ps = null;
String sql="Update bank set current_money = current_money +
"+sell_sale+" WHERE user_id='"+uid+"'";
%>

5.2 TRIGGERS AND STORED PROCEDURES

• Trigger is used in Stock market to initialize a new user into banks with an initial
deposit of 1lakh the moment a new user is registered.

CREATE DEFINER=`root`@`localhost` TRIGGER


`users_AFTER_INSERT`AFTER INSERT ON `users`
FOR EACH ROW
BEGIN
INSERT INTO `project`.`bank`
(`bank_name`,`user_id`,`current_money`)VALUES
(new.bank,new.user_id,100000);
END ;

32
• Stored procedure is used in all the user forms to register the user.

CREATE DEFINER=`root`@`localhost` PROCEDURE `register`(in name char(50), in


emailchar(255), in password char(155), in phone char(12), in bank varchar(30))
BEGIN
INSERT INTO
users(`name`,`email`,`password`,`phone`,`bank`)
VALUES( name,email,password,phone,bank);
END

• Stored procedure is also used in buy stocks.


CREATE DEFINER=`root`@`localhost` PROCEDURE `buy in uid char(50), in
symbolchar(255), in volume char(155), in prices varchar(30),in time2
varchar(30))
BEGIN
INSERT INTO investments VALUES
(uid,symbol,volume,prices,time2);END;

5.3 SYSTEM TESTING:

5.3.1 SOFTWARE TESTING

Testing is the process used to help identify correctness, completeness, security and
quality of developed software. This includes executing a program with the intent
of finding errors. It is important to distinguish between faults and failures. Software
testingcan provide objective, independent information about the quality of software
and risk ofits failure to users or sponsors. It can be conducted as soon as executable
software (even if partially complete) exists. Most testing occurs after system
requirements have been defined and then implemented in testable programs.

33
5.3.2 MODULE TESTING AND INTEGRATION

Module testing is a process of testing the individual subprograms, subroutines,


classes, or procedures in a program. Instead of testing whole software program at
once, module testing recommend testing the smaller building blocks of the
program. It is largely white box oriented. The objective of doing Module testing
is not to demonstrate proper functioning of the module but to demonstrate the
presence of an error in the module. Module testing allows implementing of
parallelism into the testing process by givingthe opportunity to test multiple
modules simultaneously.

The final integrated system too has been tested for various test cases such as
duplicate entries and type mismatch.

34
CHAPTER 6

RESULTS AND DISCUSSIONS


6.1 RESULT

The resulting system is able to:

□ Authenticate user credentials during login.

□ Salted encryption for security of user passwords.

□ Register new users and link to their banks.

□ Allow users to view historical data of all the stocks.

□ Allow user to see the companies present in the stock market.

□ Ability to buy and trade shares in the companies they want to.

□ Sell the stocks when they feel they have made a profit.

6.2 SNAPSHOTS

This chapter consists of working screenshots of the project.

6.2.1 LOGIN PAGE

This is the login page for existing users and is the first page shown to any customer.

35
6.2.2 REGISTRATION PAGE

This is the registration page or any new users.

6.2.3 HOME PAGE

First Home Page shown to customers after login

36
6.2.4LIST OF COMPANIES

List of Nifty 50 companies used in our system

6.2.5 LATEST STOCK PRICE

This Page shows the latest stock market prices for all companies in the database

37
6.2.6 HISTORICAL STOCK PRICES

This allows users to see high, open, close and volume traded over the
selected timerange for any company they see.

6.2.7 BUY STOCKS PAGE


This page allows you to invest money in the stock of your choice.

38
6.2.8 PROFITS AND LOSS PAGE

We can see all our investments made and their respective profits/loss made from the
investments.

39
CHAPTER 7

CONCLUSION AND FUTURE ENHANCEMENT


The Stock Market System provides easier maintenance of various stocks
that person will invest in. It allows simplified operation and is a time saving
platform with the ability to view historical data and thus invest easily and
carefully on the various companies. The application has been completed
successfully and tested with suitable test cases. It is user friendly and
contains suitable options for users and shareholders. This is developed using
HTML5, CSS, JavaScript, JSP and SQL. The goals achieved by this project
are:
➢ Centralized database

➢ Easier buying, selling of various stocks.

➢ User friendly environment.

➢ Efficient management of stocks.

➢ Ability to view historical data and analyse them for better growth.

➢ View profits and loss statements, current investments in various companies.

Future upgrades to this project will implement:

➢ Better interfaces for the ability to view the stock prices of various
companies including better analytics, more data across various
companies, sectors and industries

➢ More stock market platforms including Sensex, Dow Jones etc.

➢ Ability to trade in forex exchanges and mutual funds.

➢ Better banking implementations between the customer and his bank.

➢ Ability to see and analyse the various companies customers tend


to trade and analyse these for better info.

40
REFERENCES
[1] Ramakrishnan, R., & Gehrke, J. (2011). Database
management systems. Boston: McGraw-Hill.

[2] Monson-Haefel, R. (2007). J2EE Web services. Boston,


Mass: Addison-Wesley. Silberschatz A., Korth H. F., &
Sudarshan S. (2011).

[3] Database systems concepts. Estados Unidos: McGraw-Hill


Companies, Inc.

[4] Hanna P. (2002): JSP 2.0 The Complete Reference,


Second Edition McGraw Hill Education.

[5] David F. (2011). JavaScript: The Definitive Guide Sixth edition.

[6] https://www.w3schools.com

[7] https://www.canvasjs.com

[8] https://getbootstrap.com/

[9] https://fontawesome.com

41

You might also like