Commodity Registry
Single source of truth for financial instrument data. Used to map ISINs, Tickers, and Names to canonical commodity identifiers for Beancount and other financial tools.
Concepts
- Canonical Name: The unique identifier used in Beancount ledgers (e.g.,
AAPL,CSPX). - ISIN: International Securities Identification Number (e.g.,
US0378331005). primary key for resolution. - FIGI: Financial Instrument Global Identifier.
- Ticker: Provider-specific symbol (e.g.,
AAPLfor Yahoo,CSPX.Lfor Yahoo).
Installation
uv tool install commodity-registry
Configuration
The registry loads data from two sources:
- Bundled Data: Built-in commodities (ETFs, Stocks).
- User Data: Custom YAML files located at
COMMODITY_REGISTRY_PATH.
Set the environment variable to point to your custom registry:
export COMMODITY_REGISTRY_PATH=~/path/to/my/registry
The registry recursively scans this directory for .yaml and .yml files.
Usage
Resolve a Token
Find the canonical commodity for an ISIN, Ticker, or Name.
commodity-reg resolve US0378331005
# Output: Resolved: AAPL
Automatic Currency Resolution
The registry programmatically resolves standard currencies to Yahoo tickers if they are not in your custom registry:
resolve EUR->EURUSD=Xresolve EUR/JPY->EURJPY=Xresolve USD/JPY->JPY=X
This eliminates the need to manually define standard Forex pairs in your registry files.
With price verification (checks if price matches historical data):
commodity-reg resolve US0378331005 --date 2024-01-01 --price 185.00
Add a Commodity
Add a new commodity to your local registry.
# Auto-fetch metadata from Yahoo Finance
commodity-reg add US0378331005 --fetch
# Manually specify details
commodity-reg add --name AAPL --isin US0378331005 --ticker AAPL --instrument-type Stock --asset-class Stock --currency USD
Linting
Validate your registry data and check for duplicates.
commodity-reg lint
Verify against live market data (checks if tickers are valid):
commodity-reg lint --verify
Fetch Metadata
Look up security details from online providers (Yahoo Finance, FT).
commodity-reg fetch --isin US0378331005
Programmatic Usage
You can use the registry in your Python scripts:
from commodity_registry.registry import get_registry
# Initialize registry (loads bundled data + user data from env var)
reg = get_registry()
# 1. Resolve by ISIN
commodity = reg.find_by_isin("US0378331005")
if commodity:
print(f"Name: {commodity.name}, Currency: {commodity.currency}")
# 2. Search by any token (ISIN, Name, FIGI)
candidates = reg.find_candidates("AAPL")
for c in candidates:
print(f"Found: {c.name} ({c.isin})")
# 3. Look up by ticker
# Note: Ticker lookup requires the provider name
comm = reg.find_by_ticker("yahoo", "AAPL")
Data Format (YAML)
commodities:
- name: AAPL
isin: US0378331005
instrument_type: Stock
asset_class: Stock
currency: USD
tickers:
yahoo: AAPL
validation_points:
- date: "2024-01-01"
price: 185.64
Contributing
- Bundled Data: Submit a PR to add common instruments to
src/commodity_registry/data/commodities/. - Providers: Implement new data sources in
src/commodity_registry/finder.pyby adding a class that implements theDataSourceinterface.
Metadata
Release files for commodity-registry 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| commodity_registry-0.2.1.tar.gz | 21.7 kB | Without provenance | Details for commodity_registry-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| commodity_registry-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for commodity_registry-0.2.1-py3-none-any.whl |
Total release size: 46.7 kB
Release files / commodity_registry-0.2.1.tar.gz
| Download URL | commodity_registry-0.2.1.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af754116282d81924165117922a9b92902f27d4625dfedc8d1b08c9b27b7e93c
|
|
BLAKE2b-256 checksum How to use checksums |
8672430f93ed5d082633c029295ffe77780e84b36b5465f97200f188fcaf0817
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / commodity_registry-0.2.1-py3-none-any.whl
| Download URL | commodity_registry-0.2.1-py3-none-any.whl |
|---|---|
| Size | 25.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fabc743c9ec33d290ed5fa277a7ec851b9eb16d8a787dc7764de8a01802e6000
|
|
BLAKE2b-256 checksum How to use checksums |
5af86fbb112f95c507e4e4f3411badd2de434760c1ab9c13f5399637e69a9d39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for commodity-registry 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.