You are on page 1of 27

University of Bridgeport CS-597: Advanced Problem in Computer Science

-- Master Project Report -September 28, 2001

ONLINE STOCK TRADING SYSTEM


Project Advisor: Prof. Tarek Sobh Student: Yuming Bao, #469449

TABLE OF CONTENTS
TABLE OF CONTENTS .................................................. ABSTRACT ...................................................................... INTRODUCTION AND BACKGROUND ...................... BACKGROUND OF ONLINE TRADING ..................... BRIEF PROJECT DESCRIPTION ................................. INTRODUCE JAVA SERVLET..................................... GLOSSARY ................................................................... SYSTEM FUNCTION OVERVIEW ............................... COMPARE PRICE CHANGES ...................................... ACCESS STOCK PROSPECTUS .................................. ACCESS USER PORTFOLIO ........................................ TRADING STOCK. ........................................................ THE TRADING ENGINE .............................................. SYSTEM DESIGN OVERVIEW ..................................... SYSTEM ORGANIZATION .......................................... SYSTEM FLOW ............................................................ IMPLEMENTATION LANGUAGES............................. SYSTEM REQUIREMENT ............................................ Server End .................................................................. Client End (User end): ................................................. USER INPUTS ............................................................... SYSTEM OUTPUTS ......................................................

SYSTEM FILES ............................................................. LIMITATIONS AND RESTRICTIONS ......................... CLASSES ....................................................................... USER MANUAL ............................................................... INSTALLATION ........................................................... Install server ................................................................ Start Server ................................................................. Client .......................................................................... USER INSTRUCTION ................................................... Login manual .............................................................. New User Register ...................................................... Portfolio ...................................................................... Trade........................................................................... Buying Stock ........................................................... Selling Stock ........................................................... More about trading .................................................. Open Orders ................................................................ History ........................................................................ Compare Stocks .......................................................... Stock information ........................................................ Real Market index ................................................... Stock Quote............................................................. Stock Profile ............................................................ Stock Chart.............................................................. Stock Research ........................................................ News ....................................................................... User logout.................................................................. REFERENCES .................................................................

ABSTRACT
This project is to develop an Online Personal Stock Investing System, which provide services for investors to monitor and compare price changes, buy stocks, sell stocks and manage their portfolios, trading details, view open orders. Through the system, the investors are able to obtain the real time stock information, finding stock chart, news and

research on internet that can help users to find the right investment strategies, all these using a user-friendly well-organized graphical user interface. This online stock trading system is modeled as client-server-data

three-tier structure. User submits request to servlets, servlets fetch information by accessing database files or Internet websites and create a page to display all the information that meets user s request. Keywords: Online trading system, Java, Jave Servlet, Client/Server, browser, web server

INTRODUCTION AND BACKGROUND


Background of online trading
Today, you can hardly pick up a newspaper, turn on a television, overhear a conversation, or talk to a friend without mention of the Internet. It has done nothing short of change the way our world works and the way our nation invests. And overall, it has changed us for the better. Point, click, and trade these three little words sum up the allure of online stockbrokers. Using nothing more than an Internet connection and an account with an online broker, one can buy and sell shares of stocks and mutual funds with mere keystrokes. No waiting to place an order with

a brokerage house, no high commissions gobbling up big pieces of your nest egg. The number of people using the Web to invest is growing fast. As the stock market moves in and out of record territory, investors are increasingly turning to the Web to research, discuss and trade stocks and securities. By one account, more than seven million Americans trade on-line -comprising 25 percent of all trades made by individual investors. In 1994, not one person traded over the Internet. In the next few years, the number of on-line brokerage accounts will roughly equal the metropolitan populations of Seattle, San Francisco, Boston, Dallas, Denver, Miami, Atlanta and Chicago, combined. A Forrester Research study predicts that the number of online accounts will grow from the current level of about 3 million to roughly 14 million by 2002. Over 6 million plucky investors have already exchanged the security of traditional brick-and-mortar brokerage houses for the promise of cheap, fast online transactions and reams of late-breaking information about the hottest properties on the market. Personal computer technology is becoming an important, integrated element for online investment. Mainframes, mini and microcomputers have given way to PC's in 1990. Revolutionary strides in interconnectivity have been observed with the advent of network operating systems (NOS), object-oriented programming methodology and client-server paradigms with ever decreasing price to performance ratio. The growth of the Internet

