- ago
Hello,

I recently discovered the Multi-currency setting for backtesting. This is exciting because I am hoping I can use it to evaluate my MetaStrategy more accurately.

It seems there is a problem for me with WL accessing the conversion rates. Do I need to ensure I have certain data or settings activated for this feature to work? Do some currency conversion rates come from different places or is there a single file/database that WL accesses for this setting?

I am hoping that this is the cause for the difficulties I have run into. I have had a couple of difficulties. First, I have found it greatly increases the processing time for strategies. This is of course expected, but I found in a couple of test cases, it decreased the speed by at least 1000x and made it unusable. I am hoping this is related to an error I was getting that I have attached a screenshot of below and pasted the Log message.

Second, I found no results (the adjustment for profit b/c of currency in every trade was zero) when using USDCHF. Again, I suspect that WL is not finding any data about the conversion rate.

Thanks,
Dandude

Log:
at WealthLab.Data.DataProviderBase.GetHistory(String symbol, HistoryScale scale, DateTime startDate, DateTime endDate, Int32 maxBars, DataRequestOptions cb)
at WealthLab.Data.HistoricalDataValet.ReadComposer(String asset, HistoryScale token, DateTime serv, DateTime ivk2, Int32 no__token3, IHistoryProvider var14, DataRequestOptions reference5)

0
623
Solved
25 Replies

Reply

Bookmark

Sort
- ago
#1
Here is the screenshot:

0
- ago
#2
Just as a note: I have encountered the same problem when using individual strategies, not just the MetaStrategy. And also with EURUSD. I suspect it is a data issue, I just am not clear where WL is going to get this data.
0
Cone8
 ( 5.68% )
- ago
#3
QUOTE:
It seems there is a problem for me with WL accessing the conversion rates.
There should be no problem if you have Wealth-Data selected. And, if it's at the top of the list of Historical Providers it should be fast.

QUOTE:
Do some currency conversion rates come from different places
It uses Historical Providers, Daily bars only.

QUOTE:
First, I have found it greatly increases the processing time for strategies.
Here's a secret: Multicurrency has always been running since build 36. The conversion just returns "1" when it's disabled.

The only reason I can think why it would cause slow down when you enable it is due to searching for currency data that your configuration seems to have trouble providing.

QUOTE:
Again, I suspect that WL is not finding any data about the conversion rate.
I think you're right. What happens when you request a Daily chart for USDCHF?

(IQFeed cannot help you with that symbol... it would be USDCHF.COMP or USDCHF.FXCM with a forex subscription)
0
Best Answer
- ago
#4
So I did not have wealth-data checked. When I tried to open the USDCHF chart, it said it could not find the data. However, once I checked wealth-data, the chart populated. I am guessing this will solve my problem.

Thanks Cone!!
1
Glitch8
 ( 10.97% )
- ago
#5
Definitely, the multi-currency feature depends on WealthData for the historical currency data.
0
- ago
#6
I think I discovered another problem

I am still getting no change in results, but I think I know why. I unchecked the "futures mode" selection under the backtest settings and the backtest went from giving me "0" for every Fx Gain(USD), to actually calculating it.

Unfortunately this seems to mean that I will be unable to apply this setting when testing futures unless there is a workaround or setting I am missing.

There is no longer any error in the log viewer, however.

Specifically I am trying to trade the @CNH#C futures which are denominated in CNY.

There are some other foreign futures I am trying to test such as the @NIY#C, DXS#C, EX#C, LF#C, SS#C, SW#C, and XG#C.

0
Cone8
 ( 5.68% )
- ago
#7
What currencies are assigned to your contracts in Markets and Symbols?
Which currency did you select as your Multi-Currency Base Curr.
0
- ago
#8
I have set the currencies for the futures contracts, @CNH## is set to CNY, for example.

My base currency is set to USD.
0
Cone8
 ( 5.68% )
- ago
#9
You're telling me that you're using a contract whose currency is sort of pegged to the USD?
Of course it depends on your trade timeframes, but how much difference are you expecting?
Got a different example?
0
Cone8
 ( 5.68% )
- ago
#10
Maybe you're doing intraday trading/backtest?
That would explain it too.

The goal of the multi-currency backtest feature is two-fold: allows backtest results of instruments priced in different quote currencies (USD, EUR, AUD, BTC, etc) to be translated to a single base currency, while accounting for significant currency effects on non-base currency trades that span more than one day.
0
- ago
#11
I did switch the symbol to the XG#C priced in EUR and got the same result.

I did these tests with a daily strategy that holds for days/weeks/months.
0
Cone8
 ( 5.68% )
- ago
#12
Okay, I see it. Something's wrong with the "Fx Gain" column for futures. We can fix that, thanks.

However, the Multi-Currency results are correct and shown for in the Base currency everywhere else - Metrics Report, Equity Curve, By Symbol.. etc.
0
Cone8
 ( 5.68% )
- ago
#13
Sorry I didn't recall this right away, but trading futures is different. Unlike stocks, a currency exchange from a base to a trade currency is not required (or performed) to satisfy futures margin. The Forex effect is noticed only in the difference between the value of the contract at the beginning and end of the trade. That's why the Fx Gain column is zero for futures.

