Skip to content

FX (Foreign Exchange) prediction pipeline that forecasts the next‑day EUR/USD exchange rate using real historical market data and industry‑standard technical indicators

Notifications You must be signed in to change notification settings

mitrapinaki/fx_rate_prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

FX Prediction Pipeline (MA, RSI, MACD + ML Pipeline)

This project builds a complete FX (Foreign Exchange) prediction pipeline that forecasts the next‑day EUR/USD exchange rate using real historical market data and industry‑standard technical indicators. Historical FX prices are retrieved from the Frankfurter API, a free and reliable data source requiring no API key. The dataset is enriched with widely used quantitative finance indicators—including Moving Averages (MA5, MA10), Relative Strength Index (RSI‑14), and MACD with Signal Line—along with lagged price features that capture short‑term market momentum.

All preprocessing, feature scaling, and model training are handled through a clean scikit‑learn Pipeline, ensuring a production‑ready workflow. A Linear Regression model is trained to predict the next‑day closing rate, providing a simple but effective baseline for FX forecasting. This project demonstrates how machine learning can be applied to real‑world financial time‑series problems and serves as a foundation for more advanced models such as Random Forests, XGBoost, or LSTM neural networks.

Overview This project demonstrates a real‑world FX (Foreign Exchange) prediction pipeline using:

Free historical FX data from the Frankfurter API

Technical indicators widely used in quantitative finance

scikit‑learn Pipelines for clean, production‑ready ML workflows

Linear Regression for next‑day EUR/USD forecasting

This is a practical, industry‑aligned example of how ML is applied in FX trading, risk management, and quantitative research.

Features ✔ Free FX data (no API key required) Using Frankfurter API:

Historical EUR/USD prices

JSON format

Reliable and stable

✔ Technical Indicators Included MA5 (5‑day moving average)

MA10 (10‑day moving average)

RSI14 (Relative Strength Index, 14‑period)

MACD (12–26 EMA difference)

Signal line (9‑period EMA of MACD)

Lag features (lag1, lag2, lag3)

✔ ML Pipeline ColumnTransformer

StandardScaler

LinearRegression

Clean, modular, production‑style design

✔ Predicts Next‑day EUR/USD closing rate

📦 Installation

  1. Create a virtual environment

python3 -m venv venv source venv/bin/activate 2. Install dependencies

pip install pandas numpy scikit-learn requests (Optional)

pip install matplotlib ▶️ Running the Script Run the FX prediction pipeline: python fx_rate_prediction.py

You will see: API status Sample of downloaded data Model R² score

Predicted next‑day EUR/USD rate

📂 Project Structure Code fx_prediction_pipeline/ │ ├── fx_rate_prediction.py. # Main FX prediction pipeline ├── README.md # Project documentation └── venv/ # Virtual environment (optional) 🧠 How It Works

  1. Download FX Data Using Frankfurter API:

Code https://api.frankfurter.app/2023-01-01..2023-12-31?from=EUR&to=USD 2. Build Technical Indicators Moving averages smooth price trends

RSI measures momentum

MACD captures trend reversals

Lag features capture short‑term autocorrelation

  1. Build ML Pipeline Scale numeric features

Train Linear Regression

Predict next‑day price

  1. Evaluate Model R² score

Prediction output

📊 Example Output Code Status: 200 Preview: {"amount":1,"base":"EUR","start_date":"2023-01-01", ... }

Predicted next-day EUR/USD: 1.0873 Model R² score: 0.82

About

FX (Foreign Exchange) prediction pipeline that forecasts the next‑day EUR/USD exchange rate using real historical market data and industry‑standard technical indicators

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages