This project estimates the real-time interbank rate of the USD/TND currency pair in Tunisia by combining global currency fundamentals with local market liquidity effects. It was developed as part of the FIN460 β Dynamic Asset Pricing Theory course under the supervision of Dr. Eymen Errais.
To compute a continuously updating intrinsic value of USD/TND that reflects:
- π Global economic fundamentals (EUR/USD, GBP/USD, USD/JPY)
- π§ Local interbank market conditions (spread modeling)
The final model helps market participants evaluate whether offered quotes are fair or distorted due to short-term frictions.
The project is structured in three parts, each building toward a hybrid, real-time forecast engine.
Estimate weights ( w_1, w_2, w_3 ) in:
[ \text{USD/TND} = \text{Latest Fixing} \times (w_1 \cdot %\Delta\text{EUR/USD} + w_2 \cdot %\Delta\text{GBP/USD} + w_3 \cdot %\Delta\text{USD/JPY}) ]
- Data compilation from raw exchange sources
- Correlation analysis (Pearson): revealed expected signs (EUR & GBP: negative, JPY: positive)
- Feature engineering trials (e.g., EUR/GBP) β inconclusive
- Applied XGBoost regression (RΒ² = 0.98)
- Used SHAP to extract feature impact:
- ( w_1 = -0.15 ), ( w_2 = -0.12 ), ( w_3 = +0.13 )
- FX reserve-based macroeconomic weighting
- PCA (explained variance: 64%, 28%, 8%) β informative but not interpretable enough
Model the spread between the theoretical value and the interbank rate β driven by liquidity shocks and seasonality.
- Monthly spread boxplots revealed volatility clusters in months:
[January, February, May, June, September]
-
LSTM Model:
- Trained on rolling windows of 30 days of interbank rates
- Used for stable months:
[March, April, July, August, October, November, December] - Captures memory and autocorrelation in the FX market
-
OU-Jump Diffusion:
- Stochastic model with:
- Mean-reverting base
- Laplace-distributed jumps
- Parameters estimated using Maximum Likelihood Estimation (MLE)
- Models real-time spread in volatile periods
- Stochastic model with:
For each date:
- If month is stable β use LSTM
- If month is volatile β use Parametric model, only if:
|Parametric - LSTM| β€ 300 pips (0.03)- AND
|Forecast[t] - Forecast[t-1]| β€ 300 pips
Forecast_LSTMForecast_ParametricFinal_Forecastβ based on decision logic
Saved to: Forecast_By_Month_Resolved.xlsx
LSTM is a special type of Recurrent Neural Network (RNN) designed to capture long-term dependencies in sequential data. It's ideal for financial time series because it "remembers" patterns over time β such as cycles or delayed effects.
- Traditional RNNs suffer from vanishing gradients β they forget early time steps.
- LSTMs use gates (input, forget, output) to control memory flow and maintain information across time.
Let:
- ( x_t ): input at time ( t )
- ( h_t ): hidden state
- ( C_t ): cell state
The update equations:
[ \begin{aligned} f_t &= \sigma(W_f \cdot [h_{t-1}, x_t] + b_f) &\quad \text{(Forget gate)} \ i_t &= \sigma(W_i \cdot [h_{t-1}, x_t] + b_i) &\quad \text{(Input gate)} \ \tilde{C}t &= \tanh(W_C \cdot [h{t-1}, x_t] + b_C) &\quad \text{(Candidate)} \ C_t &= f_t \cdot C_{t-1} + i_t \cdot \tilde{C}t &\quad \text{(Cell update)} \ o_t &= \sigma(W_o \cdot [h{t-1}, x_t] + b_o) &\quad \text{(Output gate)} \ h_t &= o_t \cdot \tanh(C_t) &\quad \text{(New hidden state)} \ \end{aligned} ]
The OU Jump Diffusion model is a mean-reverting stochastic process that includes occasional jumps. Itβs well-suited to FX markets where the rate typically reverts to a fundamental level β but can "jump" due to liquidity shocks, policy events, or sudden demand shifts.
[ dX_t = \theta(\mu - X_t),dt + \sigma,dW_t + J_t,dN_t ]
Where:
- ( X_t ): the spread or price level
- ( \theta ): speed of mean reversion
- ( \mu ): long-term mean
- ( \sigma ): volatility
- ( dW_t ): Brownian motion (random noise)
- ( J_t ): jump size (Laplace-distributed)
- ( dN_t ): jump process (Poisson arrivals)
- Captures mean-reversion: price wants to return to ( \mu )
- Allows jumps: sudden, realistic shifts
- Ideal for modeling FX spreads with seasonality and shock behavior
SHAP explains predictions by computing the marginal contribution of each feature using a concept borrowed from cooperative game theory: Shapley values.
- Works with any black-box model (e.g., XGBoost)
- Assigns a fair contribution to each feature
- Visual, interpretable, and consistent
The SHAP value ( \phi_i ) for feature ( i ) is:
[ \phi_i = \sum_{S \subseteq F \setminus {i}} \frac{|S|! (|F| - |S| - 1)!}{|F|!} \left[ f(S \cup {i}) - f(S) \right] ]
Where:
- ( F ): full set of features
- ( S ): subset of features excluding ( i )
- ( f(S) ): model output using subset ( S )
SHAP was used to determine the relative impact of:
- ( %\Delta \text{EUR/USD} )
- ( %\Delta \text{GBP/USD} )
- ( %\Delta \text{USD/JPY} )
Resulting in:
- ( w_1 = -0.15 ), ( w_2 = -0.12 ), ( w_3 = +0.13 )
git clone https://github.com/<your-username>/DAPT_Project.git
cd DAPT_Project/Integratedpip install numpy pandas tensorflow scikit-learn scipy matplotlibpython forecast_model_runner.pyDAPT_Project/ βββ Project_Description/ # Data sources, PDF brief βββ Part_I/ # Basket weight estimation βββ Part_II/ # LSTM + stochastic spread modeling βββ Integrated/ # Final hybrid decision engine βββ docs/ # Architecture, diagrams βββ LICENSE.txt βββ README.md # This file
Aziz Jaidane
FIN460 β Dynamic Asset Pricing Theory @ Tunis Business School | UniversitΓ© de Tunis