Stock Trading Simulator

Desktop application for simulating real-time stock trading

A desktop trading simulation using sockets, JDBC, database views, and periodically refreshed prices. This course project is separate from TradeAI.

Overview

Stock Trading Simulator is a desktop application that simulates a real-time stock market and provides a stock trading experience. The project integrates a MySQL database with a Java desktop application; its main focus was using sockets for networking, JDBC, and Java Graphics.

Stock Trading Simulator dashboard with a price chart and holdings

Goals

Employ sockets, JDBC, and Graphics

On the client side, I used sockets for the client-server connection and Graphics to visualize the stock market. On the server side, I used JDBC for CRUD operations.

Development

Designing the relational database

I designed the relational schema before developing the application, after analysing the required CRUD operations and the data to store. Four tables were needed: users, transactions, stocks, and stock_history. I also created two views, user_assets and latest_stock_price, to keep queries simple during development.

Stock Trading Simulator schemaThe user_assets and latest_stock_price views

Developing the desktop application

With the required endpoints for CRUD operations defined, I built the server first, using JDBC to connect to a local MySQL database. To replicate real-time market dynamics, I integrated finnhub.io for stock data; while the server runs, the database's stock prices update every 10 seconds.

Then I built the client application: user authentication, buying and selling shares, and stock charts.

Retrospective

More stock options

Due to time constraints and the limits of finnhub.io's free tier, I could only offer a few stocks. With more time and resources, I would include a comprehensive range for a more robust simulation.

A first desktop application

It was my first desktop application, built in a one-month timeframe, and I delivered working features within it. I can't share the code and queries publicly due to the course's plagiarism policy.