Currency provides the common unit needed to compare and aggregate assets. A portfolio monitor converts holdings from their exchange currencies into one target currency before calculating total value. section 6.5.1
A practical conversion workflow:
- Choose a target currency, such as USD. section 6.5.1
- Map each exchange to its trading currency, extending the mapping for uncovered exchanges. section 6.5.1
- Convert prices and yields, then multiply converted prices by share quantities to calculate position values. section 6.5.1
Mixed-currency portfolio
Microsoft shares listed on NASDAQ may be denominated in US dollars, while BMW shares listed on Frankfurt may be denominated in euros. Converting both positions to USD makes the portfolio total comparable, but exchange-rate fluctuations add risk. section 6.5.1
Listing 6.5 Converting currency
from currency_converter import CurrencyConverter
def get_conversion(target_currency = "USD"):
c = CurrencyConverter()
mapping_exchange_currency = { #1
'ARCA': c.convert(1, 'USD', target_currency),
'NASDAQ': c.convert(1, 'USD', target_currency),
'NYSE': c.convert(1, 'USD', target_currency),
'BATS': c.convert(1, 'USD', target_currency),
'PINK': c.convert(1, 'USD', target_currency),
'IBIS': c.convert(1, 'EUR', target_currency),
'AEB': c.convert(1, 'EUR', target_currency),
'VSE': c.convert(1, 'EUR', target_currency),
'AMEX': c.convert(1, 'USD', target_currency),
'BVME': c.convert(1, 'EUR', target_currency),
'SBF': c.convert(1, 'EUR', target_currency),
'EBS': c.convert(1, 'CHF', target_currency),
'CPH': c.convert(1, 'DKK', target_currency),
'PRA': c.convert(1, 'CZK', target_currency)
}
return mapping_exchange_currency
conversion = get_conversion() #2
Inspect the exchange-to-currency mapping and the CurrencyConverter calls used to produce conversion factors. section 6.5.1