has been richly supplemented with hypertext/media based browser technology to what we now recognize as the World Wide Web. Some applications for computer technology allow people access information resources from global network environment.

Brief Project Description


The goal of this project is to contribute to the design and implementation of an online personal stock trading system that would be deliverable over the WWW replete with interactive modules. These modules will have the basic services: managing personal portfolios, obtaining real time stock information, finding stock chart, news and research on internet that can help you find the right investment strategies, all these using a user-friendly well-organized graphical user interface.

Introduce Java Servlet


This project is implemented most with Java Servlets. The Java Servlet API, introduced as the first standard extension to Java, provides a generic mechanism to extend the functionality of any kind of server. A servlet is a Java program embedded within a Web server. Instead of using Perl, some other scripting language, or a server proprietary API to respond to an HTML request, you would use a Java servlet. The servlet runs directly in the Web server and does not need to fork off a new process. They can live on between sessions, can communicate directly with other servlets, and are portable between platforms and Web servers. Servlets are most commonly used, however, to

extend Web servers, performing tasks traditionally handled by CGI programs. The beauty of servlets is that they execute within the Web server's process space and they persist between invocations. This gives servlets tremendous performance benefits over CGI programs. Yet because they're written in Java, servlets are far less likely to crash a Web server than a Cbased NSAPI or ISAPI extension. Servlets have full access to the various Java APIs and to third-party component classes, making them ideal for use in communicating with applets, databases, and RMI servers. Plus, servlets are portable between operating systems and between servers -- with servlets you can "write once, serve everywhere."

Glossary
ASCII American Standard Code for Information

Interchange. Most commonly associated with the standard test format (ASCII test) Browse r ClientServer System A system of two or more computers in which at least one computer provides services for one or more other computers. The services can be database services, communication services, printer services, or some other function. Databas A self-describing collection of integrated records. An application capable of interpreting hypertext.

e Servlet A servlet is a Java program embedded within a Web server that respond to an HTML request, you would use a Java servlet. The servlet runs directly in the Web server and does not need to fork off a new process. A servlet can live on between sessions, can communicate directly with other servlets, and are portable between platforms and Web servers. GUI Graphical User Interface, an interface having window, pop-down menus and other features that are often manipulated with a mouse pointer. Internet JAVA LAN A group of interconnected computers. Object Oriented programming language. Local area network. A group of microcomputers connected to one another by means of communication lines in close proximity, usually less than a mile. URL Yahoo Tomcat Uniform Resource Locator Internet search engines. A web server designed for PC.

SYSTEM FUNCTION OVERVIEW

This project is an online stock trading system. It is a three-tier structure Java program. User submits request to Java servlets, and servlets will fetch information from Internet or from database files and create a page to display all the required information on user s web browser. Through this system, user can monitor and compare price changes, trade stocks, manage portfolio, get real time information about stock and market. Through the system, users can perform following functions:

Compare Price Changes


Twenty selected stocks' real time price is continuously monitored by the back engine. User may check a number of them that are the most up/down during a period of time in the past. By just click a button, the given number of stocks' symbols and price changes will be listed in the ascending order. The twenty stocks that are chosen to be checked are: DELL, IBM, ORCL, MSFT, CSCO, INTC, SUNW, LU, EMC, GE, NT, AOL, PALM, JDSU, AMZN, YHOO, AMD, CIEN, F, AXP.

Access Stock Prospectus


Allow investors to retrieve the related information about some specific stock. The following information about each stock can be obtained through the system: (1) Real time Stock Information (2) Stock price charts (3) Company Information of corresponding stocks. (4) Stock research and

(5) Related news. User will get all the useful information by giving the stock system.

Access User Portfolio


Allow investors to access their own portfolios. Each investor has his/her own portfolio, which will keep all the information about the investment of the user, including account statement (including available cash, available margin, account value, stock value, buying power, pending money and holding stocks), transaction history and open orders. The investors can access their personal account and get all the information about their account.

Trading Stock.
User can exchange stocks via the system. The system is designed to protect investors from fraud. Each user will be asked to input their account name and his/her password. If the login/password is verified, the use can enter the portfolio, otherwise, the login request will be denied. Users can customize their orders by choosing Action (Buy or Sell), Quantity(Shares of stocks), Symbol(Stock symbol), price(the acceptable trading price) and Order Type(Market or Limit). Background running engine will check all the open orders periodically. For market orders, the final deal price

