Lazy loaded image
💻COMP1314 Assessments
Words 2189Read Time 6 min
Nov 23, 2025
Dec 15, 2025
type
status
date
slug
summary
tags
category
icon
password
💻
This statement is made in advance: This experiment was conducted on a MacBook Pro (chip: Apple M1 Pro) (macOS: 15.7.1 (24G231)). The system of this article is fully tested and run based on the Ubuntu 24.04.3 LTS system provided by multipass.
notion image
 
In order to find out who will be the most reserved asset in the future world, this report captures data on the recent price trends of Bitcoin, and draws 10 different diagrams accordingly. This experiment compares and analyzes the price fluctuation characteristics and investment value of Bitcoin by building an automated data collection and visualization system.

Stage 1: Environment preparation and Git initialization

Step 1: Install the necessary software

Jq is very useful in processing JSON data (such as Bitcoin price) returned by API.
Git is used for version control.
Gnuplot is used for plotting graphs.

Step 2: Create a project folder

Step 3: Initialize Git

notion image

Step 4: Set the ignore file (Security) to create .gitignore to prevent password leakage.

Paste the following content, and then press Ctrl+O (Save), Enter, Ctrl+X (Exit):
notion image

Stage 2: Database Settings (MySQL)

Create a database that conforms to 3NF (the third paradigm)
Download through the terminal command before create database
notion image
Here, I have to use another way to use database

Solution (if it is aarch64)

Since I am on Linux (Ubuntu), I don't need XAMPP. The package manager that comes with Linux installs Apache, MySQL and PHP, which is more stable and native than XAMPP.
Running the following command directly to replace XAMPP :
Step 1: Update the software source
Step 2: Install Apache, MySQL (MariaDB) and PHP
For Windows (WSL):
Try:
  1. Update ur system:
  1. Install Apache
  1. Run
  1. Test: Open in Windows web browser
  1. Install MySQL
  1. Run
  1. Set up the security configuration
  1. Install PHP
  1. Check version
  1. Let Apache identify php
  1. Create your PHP project directory in WSL
Apache default website path:
  1. Test
Then go ur web:

Step 5: Launch XAMPP

Step 6: Write an SQL script

 
notion image
notion image

Step 7: Git Commit #1

notion image

Stage 3: Data Collection

Step 8: Create a configuration file and isolate the password.

notion image

Step 9: Write a scraping script (tracker.sh)

Step 10 : Testing:

notion image

Step 11: Git Commit #2

notion image

Stage 4: Automated Tasks (Crontab)

Step 12: Set scheduled task

Add new line at the end of the file, run the file each 6 hours automatically.

Step 13: Update the document #3

notion image

Stage 5 : Drawing Script (GNU Plot)

Step 14: Write drawing scripts (plot_graph.sh)

 

Step 15: Testing

notion image

Step 16: Git Commit #4

notion image
 
notion image
 
 
🫂
How to view the images in localhost

Use Python to Open a Temporary Web Page

As long as your virtual machine and your computer are on the same network
  1. Find the Virtual Machine's IP Address:
Find an address similar to 192.168.x.x or 10.0.2.15.
  1. Start the Temporary Server:
  1. Download on the Real Device:
Go back to your Windows/Mac browser and enter:
For example, for mine is:
  1. Close the Server:
Press Ctrl + C in the virtual machine terminal to stop.
notion image

Some graphs you need to know

This graph records what we really need
notion image
This graph shows my folder
notion image
This file records the time and price
notion image
This file allows me to track the price and draw the image every 12 h.
notion image

Git commands

ERD Graph:

notion image

Tables In MySQL:

SHOW DATABASES;
notion image
USE crypto_tracker;
notion image

Two tables:

SELECT * FROM currencies;
notion image
SELECT * FROM price_history;
notion image
💻
Transfer the file from My mac to multipass ubuntu

README.md

Crypto Price Tracker

A comprehensive cryptocurrency price tracking system that automatically collects, stores, analyzes, and visualizes price data from various sources.

Features

  • Automated Data Collection: Fetches cryptocurrency price data from APIs at regular intervals
  • Database Storage: Stores price history with MySQL database including current, high, and low prices
  • Data Cleaning: Removes duplicate entries and validates data integrity
  • Visualization: Generates 10 different charts and graphs for price analysis
  • Error Handling: Robust retry mechanisms and comprehensive error reporting
  • Scheduled Execution: Automated execution via cron jobs

Project Structure

Prerequisites

  • MySQL/MariaDB server
  • Required tools: curl, jq, gnuplot
  • Bash shell environment

Installation

  1. Set up the database:
    1. Create configuration file: Create config.env with your database and API settings:
      1. Install required tools:

        Usage

        Manual Execution

        1. Collect price data:
          1. Clean the data:
            1. Generate charts:

              Automated Execution

              Set up cron jobs for automated execution:
              Add the following lines (adjust paths as needed):
              This will:
              • Run the tracker every hour at minute 0
              • Generate charts every hour at minute 5

              Data Analysis

              The system provides multiple analysis views:
              • Hourly Statistics: Average prices per hour
              • Daily Statistics: Daily averages, maximums, minimums, and counts
              • Weekly Statistics: Weekly average prices
              • Recent Trends: Latest 30 data points
              • Price Distribution: Histogram analysis
              • Combined Trends: Multi-timeframe comparisons

              Generated Charts

              The system automatically generates various chart types:
              1. Hourly Average Price Trend
              1. Daily Average Price
              1. Weekly Average Price
              1. Combined Trend Analysis
              1. Full Price History
              1. Price Distribution Histogram
              1. Daily Maximum Prices
              1. Daily Minimum Prices
              1. Records Per Day
              1. Recent 30 Price Points

              Error Handling

              The system includes comprehensive error handling:
              • Retry Mechanism: Automatic retries for failed API calls (up to 3 attempts)
              • Data Validation: Validates timestamp and price formats
              • Backup Creation: Automatic backups before data cleaning
              • Logging: Detailed logs for troubleshooting

              Configuration

              Database Configuration

              Edit config.env:

              API Configuration

              Set your preferred cryptocurrency API endpoint:

              Troubleshooting

              Common Issues

              1. Permission Denied: Ensure scripts have execute permissions
                1. Database Connection Error: Verify MySQL credentials and service status
                  1. Missing Dependencies: Install required tools
                    1. Empty Data Files: Check API connectivity and log files

                      Data Backup

                      The system automatically creates backups before data cleaning:
                      • Backup files are stored in backup/ directory
                      • Filename format: my_data_backup_YYYYMMDD_HHMMSS.txt
                      • Manual backup: cp data/my_data.txt backup/my_data_backup_$(date +%Y%m%d_%H%M%S).txt

                      License

                      This project is part of COMP1314 coursework.
                       
                      上一篇
                      Mastering Inputs and Outputs: Two Raspberry Pi Projects with Explorer HAT Pro
                      下一篇
                      About This Blog

                      Comments
                      Loading...