RightEdge - The Ultimate Backtesting and Trading System Development Platform

Trade in Different Currencies

RightEdge supports trading in different currencies. This includes directly trading the foreign exchange market (Forex), as well as trading other instruments (stocks, options, futures, etc) that are traded in different currencies.

Currency Overview

Your account currency is the currency of your initial trading capital, the cash balance of your broker account, and what the profits or losses from trading eventually get converted to. Margins and trading commissions are also all in the account currency. It can be configured in the RightEdge options.

The currency that an instrument is traded in is called the asset currency. The asset currency can be set when the symbol is added to the watch list, or modified in the Symbol Information dialog for an existing symbol. If the asset currency is different from the account currency, then when a trade is filled, the price of the symbol or the profit or loss of the trade will be converted from the symbol's asset currency to the account currency. This is described in more detail below.

Forex symbols are expressed as a currency pair, such as EUR/USD. To add a Forex symbol to the watch list, set the asset type to Forex, and specify the name in the format XXX/YYY. The first currency is known as the base currency, and the second currency is known as the counter currency. The price quoted for a Forex symbol is the price of the base currency in terms of the counter currency. So if the price of EUR/USD is 1.2, then one EUR can be bought with 1.2 USD. Opening a Forex position can be represented as buying one currency and selling (or shorting) the other. A long position corresponds to buying the base and selling the counter currency.

Exchange rates

Whenever you trade an instrument with an asset currency which is different from your account currency, RightEdge needs to know the exchange rate between the two currencies. In addition to letting you trade Forex symbols directly, RightEdge uses Forex data as the source for the exchange rates. To provide this data to RightEdge, for each asset currency you will use, set up a Forex symbol in the watch list for that currency and the account currency. Then import or download historical data for that Forex symbol. The data should start before the trade start date you will use in your system, so that the exchange rate data is available when the system starts trading.

If the exchange rate is not available when it is needed for a fill, you will get an error with a message similar to "Could not convert from JPY to USD for date 1/1/2013 11:08:00 PM". If you run into this, make sure you have the corresponding Forex symbol configured in your watch list, and that you have historical data for it available before the date and time specified.

How Profit and Loss are Calculated

For each fill, RightEdge keeps track of both the fill price in the symbol's asset currency, as well as the result of converting that price into the account currency. In your system code, you can access these values using the SymbolPrice and AccountPrice properties of the Price object. Which of these price values is used when calculating profit and loss depends on the asset class of the symbol and whether or not it has a margin value.

If the asset class is Forex, or if the asset class is Future, Option, or Futures Option and an Initial Margin is set (ie greater than zero), then the symbol price will be used to calculate the profit or loss in the symbol's asset currency. This amount will then be converted to the account currency using the current exchange rate. This means that the profit is not affected by exchange rate fluctuations while a position is open, but only by the exchange rate at the time it is closed.

If the asset class is Future, Option, or Futures Option and the Initial Margin is not set, or if the asset class is any other asset class besides Forex, then the account price will be used to calculate the profit or loss. This means that the exchange rate at the time of position entry and at the exit will both apply, and that the profit of the position will be affected if the exchange rate changes between the entry and exit.

Forex Interest

RightEdge can also simulate interest applied to open Forex positions. Since a Forex position is essentially being long one currency and short another currency, and the interest rates may vary between currency, brokers may pay interest on the "long" currency and charge interest on the "short" currency for open Forex positions. You can enable this with the "Apply Interest to open Forex Positions" setting in the RightEdge options, and you can also set the time of day that this interest is applied to open positions.  You will also need to set up symbols in the watch list with the asset type "Interest Rate" for each applicable currency, and supply data for those symbols.