Stock Trading

Algorithm

June 2023

Select a version to view

Neural Network Stock Trading System

A learning-focused machine learning project built entirely from scratch — demonstrating my ability to design, optimize, and evaluate neural networks without relying on pre-built ML frameworks.

Project Overview

This project is a self-built neural network trading system that analyzes minute‑level stock data and attempts to generate buy/sell decisions. The focus of this project was not to build a profitable trading bot, but to fully understand how neural networks work at the lowest level — from matrix operations to training logic.

Why this project matters:

  • I implemented a complete neural network using only NumPy — no TensorFlow, PyTorch, or ML libraries.
  • I created a custom learning and evaluation strategy to optimize the model.
  • I simulated trading decisions and evaluated them with a performance metric I designed myself.
  • The project shows my ability to work independently, build complex systems, and quickly learn advanced ML concepts.

How the System Works

The model takes short windows of historical TSLA price data and outputs a probability for buying or selling. Instead of classical backpropagation, I used a simple evolutionary strategy, repeatedly adjusting the model’s weights and keeping the best-performing version.

Key Components

  • Custom Neural Network: Several fully connected layers coded manually.
  • Evolutionary Training: Small informed changes to the model, keeping better-performing generations.
  • Profit Index: My own scoring function to judge trading performance.

Simulation & Testing

I ran the model across historical 1‑minute TSLA data, simulating buy/sell decisions. The Profit Index rewarded:

  • Correct direction predictions
  • High-confidence decisions
  • Stable, repeatable performance over many data slices
The simulation results were not profitable — but they revealed how tiny weight changes influenced model behavior, and gave me hands‑on intuition about training dynamics.

Results

While the system did not produce a profitable trading strategy, it successfully demonstrated that:

  • I can independently design and implement a multi-layer neural network.
  • I understand how data preprocessing, weight initialization, activation functions, and output interpretation work under the hood.
  • I can build custom evaluation metrics and training loops without relying on existing tools.

What I Learned

This project provided deep, practical intuition about modern machine learning. Key learnings include:

  • How neural networks behave internally (beyond high-level libraries)
  • How to structurally debug ML models and interpret unstable learning behavior
  • The challenges of financial time‑series prediction
  • How to design experiments, evaluate performance, and iterate methodically
In short: This project wasn’t about creating the perfect trading bot — it was about building ML fundamentals from the ground up. It showcases my ability to tackle complex problems independently, understand the math behind machine learning, and apply these skills in practical scenarios.

Neural Network Stock Trading System

A learning-focused machine learning project built entirely from scratch — demonstrating my ability to design, optimize, and evaluate neural networks without relying on pre-built ML frameworks.

Project Overview

This project is a self-built neural network trading system that analyzes minute‑level stock data and attempts to generate buy/sell decisions. The focus of this project was not to build a profitable trading bot, but to fully understand how neural networks work at the lowest level — from matrix operations to training logic.

Why this project matters:

  • I implemented a complete neural network using only NumPy — no TensorFlow, PyTorch, or ML libraries.
  • I created a custom learning and evaluation strategy to optimize the model.
  • I simulated trading decisions and evaluated them with a performance metric I designed myself.
  • The project shows my ability to work independently, build complex systems, and quickly learn advanced ML concepts.

How the System Works

The model takes short windows of historical TSLA price data and outputs a probability for buying or selling. Instead of classical backpropagation, I used a simple evolutionary strategy, repeatedly adjusting the model’s weights and keeping the best-performing version.

Key Components

  • Custom Neural Network: Several fully connected layers coded manually.
  • Evolutionary Training: Small informed changes to the model, keeping better-performing generations.
  • Profit Index: My own scoring function to judge trading performance.

Architecture

Neural Network Diagram

Illustration of the multi-layer network used (simplified for visualization).

Simulation & Testing

I ran the model across historical 1‑minute TSLA data, simulating buy/sell decisions. The Profit Index rewarded:

  • Correct direction predictions
  • High-confidence decisions
  • Stable, repeatable performance over many data slices
The simulation results were not profitable — but they revealed how tiny weight changes influenced model behavior, and gave me hands‑on intuition about training dynamics.

Results

While the system did not produce a profitable trading strategy, it successfully demonstrated that:

  • I can independently design and implement a multi-layer neural network.
  • I understand how data preprocessing, weight initialization, activation functions, and output interpretation work under the hood.
  • I can build custom evaluation metrics and training loops without relying on existing tools.

What I Learned

This project provided deep, practical intuition about modern machine learning. Key learnings include:

  • How neural networks behave internally (beyond high-level libraries)
  • How to structurally debug ML models and interpret unstable learning behavior
  • The challenges of financial time‑series prediction
  • How to design experiments, evaluate performance, and iterate methodically
In short: This project wasn’t about creating the perfect trading bot — it was about building ML fundamentals from the ground up. It showcases my ability to tackle complex problems independently, understand the math behind machine learning, and apply these skills in practical scenarios.

Overview

This project explores how machine learning (ML) can be used to predict short-term stock price movements.

Inspired by a YouTube video on algorithmic trading, I decided to rebuild and improve a similar model from scratch in Python to better understand the fundamentals of Neural Networks.

The goal was not to create a profitable trading algorithm, but to learn the underlying mechanics of predictive financial modeling and backtesting.

How it works

1

Market Data
Tesla 1-min Price Data gets loaded

2

Neural Network
A neural network is trained to predict whether the next candle will be bullish or bearish

3

Trained Model
The model predicts a numeric value from -1 (100% SELL) to 1 (100% BUY) for the next candle

4

Backtesting
The model and its returns are tested in a trading simulation also made in python

Step 1

Loading Market Data

1-Minute TESLA stock data was downloaded from Yahoo Finance