WIA1002 Data Structure Group Assignment

Topic 5: Wall Street Warriors
Occurrence: 5 (Group 6)

Project Description

This project is a stock trading application that fetches real-time stock data using Yahoo Finance API and provides a user-friendly interface for users to view and trade stocks. It utilizes data structures and algorithms to efficiently manage the stock listing, prioritize orders, and implement trading rules.

Getting Started

To run the stock trading application locally, follow these steps:

Server

  1. Obtain your own API key from https://rapidapi.com/sparior/api/yahoo-finance15 (for real time stock data) and https://www.marketaux.com/news/country/my (for latest news)
  2. Obtain your own email and app password (for email notification)
    by following this guide https://youtu.be/ugIUObNHZdo [3:00-3:40]
  3. Create an .env file in stocktrading-app/src/main/resources
  API_KEY="xxxxxxxxxxx"  
  API_BASE_URL="https://yahoo-finance15.p.rapidapi.com/api/yahoo/qu/quote/"

  NEWS_API_TOKEN="xxxxxxxxxxx"
  NEWS_API_BASE_URL="https://api.marketaux.com/v1/news/all"

  EMAIL_USERNAME="xxxxxx@gmail.com"
  EMAIL_PASSWORD="xxxxxxxxxxxxxxxx"
  1. Run StockTradingApplication.java
  2. Access the application in your web browser at http://localhost:8080.

Database

  1. View the guide here to install sqlite3 and setup the database.

Client

  1. Install Node.js
  2. Open terminal
  cd client
  cd stock-trading-client
  npm start

if there is an error (below), run npm install react-scripts --save and try again

  'react-scripts' is not recognized as an internal or external command, operable program or batch file.
  1. Access the application in your web browser at http://localhost:3000.
  2. Extensions for VSCode:
    • ES7+ React/Redux/React-Native snippets (ID: dsznajder.es7-react-js-snippets)

Usage

  • Visit http://localhost:8080 to view the stock trading application (server)
  • Visit http://localhost:3000 to view the stock trading application (client)

Project Structure

The project follows a standard directory structure that helps organize the source code and resources. Here's an overview of the project structure (server):

stocktrading-app
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── stocktrading
│   │   │           └── stocktradingapp
│   │   │               ├── config
│   │   │               ├── controller
│   │   │               ├── model
│   │   │               ├── service
│   │   │               └── StockTradingApplication.java
│   │   └── resources
│   │       ├── static
│   │       ├── templates
│   │       └── application.properties
│   │           
│   └── test
│       └── java
│           └── com
│               └── stocktrading
│                   └── stocktradingapp
│                       └── StockTradingApplicationTests.java
├── pom.xml
└── .gitignore
  • src: Contains the main source code and resources of the project.

    • main: Directory for the main source code.

      • java: Directory for the Java source code.

        • com.stocktrading.stocktradingapp: Package directory that follows the Java package naming convention.

          • controller: Contains the controllers responsible for handling HTTP requests and defining API endpoints.

          • model: Contains the model classes that represent the entities in the application, such as Stock.

          • service: Contains the service classes that implement the business logic and interact with external APIs.

          • StockTradingApplication.java: Main entry point of the application.

      • resources: Directory for additional resources used by the application.

        • static: Directory for storing static files such as CSS, JavaScript, and images.

        • templates: Directory for storing templates used by the application.

        • application.properties: Configuration file for the application.

  • test: Contains the test code for the project.

    • java: Directory for test code written in Java.

      • com.stocktrading.stocktradingapp: Package directory that mirrors the main source code structure.

        • StockTradingApplicationTests.java: Test class(es) for testing the application's functionality.
  • pom.xml: Maven Project Object Model file that defines project dependencies, build configuration, and plugins.

  • .gitignore: Specifies which files and directories should be ignored by version control.