---
title: "LSTM Gold from Scratch"
url: "https://ridwaanhall.com/projects/lstm-gold-from-scratch"
markdown: "https://ridwaanhall.com/projects/lstm-gold-from-scratch.md"
summary: "An LSTM written in pure NumPy that forecasts Indonesian gold prices from live data."
---

# LSTM Gold from Scratch

> An LSTM written in pure NumPy that forecasts Indonesian gold prices from live data.

- Category: Machine Learning
- Status: Completed
- Started: June 1, 2025
- Built with: Python, NumPy, Pandas, Matplotlib, LSTM, Machine Learning
- Source: https://github.com/ridwaanhall/LSTM-Gold-from-Scratch

## About

### The problem

Frameworks make LSTMs easy to use and hide how a cell, a layer and backpropagation through time actually work.

### The approach

I implemented the LSTM cell, layer and network myself in NumPy, with a data fetcher for the Pegadaian gold API, preprocessing with technical indicators, and a configurable YAML pipeline.

- Single-step and multi-step forecasting.
- Training, prediction and technical-analysis plots.
- Regression, trading and time-series metrics, and saving and loading of the full pipeline.

### The result

A learning project in the same spirit as Neural Network from Scratch, applied to gold prices.

## Features

- **Pure NumPy LSTM**: Cell, layer and network, without a framework.
- **Live Data**: Prices fetched from the Pegadaian gold API.
- **Multiple Forecast Modes**: Single-step and multi-step prediction.
- **Persistence**: Save and reload a trained model with its pipeline.

## Tags

lstm, numpy, Gold Price Prediction

## Elsewhere

- This page for people: https://ridwaanhall.com/projects/lstm-gold-from-scratch
- Index of every page as Markdown: [llms.txt](https://ridwaanhall.com/llms.txt)
