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
- 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
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
- 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
- Build ML Pipeline Scale numeric features
Train Linear Regression
Predict next‑day price
- 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