will be the last trade price of the real market, and the transaction will be complete as soon as possible. For Limit orders, if your buying price is

lower than the market price (or your selling price is higher than the market), your order can t be completed until the market price meets your

price. Otherwise, your order will be complete as soon as possible, and the deal price will be the market price.

The trading engine


The engine is an always alive process running background. It will check all the open orders in the system and try to accomplish the orders. It will periodically check open orders in the system. Check the real time market price of the stock. If the price is better than the user request, the order will be fulfilled with this market price, else the order will remain open in the system. Meanwhile, the engine is also continuously monitoring the price changes of twenty selected stocks. According to user s commands, it may compare the price changes, and then obtain a number of stocks that are the most up/down during a period of time in the past. After that, the given number of stocks' symbols and price changes will be listed in the ascending order.

SYSTEM DESIGN OVERVIEW


System Organization
The system organization for the project is as follows:

In general the clients (web browser such as Netscape) will send requests via the web server over to the Java servlets reside on the server PC. Those servlets will access the database files or access information on the Internet, and then generate a response page to display on user's browser.

System Flow
User inputs all required information into the web browser and then submits the request. The request will be sent to the Java Servlets reside on the server PC. Once a request is received by the servlet, the servlet will perform corresponding function depend on the request type. The servlet maybe access the database files or retrieve the information from the Internet. In the end, the servlet will generate a dynamic homepage sending back to client web browser. User will get all needed information on the web browser.

Implementation Languages
In late 1995, the Java programming language burst onto the Internet scene and gained instant celebrity status. JAVA is a portable programming language with a standard set of class libraries. The promise of java is that it will become the universal glue that connects users with information,

whether that information comes from web servers, databases, information providers, and any other imaginable sources. The APIs permit a programmer to create appropriate Graphical User Interfaces and communicate with network services such as HTTP. Java has built-in security and safety features are reassuring both to programmers and to the users of the program. Java even has built-in support that make advanced programming tasks, such as network programming, database connectivity, and multithreading, more straightforward.

System Requirement
Server End 1. You must have Java Virtual Machine on your PC. 2. You must have Java Servlet Development Kit (JSDK) installed on your machine. 3. A web server must be installed. You need to download Java Web Server such as Tomcat from java.sun.com. Install them into

c:\program files\Tomcat-3.2.1. Client End (User end): IE4.0/Netscape 4.5 or up is recommended.

User Inputs
User interactivity will be a major function that will be required by the on line stock trading system. Sometimes users will have to enter information in form fields by using their keyboard or sometimes users will

need to use the mouse to click buttons, highlight choices, initiate functions, and navigate the pages.

System Outputs
The outputs of the application will be generated dynamically by the application according to the user's input and interactivity. The application will communicate with the server end database files and will return relevant information.

System Files
Besides the browser application, end-users do not have to have additional system files to run the interface because the JAVA Virtual Machine and the web browser handles most of the processing of servlets and HTML tags.

Limitations and Restrictions


Users can encounter problems or limited functionality if they are not using Netscape version 4.5 or later. The JAVA Virtual Machine is available in an earlier version of Netscape but, tends to be unstable at times which causes the computer, especially Power PC, to hang. It is recommended that users should upgrade to a newer version of Netscape that are available at the Netscape websites.

Classes
Class name Activate actv delete Functions Achieved Generate the reply page of opening orders Generate the page body of opening orders Delete an opening order

dotrade dow

Do the trade Generate the market index of the main page engine Check opening orders and 20 real time stock price CheckStock Get stock price from stored file for compare checkActiveStock Check stock price change by user s instruction GetQuote Get real time quote data from internet GetValue Get real time stock market price History Generate the history page mainFrame Generate the main page newUser Create a new account for a new user OpenFile Open file portfolio Generate page of portfolio port Get token from data file and prepare for portfolio quote Get the real time stock information trade Trade stocks loginStock Login the stock center

USER MANUAL
Welcome to this User Manual. This manual will lead you go through the installation and tell you how to use the system . On line stock trading

