AlgoTraderAlgoTrader Documentation

Chapter 13. Forex Handling

13.1. Currency Handling
13.1.1. Futures
13.1.2. Forex
13.1.3. Currency Attribution
13.2. Forex-Hedging
13.2.1. Exchange vs. Margin Trading
13.2.2. FX Future

The System provides full Forex and Currency Exchange Management. FX Rates can be retrieved in real-time. All portfolio figures are calculated based on up-to-date FX-Rates.

FX conversion is provided through the MarketDataService. When subscribing for a non-portfolio currency instrument the system will automatically subscribe the Forex instrument necessary to convert the non-portfolio currency balance (e.g. realized PnL and market value) into the portfolio currency. In some cases multiple Forex / Currency Pairs (based on the same base and quote currency) are available in the system which are traded through different brokers / exchanges.

For those cases a special setting misc.defaultMarketAdapters defines the priority in which market adapters and exchanges are used. The default value is the following:


This is a comma separated list of preferred <exchange>:<adapterType>. Exchange code is taken from the database security.exchange_code value and adapter type is ch.algotrader.enumeration.AdapterType. Optional specific security pairs are also supported, using '@' symbol, e.g. 'BTCUSD@BITF:CNG'. When the platform needs to make a conversion for a given forex, it will iterate over this list and determine the first match. Match means all of the below:

To change the default settings the following property needs to be updated inside Alternatively the properties can be changed via Section 2.3, “VM Arguments”

# default exchanges/adapter types to use for market data. <SYMBOL>@<EXCHANGE_CODE>:<ADAPTER_TYPE>

For example, -Dmisc.defaultMarketAdapters=BTCUSD@BITF:CNG,BITF:BFX means that for BTCUSD conversions Bitmex via Coinigy will be used, for all others direct Bitfinex connection will be used (assuming both Coinigy and Bitfinex adapters are running).

In most cases securities are attributed in their currency (as defined by Security). Their market value is attributed towards Market Value.

There are however the following exceptions.

The system provides automatic Forex-Hedging by the Service ch.algotrader.service.ForexService. This service will maintain multiple FX Positions to hedge all non base currency balances. For actual Forex-Hedging the following two options exist