CASE STUDY / FX CALCULATOR

FX Calculator: risk-based position sizing.

FX Calculator is a web and Android app built by Thomas Petrou for calculating position sizes across forex and CFDs. It connects account risk, instrument specifications and trade prices in a focused workflow, with manual entry, text imports and Android screenshot recognition.

Reviewed October 2026
FX Calculator in dark mode showing account risk settings and manual trade entry.
FX Calculator in dark mode showing account risk settings and manual trade entry. Source code and documentation on GitHub ↗
01

The challenge: connect trade prices to account risk

Position sizing depends on more than an entry price and a stop loss. The calculation must also account for balance, risk percentage, instrument rules and currency conversion.

FX Calculator brings these inputs together for forex, metals, indices, commodities, crypto CFDs and equity CFDs. Users can enter a trade manually or import a signal, review the detected values and calculate explicitly.

The interface separates the trade draft from the result. This gives users a chance to correct prices, instrument and direction before calculating lots, stop and target distances, reward-to-risk ratio and actual risk after volume rounding.

02

The approach: a typed engine shared by web and Android

A pure TypeScript calculation engine keeps parsing, validation, instrument rules and sizing independent of React and native platform APIs.

The React interface provides manual entry, searchable instruments, account settings and light or dark themes. Capacitor packages the same workflow for Android, while a Java plugin uses bundled Google ML Kit text recognition to extract signals from screenshots.

Manual trades and imports share one calculation boundary. Platform adapters isolate storage, exchange-rate requests and screenshot recognition, so calculation behaviour can be tested without a browser or Android device.

The bundled instrument catalog includes canonical symbols, aliases, contract sizes and price precision. USD and EUR account settings support conversion and instrument-specific overrides. Exchange-rate requests include timeout handling, caching and rate provenance.

03

What was built: a complete position sizing workflow

The app combines trade entry, risk calculations, editable imports and local history in a responsive interface.

Users can copy calculated values for a trading platform. Copying also saves the trade locally, making previous calculations available in history. Screenshot recognition is available on Android; manual entry and pasted-text imports work in the browser.

The repository documents usage, architecture, calculation rules, privacy and development. Automated checks cover the domain calculations, parsing, catalog projection, conversion failures, overrides, restored drafts, history and user workflows.

  • React and TypeScript web interface
  • Capacitor Android application
  • Risk-based lot sizing and reward-to-risk calculations
  • Pasted-text signal imports and Android screenshot OCR
  • Local settings, copied trade history and themes
  • Documented calculation rules and automated verification
04

Calculation scope and engineering lessons

FX Calculator calculates trade parameters; it does not connect to a broker or execute orders.

The instrument catalog is a dated snapshot rather than a live broker feed. Users need to verify broker specifications and configure overrides where appropriate. Calculations do not model commissions, spread, slippage, swaps or margin requirements; exchange rates are reference conversion inputs rather than streaming quotes.

The project demonstrates how a clear domain boundary can support a responsive web app and native Android capabilities together. Validation, conversion failures and volume rounding remain explicit, while the interface guides users through review, calculation and copying.

Relevant capabilityAppsNext projectDJNote

05 / LET’S MAKE IT REAL

Have a project in mind?

Share the idea, the problem, or the process you want to improve. You will receive a practical reply about scope, priorities, and a sensible first version.

Email Thomas