{"slug": "financial-market-analysis-double-tower-transformer", "title": "Financial Market Analysis (Double-Tower Transformer)", "summary": "A developer built a Double-Tower Gated Transformer Network (GTN) to generate profitable trading signals from high-frequency EUR/USD forex data. The system uses a custom cost matrix and weighted cross-entropy loss to combat class imbalance, and optimizes for raw profitability under real-world MetaTrader 5 constraints. Despite overfitting on a single batch, the model underfitted when scaled to one epoch with maximum parameters on an A100 GPU.", "body_md": "A predictive machine learning system explicitly designed to generate profitable trading signals from high-frequency (1-minute) EUR/USD forex data. The flagship focus of this repository is a custom Double-Tower Gated Transformer Network (GTN) built to predict Take Profit / Stop Loss (TP/SL) strikes.\n\nThe data pipeline processes 1-minute OHLC bars to map out realistic TP/SL bounds over a 24-hour lookahead rather than using fixed time horizons.\n\nThe core model, the **Gated Transformer Network (GTN)**, utilizes a dual-tower architecture that separates feature interactions from temporal sequences. It replaces traditional sinusoidal encodings with learned time embeddings to capture market regime shifts and session overlaps (London, NY, Tokyo).\n\nTo combat severe class imbalance (the model's tendency to constantly predict \"keep/hold\"), the network optimizes against a custom cost matrix and weighted cross-entropy loss.\n\n![[Pasted image 20260710145647.png]]\n\nInstead of optimizing for standard classification accuracy, the pipeline tackles raw profitability. The intent is for models to learn the structural mechanics of price action, balancing Risk/Reward ratios (e.g., 1:2) against real-world MetaTrader 5 execution constraints (enforcing next-candle open entries and proper UTF-16-LE signal formatting).\n\n`(buy_precision + sell_precision)/2 - 0.25 * |buy_precision - sell_precision|`\n\nfind out why despite everything we underfitted?\n\nI did manage to overfit on a single batch of data; however, based on the scaling laws paper, I tried to do 1 epoch with proportionate maximum parameters that I can efficiently fit into the 80GB VRAM of an A100 GPU or 2*40GB VRAM of A100 depending of availability.\n\nreference paper: [https://arxiv.org/pdf/2103.14438](https://arxiv.org/pdf/2103.14438)\n\nGated Transformer Networks for Multivariate Time Series Classification", "url": "https://wpnews.pro/news/financial-market-analysis-double-tower-transformer", "canonical_source": "https://dev.to/masihmoafi/financial-market-analysis-double-tower-transformer-2nih", "published_at": "2026-07-10 12:09:00+00:00", "updated_at": "2026-07-10 12:42:43.736636+00:00", "lang": "en", "topics": ["machine-learning", "neural-networks", "ai-research", "developer-tools"], "entities": ["Gated Transformer Network", "EUR/USD", "MetaTrader 5", "A100 GPU"], "alternates": {"html": "https://wpnews.pro/news/financial-market-analysis-double-tower-transformer", "markdown": "https://wpnews.pro/news/financial-market-analysis-double-tower-transformer.md", "text": "https://wpnews.pro/news/financial-market-analysis-double-tower-transformer.txt", "jsonld": "https://wpnews.pro/news/financial-market-analysis-double-tower-transformer.jsonld"}}