A data analytics pipeline using Apache Spark and Java to process historical stock data and rank investments based on Return on Investment (ROI) and volatility.

This university coursework project demonstrates a data processing pipeline for analyzing and ranking financial assets using Apache Spark. The application processes historical stock prices and company metadata to identify promising investment opportunities based on key performance indicators like Return on Investment (ROI) and volatility.
The core of the project is a Spark application that performs the following steps:
Data Ingestion: It reads two datasets:
stock_data.json) containing company information such as name, industry, sector, and Price-to-Earnings (P/E) ratio.all_prices-noHead.csv) containing daily stock prices (close price) for various tickers.Data Preprocessing:
2020-04-01 in the code).Feature Calculation: For each stock ticker, it calculates two key financial metrics:
Data Integration: The calculated metrics (returns and volatility) are joined with the asset metadata based on the stock ticker.
Investment Ranking: The application filters the assets based on predefined thresholds:
4.0.25.0.Output: The final ranked list of assets, along with their calculated features and metadata, is printed to the console and saved to a SPARK.DONE file in the results/ directory. This file also includes the application's start time, end time, and total execution duration.
Clone the Repository
git clone <repository-url>
cd bigdata/BigData-AE-2025-Template
Build the Project Use Maven to compile the source code and package it into a JAR file.
mvn clean package
This command will create a JAR file in the target/ directory (e.g., BigData-AE-2025-Template-0.0.1-SNAPSHOT.jar).
Run the Spark Application
You can submit the application to a local Spark instance using the spark-submit script.
spark-submit \
--class bigdata.app.AssessedExercise \
--master local[4] \
target/BigData-AE-2025-Template-0.0.1-SNAPSHOT.jar
The application's behavior can be customized using environment variables, which is useful for running it in different environments without changing the code.
SPARK_MASTER: Sets the Spark master URL. Defaults to local[4] for local execution.BIGDATA_PRICES: Specifies the absolute path to the stock prices CSV file. Defaults to resources/all_prices-noHead.csv.BIGDATA_ASSETS: Specifies the absolute path to the asset metadata JSON file. Defaults to resources/stock_data.json.BIGDATA_RESULTS: Specifies the directory path where the output file should be saved. Defaults to results/.Example with custom paths:
export BIGDATA_PRICES="/path/to/my/prices.csv"
export BIGDATA_ASSETS="/path/to/my/assets.json"
spark-submit \
--class bigdata.app.AssessedExercise \
--master local[4] \
target/BigData-AE-2025-Template-0.0.1-SNAPSHOT.jar
.
├── pom.xml # Maven build configuration
├── resources/ # Default data files
│ ├── all_prices-noHead.csv
│ └── stock_data.json
├── results/ # Default output directory
└── src/main/java/bigdata/
├── app/ # Main application logic
│ └── AssessedExercise.java
├── objects/ # Java objects (POJOs) for data modeling
├── technicalindicators/# Logic for calculating financial metrics
├── transformations/ # Custom Spark data transformation functions
└── util/ # Helper and utility functions
Stars
0
Forks
0
Watchers
1
Primary Language
Java