Installation
This program is modeled as model. Install server You must have Java Virtual Machine on your PC. You must have Java Servlet Development Kit (JSDK) installed on your machine. A web server must be installed. You need to download Tomcat Client-Server-Database three-tier

from java.sun.com. Install it into c:\program files\Tomcat-3.2.1. Set up an alias (virtual directory) c:\jy\trade\ . Copy all java files into C:\jy\trade\Web-inf\classes\. Under this directory, compile all the java files using javac *.java . trade , and then map it to the directory

Copy all html files into C:\jy\trade\, and copy all image files into C:\jy\trade\images\. Make a directory c:\jy\trade\profiles, make an empty file named: password.txt. Now your installation for server end has finished.

Start Server To launch the server, click C:\Program Files\tomcat-

3.2.1\bin\startup.bat; and then start the engine by command line: java engine x (x: an integer that represents the interval in seconds at which engine checks real time stock price once again). Client All needed is a web browser. IE 4.0 / Netscape 4.5 or up is recommended. Once the server is launched, user can access the service anywhere if and only if a web browser is available. In this manual, 127.0.0.1 (localhost) is used as server s IP address. Enter

http://localhost/trade/loginStock.html

in the address bar of the localhost

browser. To access a sever on another machine, just replace by the server s IP address.

User Instruction
Login manual Open the location will see login page. http://localhost/trade/loginStock.html , the users

For users with an existing account, just enter his user name and password, then click submit button.

If user name and password are correct, displayed. That means login succeeds.

stock center

page will be

If user left user name or password empty, there will be an alert window pop up and tell user to fill in the user name or password.

If user name or password is not correct, system will tell user to login , user can click login and try to login again.

Failed

The user ID will be a combination of at most 20 any characters. The password will be a combination of at most 30 any characters. All user names and passwords are case sensitive. New User Register If you are new to this system, you need to create a new account. Click register button, User register page will be displayed.

All four fields are required. Name and password will be used to login later. Please be sure to remember your name and password. Re-enter Password is to let the user verify their password. This field must be

EXACT same as Password. The Starting money is the amount of money you want to deposit to your account.

If new user s name has already been used, system will tell user User name has been used. Choose another one , and user can click Register Here and try to register again.

If any field of register form is left blank or re-enter password is different from the first time, there will be an alert window pop up and tell user to fill up all the field or verify his password again.

After correctly registered,

stock center

page will be displayed.

Users can do all kind of transaction through this page. The detail will be given in the following sections. Portfolio Click Portfolio on pushdown menu, and then click Refresh .

Users can view information about their account, including Available Cash: The amount of cash you have in your account Available Margin: The amount of money you can borrow from your broker

Account Value: The total value of your account, including cash value and stock value Stock Value: The total value of your holding stock Buying Power: How much money you can spend to buy stock. This value is the sum of Available Cash and Available Margin Pending Cash: the amount of money is pending. This number is the amount of money pending due to the opening buy orders.

Users can also view stocks they have, including Stock Symbol, Quantity, Current Price and Price changing.

Trade Click trade on pushdown menu, Trading page will be displayed.

Buying Stock Select radio button Buy , enter quantity for purchase, stock symbol

and stock price that willing for transaction, then choose order type, Limit or Market . If choosing Market , price field can be left

empty. In fact, anything enter in price field will be neglected when order type is market . For Limit orders, a valid price must be provided, or

the order will be invalid and can t be submitted.

After transaction succeeds, system will check the order, including validating all the required. If any field is in valid, system will announce this order is invalid.

Be sure to spend money you do have. Never spend money you don t have. System will not accept your order. If user doesn t have enough buying power to complete the purchase, system will tell user have enough cash. You don't

If everything is correct, system will insert this order into the trading system. You will see a page telling you successfully initiated. Your order has been

Selling Stock Selling stock is same as buying stock. Select radio button Sell ,

enter quantity for sale, stock symbol and stock price that willing for transaction, then choose order type, Limit or Market . If choosing

Market , price field can be left empty. In fact, anything enter in price field will be neglected when order type is Market .

After transaction succeeds, system tells user successfully initiated.

Your order has been

If any field is left blank or user types in wrong

stock symbol or user tries to sell stocks he doesn t hold or user tries to sell more stock than he have, system will tell user invalid . More about trading There is an engine running background. This engine will check all the open orders periodically. For market orders, the final deal price will be Your order is

