An advanced, foreign exchange (FX) forecasting system designed to integrate multi-source data ingestion, transformer-based predictive modeling, all while embedding rigorous risk and performance management. This project showcases a modular, production-grade approach to currency market modeling using modern deep learning and financial APIs.
- Project Overview
- Core Objectives
- Key Features
- System Architecture
- Usage Guidelines
- Demonstrative Code
- Development Roadmap
- Technical Resources
- Additional Notes
- Contact Information
This system is designed to forecast exchange rate changes 1, 3 and 5 days in advance (both direction and magnitude) for multiple currency pairs by combining historical FX data with global market features. It is architected to be modular, transparent, and future-proof:
- Data Management: Aggregates and transforms raw FX prices, cross-currency features, news sentiment, and macroeconomic indicators.
- Predictive Modeling: Dual-head transformer model that simultaneously predicts returns and price direction.
- Trading Execution: A configurable engine that interfaces with broker APIs to simulate or perform live currency trading.
Note: Certain proprietary model internals and trading heuristics are intentionally omitted to protect research integrity and strategic IP.
- Clean, align, and normalize FX and macroeconomic datasets.
- Engineer time-series features: RSI, volatility ratios, and cross-currency rolling correlations.
- Apply multi-currency context through feature engineering.
- Leverage a dual-headed transformer-based neural network architecture:
- Regression Head: Predicts the percentage price change for the next period.
- Classification Head: Predicts directional movement (up/down).
- Logging and health checks for all components (model, data, execution).
- Modular containers and system watchdogs to enable scalable deployment.
Robust ingestion and transformation of raw FX, sentiment, and macro data streams, including real-time updates and privacy-compliant storage.
Advanced deep learning using attention mechanisms to model temporal dependencies and extract meaningful trends across currencies.
Simultaneous outputs for regression (price change) and classification (directional movement), optimized via multi-task loss functions.
Detailed event logging, error reporting, and system-wide status tracking for transparent audit and debugging.
- Aggregates historical exchange rate data, news and other engineered features.
- Applies windows and sequence formatting for model input.
- Sensitive economic signal transformations are abstracted.
- Transformer encoder layers with learned and positional encodings.
- Final output consists of dual-task heads for volatility prediction and directional movement.
- Custom loggers for model outputs, errors, trades, and runtime alerts.
- Performance dashboards and usage audits enabled by lightweight observability tools.
Full implementation is confidential to protect intellectual property.
This repository is intended solely as a technical showcase for collaborators and recruiters. All core implementation code is private. Documentation provides a thorough outline of the project’s structure and methodologies.
- Review Only: No downloadable source code is included.
- Inquiries Welcome: Technical discussions around system design, methodology, or performance are welcome excluding proprietary logic.
This code shows the use of Ollama LLM's to classify article types and generate summaries for later use
def classify_and_summarize_with_ollama(url: str, text: str) -> Optional[Dict[str, str]]:
"""First pass: Classify and summarize (like original but with summary)."""
prompt = f"""
You are a financial news classifier specialized in foreign exchange (FX) trading.
Analyze this Bloomberg article and determine:
1. Event Type: Central Bank, Election, Trade Policy, Economy, Geopolitical, Financial Markets, Technology, ...
2. Market Impact: high (major market moving), medium (notable), low (minimal), none (no impact)
3. Summary: 2-3 sentences focusing on FX implications
Return EXACTLY in this format. DO NOT DEVIATE, EACH LINE MUST BE FILLED:
Type: [event_type]
Impact: [impact_level]
Summary: [2-3 sentences about the article contents]
Article URL: {url}
Content:
{text.strip()[:3000]}
"""
try:
cmd = ["ollama", "run", OLLAMA_MODEL, prompt]
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=90)
output = proc.stdout.strip()
{...}
The code below is part of the feature pipeline, here it is creating additional features pertaining to Brent crude oil prices which is am important indicator to exchange rates
# Basic oil features
oil_features['oil_price'] = oil_features['brent_crude']
# Oil price changes
oil_features['oil_change_1d'] = oil_features['brent_crude'].diff(1)
oil_features['oil_change_5d'] = oil_features['brent_crude'].diff(5)
oil_features['oil_pct_change_1d'] = oil_features['brent_crude'].pct_change(1)
oil_features['oil_pct_change_5d'] = oil_features['brent_crude'].pct_change(5)
# Oil moving averages
oil_features['oil_ma_10'] = oil_features['brent_crude'].rolling(10).mean()
oil_features['oil_ma_30'] = oil_features['brent_crude'].rolling(30).mean()
oil_features['oil_ma_ratio'] = oil_features['brent_crude'] / oil_features['oil_ma_30']
# Oil volatility
oil_features['oil_volatility_10d'] = oil_features['oil_pct_change_1d'].rolling(10).std()
oil_features['oil_volatility_30d'] = oil_features['oil_pct_change_1d'].rolling(30).std()
This snippit demonstrates train accuracy vs val accuracy and how early stopping is determined between epochs
# Calculate accuracies (quick approximation for direction task)
train_accuracy = self._calculate_accuracy(train_loader)
val_accuracy = self._calculate_accuracy(val_loader)
training_history['train_accuracy'].append(train_accuracy)
training_history['val_accuracy'].append(val_accuracy)
# Early stopping check
if val_loss < self.best_val_loss:
self.best_val_loss = val_loss
self.early_stopping_counter = 0
if save_best:
self.save_checkpoint(epoch, val_loss, is_best=True)
else:
self.early_stopping_counter += 1
-
Data Pipeline: Robust ingestion + engineered features.
-
Modeling: transformer & LSTM with training pipeline.
-
Predicting: Predict values 1 day in advance
-
Ensemble multiple transformer variants for robustness.
-
Multi day models for muti predictions