← All projects

Deep-Learning Signal Server for Gold and FX

Dual-branch Temporal Convolutional Network trained on price and macro features, served live through FastAPI with incremental indicators and a cTrader bot client.

Client
Gold-trading client
Year
2025
Category
Quant & ML
Stack
  • Python
  • PyTorch
  • TensorFlow/Keras
  • ONNX
  • DirectML
  • FastAPI
  • SQLite
  • cTrader
  • C#
  • Google Colab

The problem

The client wanted a neural model that trades gold from live data, not a notebook that only works on history. The hard part was making the live features match the training features exactly, bar by bar, including macro data that is published late and revised.

What I built

  • Model: a dual-branch TCN. One branch reads a long window of bars, the other a short window, and the two are combined for the prediction. The first version had about 4.3M parameters and three classes (buy, sell, no trade).
  • Training data: a pipeline that merges OHLCV, dozens of indicators and FRED macro series (inflation, rates, yield curve) into a training set stored in SQLite. It was trained on cloud TPUs and GPUs.
  • Live server: FastAPI with endpoints to submit candles, get predictions, check health and view a dashboard. Indicators are updated incrementally in O(1) per bar instead of recomputed over the full history.
  • Parity tests: scripts that compare real-time features against batch-computed and database values, bar for bar, to catch train/live drift.
  • cTrader integration: a C# cBot that streams candles to the server and trades on the returned signal.
  • Higher-timeframe version: a lighter binary model that predicts the next 1-hour candle from stationary features only. Entry is timed on the 1-minute chart, and stops and targets come from ATR.
  • Deployment: one server per instrument (gold and GBPUSD) with its own model and scaler. ONNX on the GPU via DirectML, with a Keras CPU fallback.

Details

The second version dropped raw price features. Gold’s long trend made raw prices, EMAs and ATR drift between training and test periods. Returns, percentage deviations, bounded oscillators and normalized macro data fixed that.