the last trade price of the real market, and the transaction will be complete as soon as possible. For Limit orders, if your buying price is lower

than the market price (or your selling price is higher than the market), your order can t be completed until the market price meets your price. Otherwise, your order will be complete as soon as possible, and the deal price will be the market price. Open Orders You can view your open orders by click Open orders on pushdown

menu. You can view all information about your open orders including action (buy/sell), stock symbol, quantity and price (market/limit).

If you feel regret about some open orders, just cancel these orders by click cancel button at anytime.

History Click history on pushdown menu, then users can view information

about all their account transaction history since the account was created, including Action (deposit/withdraw/buy/sell), stock symbol, quantity, price and date/time when completion of this transaction.

Compare Stocks User may compare a number of stocks among 20, which are the most up/down during a period of time in the past.

After the button is clicked, the given number of stock symbols and price changes will be listed in ascending order.

Stock information Click Quotes on pushdown menu, and with different option on

Quote menu, users can view different kind of information about stocks. Real Market index Click Refresh , user can view the real time market index, including

Dow Jones, Nasdaq, S&P 500. These index will reflect the overall market performance. Stock Quote Click then click Quote on Quote menu, enter stock symbol in text area, and

GET . User can get real time stock information, including

last trade value, trading time, price change, Stock exchange volume and stock price change percentage.

User can enter multiple stock symbols at the same time, use space as delimiters between the symbols.

If user type in symbol that doesn t exist, system will tell user Symbol not found.

Error:

Stock Profile Click then click Profile on Quote menu, enter stock symbol in text area, and

GET . User can get company profile from Internet, including

company address, industry type, CEO, company description, fundamental data (total net income, EPS, Dividends and ect.) and ratio data (price/earning ratio and ect.).

User can enter multiple stock symbols at the same time, type space in between these symbols.

Stock Chart Click then click Chart on Quote menu, enter stock symbol in text area, and

GET . User can get stock chart of whole last year from

Internet. User can enter multiple stock symbols at the same time, type space in between these symbols.

Stock Research Click Research on Quote menu, enter stock symbol in text area,

and then click

GET . User can get stock research information from

Internet, including Analyst Recommendations and EPS Estimates. User

can enter multiple stock symbols at the same time, type space in between these symbols.

If user type in symbol that doesn t exist, system will tell user Symbol not found. Look up symbol .

News Click then click News on Quote menu, enter stock symbol in text area, and

GET . User can get news related to specific stock from

Internet. User can enter multiple stock symbols at the same time, type space in between these symbols. Click stock symbol to read news about this stock. If user type in symbol that doesn t exist, system will tell user Error: Symbol not found.

User can also review message related to this stock that post on Internet by clicking message.

User logout When user finishes all the transaction, just click logout this online stock exchange system. Logout , user will

REFERENCES
1. Cay S. Horstmann & Gary Cornell [1997], Core Java, Volume 1, Sun Microsystems Press 2. Cay S. Horstmann & Gary Cornell [1997], Core Java, Volume 2, Sun Microsystems Press 3. Ramez Elmasri & Shamkant B. Navathe [1994], Fundamentals of Database Systems, Second Edition, Addison-Wesley Publishing Company 4. W. Richard Stevens [1994], TCP/IP Illustrated, Volume 1, AddisonWelsey Publishing Company 5. Douglas E. Comer [1995], Internetworking with TCP/IP, Volume 1, Prentice-Hall, Inc. 6. Kay, A. (9/91). Computers, networks and education. Scientific American. pp. 138-148. 7. Brian Jepson, JAVA Database Programming, John Wiley & Sons, Inc., New York, 1997 8. JAVA Programming for the Internet, Ventana Communications Group, Inc., 1996

9.

Richard C. Leinecker and Ton Archer, Visual J++ Bible, IDG Books Worldwide, Inc., 1997

10.

Chairman Arthur Levitt, (1999). Plain Talk About On-line Investing. Pratik Patel, Java Database Program With JDBC. Coriolis Group Books, 1996

11.

12. 13.

Dave Raggett, (1999). HTML 4.01 Specification. Jason Hunter, Java Servlet programming. With William Crawford / Paperback / O'Reilly & Associates, Inc., 1999

14.

Alan R Williamson, Java Servlets: By Example. Paperback / Manning Publication company, 1999

You might also like