.. and I just checked - the mechanics of this is explained in the Help for the topic on the Multi-Currency Preference.
0
- ago
#14
Are you sure this is the case? When I use IB and I "check margin", it shows the value of the trade in the native currency, and not in USD. It is true there are many futures contracts like the @EU and @JY that trade the USDJPY or USDEUR but are quoted and traded only in USD, but for some other contracts that is not the case, as in the example of @CNH or XG and a few others.
0
Cone8
 ( 5.68% )
- ago
#15
You're right, but I said, "a currency exchange from a base to a trade currency is not required (or performed) to satisfy futures margin."
If I'm wrong by an experience you've had or other documentation, let me know.

Let's be clear. What we're talking is futures margin required to trade a contract in a different currency. You don't need to hold that cash in a foreign currency to do the trade.

Example:
Assume you have a $100K margin account in USD, and you are 100% invested in US stocks, 0 cash. The margin required to trade a DAX contract is €30K.

Your assumption in this scenario is that you need to deposit 30K EUR. Since you cannot have a negative currency balance, that could only occur by selling sufficient USD stock to later buy 30K EUR.

What actually happens is that there is a dynamic margin calculation that's running. A margin call or forced sale would only occur if your account didn't maintain the overnight/maintenance margin required (calculated with currency effect) in EUR.

Again, remember that we're only talking about the futures margin required to make the trade. The currency effect of trade gains is shown each day in the equity curve.
0
- ago
#16
Thank you for this detailed explanation Cone! I don't think I understood that function of trading some of these futures contracts that seem to transact in foreign currencies.

I will have to actually make a couple of trades with one of these contracts to see how it works exactly, but I suspect you are correct.

If you are correct, it is very good news for a strategy I discovered with a 10.0 Recovery Factor! I figured it was too good to be true and when I discovered this multi-currency feature, I assumed that that might be why the strategy seems to look so good but wouldn't actually perform that well.
1
- ago
#17
Hey Cone,

OK so I traded one CNH contract and now my IB account shows a negative balance in CNH, which is also my P/L. Since my P/L will ultimately be in the CNH currency, wouldn't WL need to do the conversion to determine the real backtest results? Or are you saying that this difference is already reflected in the contract price and therefore WL does not need to do the calculation?

Again, when I do a backtest, checking the multi-currency option does not change anything anywhere in the backtest results or positions that I can see.

Thanks,
Dandude
0
- ago
#18
Here is a screenshot

0
Cone8
 ( 5.68% )
- ago
#19
I did the trade too just now, and I have no idea where that small negative CNH currency value (-362 CNH for me, or about $50) comes from. There must be some exchange, overnight, third-party, or some other fee for trading a futures contract

What I can tell you is that it's not in the same universe as the margin required to trade the contract ($27,000) which is the part we're interested in.

Since you're motivated, let us know what you can find out from IB support about why, when trading a CNH CME contract in USD, small negative CNH balances end up in the account.
0
Glitch8
 ( 10.97% )
- ago
#20
It’s not reflected anywhere in the IB transaction log?
0
- ago
#21
Cone: I believe it is the open P/L on the position, and it is quoted in CNH (which should be CNY). I can try IB support or documentation to get more clarity.

Glitch: In the trade log window it just shows what I screenshotted above. It says the commission was 17.17 and the currency was CNH. Are you referring to a different log?
0
Glitch8
 ( 10.97% )
- ago
#22
I'm not an IB user personally so I wasn't sure if any other kind of transaction log was available.
0
Cone8
 ( 5.68% )
- ago
#23
QUOTE:
I believe it is the open P/L on the position, and it is quoted in CNH (which should be CNY).
Then everything is correct. This is a Forex Futures contract whose currency CNH. So P&L is in CNH.
As you said, in WealthLab you need to specify CNY for the currency for the contract specs.

P&L is completely separate from the currency risk of carrying the margin in CNY. Above I said the contract margin was $27K, but really it's 27K CNY.



Did you buy 27K CNY while holding the contract? No. If you had, the movement of 27K CNY in your base currency while trading the contract is what would be the Fx Gain (or Loss) that you'd see.

The CNY P&L of the trade is what's converted to the Base Currency on every bar and shows up in the Equity curve in a multi-currency backtest. Clear?

I'm still surprised that IB allows a negative currency balance because that's not allowed for forex trading and that's why you need to use CFDs to trade forex. But just now I found a doc that said this: "For Margin accounts (investment loan accounts), you can trade foreign products in supported currencies and have transactions that result in negative cash balances." https://www.ibkrguides.com/kb/article-4581.htm
0
- ago
#24
Alright, so now I see how it works. You are right, since it works on margin, there is no initial currency requirement, and therefore no currency risk involved with taking such a futures position.

However, the strategy is still working in a currency that is not USD. This makes it difficult to work into a meta-strategy. Is there a way to convert all P/L into USD for a strategy, especially at the moment of the trade exit (as I would do in practice)?

Obviously since the exchange rate changes throughout the period of the test, automating this calculation is somewhat essential to evaluating and comparing the strategy to others that transact in USD.
0
Cone8
 ( 5.68% )
- ago
#25
QUOTE:
However, the strategy is still working in a currency that is not USD.
Only if you're working with it that way intentionally.

The P&L of a Position in the backtest base currency is the standard Position.ProfitAsOf().
In the trade currency it is Position.ProfitNonBaseAsOf().
0

Reply

Bookmark

Sort