Skip to content

MarcOBL012/Forex-Peru-LSTM-Predictor-Deep-Learning-Exchange-Rate-Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Forex Peru LSTM: Exchange Rate Prediction with Deep Learning

Python TensorFlow Status

This project implements a Recurrent Neural Network (RNN) using LSTM (Long Short-Term Memory) architecture to model and predict the exchange rate behavior (Buy/Sell) of the Peruvian Sol (PEN) against the US Dollar (USD).

Unlike traditional linear models, this system leverages Deep Learning to capture complex temporal patterns and applies Monte Carlo Simulations to project future scenarios with stochastic uncertainty.

🚀 Key Features

  • Automated Data Extraction: Direct connection to the BCRP API (Central Reserve Bank of Peru) to fetch official historical series instantly, eliminating slow web scraping.
  • Intelligent Preprocessing: MinMax normalization, handling of non-business days (Forward Fill), and time-window structuring (Sliding Windows).
  • LSTM Architecture: Multi-layer model with regularization (Dropout) to prevent overfitting.
  • Stochastic Forecasting: Generation of 30-day future scenarios using recursive prediction and statistical noise (Monte Carlo) to visualize market volatility.

🛠️ Tech Stack

  • Python 3.10 +
  • TensorFlow / Keras: Neural network construction and training.
  • Scikit-Learn: Evaluation metrics (RMSE, MAE, R2) and data scaling.
  • Pandas & NumPy: Financial time series manipulation.
  • Matplotlib: Visualization of predictions and stochastic scenarios.

📊 Methodology

The project follows a standard Data Science workflow:

  1. Data Mining: Acquisition of historical data (2023-Present) via REST API.
  2. Data Wrangling: Date parsing (es-PE localization), gap filling, and transformation into 3D tensors (Samples, Time Steps, Features).
  3. Modeling: Training the LSTM network with a 60-day Look-back period.
  4. Validation: Chronological split (Train/Test) to prevent Data Leakage.
  5. Forecasting: Recursive projection with historical volatility injection.

📈 Results

image image

The model achieves competitive performance metrics on the test set, demonstrating the capability to follow the general trend of the Peruvian exchange market.

💻 Installation & Usage

  1. Clone the repository:

    git clone https://github.com/MarcOBL012/Forex-Peru-LSTM-Predictor-Deep-Learning-Exchange-Rate-Model.git
  2. Install dependencies:

    pip install tensorflow pandas numpy scikit-learn matplotlib requests
  3. Run the Notebook or Script: Open SBS_LSTM.ipynb in Jupyter Notebook or VS Code and execute the cells in order.

👤 Author

Marco Antonio Obispo Lopez

  • Student at National University of Engineering (UNI)

About

A Deep Learning model utilizing LSTM networks and Monte Carlo simulations to forecast the Peruvian Sol (PEN) exchange rate using official BCRP data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors