liveBook · Manning

Currency

As explained in Investing for Programmers

A currency is a medium of exchange issued or recognized by a government or monetary authority and used to denominate value.

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

How Investing for Programmers covers it

How deep it goes
Defines currency briefly and works through exchange mapping, conversion, and aggregation, stopping short of detailed foreign-exchange mechanics.
Examples
Uses Microsoft and BMW shares, exchange mappings, converted price columns, and a USD portfolio worksheet.
What it assumes
Assumes exchange identifiers, asset positions, and DataFrame operations while teaching the conversion workflow from exchange mapping onward.
What you can do after
Operate/configure a portfolio monitor that converts asset values and aggregates positions in a chosen currency.
How it connects
Connects currency with exchange rates, stocks, portfolios, DataFrames, and asset allocation.

Also explained in

Compare how 2 books explain currency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Investing for Programmers. The section links point to the parts of the book it draws on.