Tickers and Identifiers

Ofx files typically refer to tickers (stocks, funds, etc.) by using identifiers. For example, Fidelity’s “Fidelity 500 Index Fund” with a ticker of FXAIX is referred to in Vanguard ofx files by its ISIN, “US3159117502”.

Managing identifiers: a basic solution

If you have only a couple of tickers across all your accounts, you can simply figure out their identifiers and stick them into a file like so: fund_info.py.

If you occasionally acquire a new ticker, you can use ticker-util to download the info needed for you:

  1. Run ticker-util add --tickers FXAIX to download data for the ticker, including its name and ISIN
  2. Run ticker-util show-fund-info, which outputs:
      ('FXAIX', 'US3159117502', 'Fidelity 500 Index Fund')
    
  3. Stick this in your fund_info.py

A better solution

But if you have more, or expect to run into new tickers periodically or frequently, this gets tiring quickly, and you will need a better option. ticker-util can manage this for you:

  1. Add the new tickers to ticker-util’s cache:
    ticker-util add --tickers VTI
    
  2. Re-generate your commodities.bc file containing commodity declarations:
    # assumes $BEAN_COMMODITIES_FILE is set
    ticker-util gen-commodities-file --write-file --confirm-overwrite --include-undeclared
    
    

Your commodities.bc file will now include the new ticker and its metadata:

2000-01-01 commodity VTI
  a__annualReportExpenseRatio: "0.03"
  a__isin: "US9229087690"
  a__quoteType: "ETF"
  name: "Vanguard Total Stock Market Index Fund"

How do you get your importer to use this? In your import specification file, simply include the line:

fund_info = ticker_util.generate_fund_info()

And that’s it! Instead of maintaining a separate dictionary of ticker symbols to identifiers, that library call picks up identifiers from your commodity declarations metadata.

Multiple identifiers for the same ticker

Unfortunately, not all brokers use the same identifier to refer to the same fund. Some us the ISIN, some use CUSIP, and yet others use their own identifier strings. Therefore, ticker-util’s downloaded identifier will sometimes not match what your ofx file has. When this happens, simply add the identifier from your ofx as metadata for you commodity. ticker-util is smart enough to append its identifier to yours:

Before:

2005-01-01 commodity VBTLX
   a__isin: "OQAZ"

Run:

ticker-util add --from-file # assumes $BEAN_COMMODITIES_FILE is set
ticker-util gen-commodities-file --write-file --confirm-overwrite

After:

2005-01-01 commodity VBTLX
   a__isin: "OQAZ,US9219376038"

In the example above, Vanguard’s .ofx files contain ‘US9219376038’, while Fidelity’s contain ‘OQAZ’ as the identifier for VBTLX.

Notes mentioning this note