Subscribe to RSS feed Better handling of FX in StocksCafe - FX 2.0

By evankoh posted on 12 Oct 2020  -  1,704 views

Note: If you are investing only in stocks that are denominated in your base currency (e.g. SGD), you can skip this article.

The old way of handling FX

Previously, StocksCafe handled portfolio with multiple currencies very simplistically. It would directly convert any non-base currency using the latest FX rate when needed (except for dividends where the FX rate used is the one on ex-date).

While this is an easy to understand and implement approach, there were several issues with it which lead to inaccurate representation of your actual returns in your base currency. e.g. Many users have asked why is it that their Total in SGD cost is constantly changing. In addition, not being able to determine the FX rate for a transaction especially frustrated a few users.

The improved FX 2.0

I spent a good amount of time over the last few weeks working on improving how StocksCafe handles FX.

1) Determine your own FX rate
You can now enter your own FX when you are creating/editing transactions. Note that the field will stay hidden at first but will appear when it detects that the transaction currency is different from your base currency.

2) Accurate Representation in Base Currency
Whenever, there is a need to convert to the base currency either for display or computation purposes, StocksCafe will use the correct FX. For example, if we need to use the base currency cost of a transaction, it will be converted with the FX rate you provided, or StocksCafe's FX rate on the transaction date if you did not provide one.

This actually led to a few questions by users who have noticed that their portfolio values in base currency have changed. As such, I think it is worth mentioning here how the different values are computed.

For example, in Current Portfolio, Total in Base Currency (e.g. Total in SGD)
- Current Cost: uses the FX rates of different transactions fixed on transaction date or given by user
- Current Value: uses the latest FX rate
- Day Change: uses the latest FX rate
- Current P&L: is actually Current Value - Current Cost
- Dividends: uses the FX rate fixed on the ex-dates

One question that seems to pop up with high frequency is "How can P&L for USD be higher than P&L for Total in SGD?". Yes, this is possible due to FX loss.

This is why it is important to track all these as accurately as possible so that we know our actual gain (or loss) in the currency that matters to us.

Example (extreme but not impossible)
If you buy a stock at USD1 when USD to SGD is at 2.
Total cost in USD = 1
Total cost in SGD = 2

Then if the stock now is worth USD1.5 but USD to SGD has weakened to 1.
Total value in USD now = 1.5
Total Value in SGD = 1.5

P&L in USD = 1.5 - 1 = 0.5, but
P&L in SGD = 1.5 - 2 = -0.5

3) Debug Page
As the above can be confusing to many (including myself at times) and we often would like to understand it more in depth, I have created a debug page where details such as the FX rate used will be displayed for anyone to investigate further. As always, please let me know if you spot any errors.

4) Columns related to FX in Portfolio
- A.FX (Average FX): Weighted average of the FX used of transaction currency to base currency
- L.FX (Latest FX): Latest FX of transaction currency to base currency
- FX%: (Latest FX / Average FX - 1) in percentage

To allow us to track our FX rates better, I have added these columns that you can choose to add to your Portfolio page if you like.

Significant changes have been made to the backend to enable all these. Due to the scale of it, I might have missed a thing or two so if you see any irregularities after going through the debug pages, please let me know.

Happy investing (in different currencies)!


< Previous Article
Last Chance to get Free StocksCafe ...

List All Articles Other articles by evankoh

Do You Keep Your Extra Cash in the Bank? There Are Better Options Out There!
The company that I am currently working for in Tokyo has a cafeteria that serves free lunch to all employees, hence during lunchtime, we would get together for lunch and chat. Occasionally, the topic about money management would come up, and to date, I have yet to find a Japanese colleague who invests in the stock market, citing reasons of either finding it too risky, lack of knowledge, or more commonly, ...

Quick Updates: Dividend Withholding Tax and More
Merry Christmas! I hope you are enjoying yourself this holiday season. Just wanted to quickly share some changes I have made over this weekend: Dividend Withholding Tax As StocksCafe recently started supporting US stocks, some users have requested for StocksCafe to automatically adjust for dividends based on individuals' tax status. For example, most Singapore residents would incur a 30% tax on all ...

Downtime Notice - Migrating Away from DigitalOcean This Weekend!
This is to inform you that it is likely that there will be a period of downtime for StocksCafe this weekend. It might become inaccessible as I proceed to migrate away from my current hosting provider, DigitalOcean. Thank you for your understanding. Note: You can stop reading here if you have no intention of using hosting services. The following is written because DigitalOcean has pissed me off yet ...