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.
- 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:
MinMaxnormalization, 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.
- 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.
The project follows a standard Data Science workflow:
- Data Mining: Acquisition of historical data (2023-Present) via REST API.
- Data Wrangling: Date parsing (es-PE localization), gap filling, and transformation into 3D tensors
(Samples, Time Steps, Features). - Modeling: Training the LSTM network with a 60-day Look-back period.
- Validation: Chronological split (Train/Test) to prevent Data Leakage.
- Forecasting: Recursive projection with historical volatility injection.
The model achieves competitive performance metrics on the test set, demonstrating the capability to follow the general trend of the Peruvian exchange market.
-
Clone the repository:
git clone https://github.com/MarcOBL012/Forex-Peru-LSTM-Predictor-Deep-Learning-Exchange-Rate-Model.git
-
Install dependencies:
pip install tensorflow pandas numpy scikit-learn matplotlib requests
-
Run the Notebook or Script: Open
SBS_LSTM.ipynbin Jupyter Notebook or VS Code and execute the cells in order.
Marco Antonio Obispo Lopez
- Student at National University of Engineering (UNI)