Skip to content
All library documents

Building a Realistic Forex Trading System and Handling Decimal Arithmetic

Article QuantStart

Summary

The diary entry describes an early event-driven forex system and its roadmap toward more realistic trading and backtesting. It identifies components already present, including price streaming, signal generation, order execution, local portfolio replication, long and short positions, and unit-tested position calculations. It also lists major gaps: slippage, support for more account currencies and pairs, risk controls, historical tick data, deployment resilience, monitoring, and broker integration. The emphasis is on modeling operational details and transaction costs so simulated results better reflect live trading.

A technical section explains why currency calculations should avoid binary floating-point values, which can introduce rounding errors. It demonstrates using decimal arithmetic constructed from strings and consistent quantization for pip and profit calculations, with a reminder to use suitable decimal database types. The system is described as alpha-stage and limited to a single account currency and pair, with naive execution and unresolved slippage; it is a development account, not evidence of a profitable strategy.

Key ideas

  • Realistic forex backtests should account for spreads, slippage, outages, and operational behavior.
  • Local portfolio replication can help compare internal calculations with broker account results.
  • Decimal arithmetic helps prevent accumulated rounding errors in currency calculations.
  • The described system is limited in currency and pair support and lacks several production controls.
  • Risk management, position sizing, historical data, monitoring, and robust deployment remain necessary extensions.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.