Esc

    The API is under testing and may change before release.

    The template registry

    This page lists what the template registry holds and how to read it: every template by family, resolving one code, and what an unknown code does. A code such as USD-SOFR-OIS, BRL-USD-NDF or USD-GC-REPO is all you need to book a trade on its market's standard terms. Each family's templates and their conventions are listed in the Markets catalog.

    Quick example

    It runs with helixio alone. It counts the registry's templates by family, resolves four codes, and shows an unknown code being refused.

    Rust
    use std::collections::BTreeMap;
    
    use helixrs::statics::templates::registry;
    use helixrs::template;
    
    fn main() -> Result<(), Box<dyn std::error::Error>> {
        let listing: Vec<(&'static str, &'static str)> = registry::codes()
            .into_iter()
            .map(|(_, _, code)| (code, registry::lookup(code).expect("a listed code").family()))
            .collect();
    
        // How many templates each family holds, by family.
        let mut counts: BTreeMap<&str, (usize, &str)> = BTreeMap::new();
        for (code, family) in &listing {
            let entry = counts.entry(family).or_insert((0, code));
            entry.0 += 1;
            if *code < entry.1 {
                entry.1 = code;
            }
        }
        println!("| Family | Templates | First code |");
        println!("|---|---|---|");
        for (family, (count, first)) in &counts {
            println!("| {family} | {count} | `{first}` |");
        }
        let total: usize = counts.values().map(|(count, _)| count).sum();
        println!("total {total} templates in {} families", counts.len());
    
        // A code resolves to a template whose family is the one the listing reports.
        for code in ["USD-SOFR-OIS", "BRL-USD-NDF", "USD-GC-REPO", "CDS-STANDARD"] {
            let family = template(code)?.family();
            println!("{code:<14} {family}");
        }
    
        // An unknown code is refused, naming the code and the registered ones.
        let Err(refused) = template("USD-NOPE-OIS") else {
            panic!("an unknown code must be refused");
        };
        let unknown = refused.to_string();
        println!("refused, naming the code: {}", if unknown.contains("USD-NOPE-OIS") { "yes" } else { "no" });
    
        Ok(())
    }
    Python
    from collections import Counter
    
    import helixio as hlx
    
    TABLE = hlx.templates.catalogue().to_dict()
    
    # How many templates each family holds, by family.
    counts = Counter(TABLE["family"])
    print("| Family | Templates | First code |")
    print("|---|---|---|")
    for family in sorted(counts):
        first = min(code for code, f in zip(TABLE["code"], TABLE["family"]) if f == family)
        print(f"| {family} | {counts[family]} | `{first}` |")
    print(f"total {sum(counts.values())} templates in {len(counts)} families")
    
    # A code resolves to a template whose family is the one the listing reports.
    for code in ("USD-SOFR-OIS", "BRL-USD-NDF", "USD-GC-REPO", "CDS-STANDARD"):
        family = hlx.templates.get(code).family()
        print(f"{code:<14} {family}")
    
    # An unknown code is refused, naming the code and the registered ones.
    try:
        hlx.templates.get("USD-NOPE-OIS")
    except ValueError as refused:
        unknown = str(refused)
        print(f"refused, naming the code: {'yes' if 'USD-NOPE-OIS' in unknown else 'no'}")
    else:
        raise AssertionError("an unknown code must be refused")
    | Family | Templates | First code |
    |---|---|---|
    | CDS | 2 | `CDS-STANDARD` |
    | FRA | 2 | `EUR-EURIBOR-3M-FRA` |
    | FX swap | 3 | `EUR-USD-FXSWAP` |
    | IRS | 12 | `AUD-BBSW-6M-IRS` |
    | NDF | 41 | `AOA-USD-NDF` |
    | NDO | 37 | `AOA-USD-NDO` |
    | NDS | 11 | `BRL-CDI-NDS` |
    | OIS | 23 | `AUD-AONIA-OIS` |
    | bond | 3 | `BOND-CORP-US` |
    | bond future option | 13 | `CBOT-OTN` |
    | cross-currency swap | 15 | `ARS-USD-NDCCS` |
    | deposit | 3 | `EUR-ESTR-DEPO` |
    | meeting-date OIS | 3 | `EUR-ESTR-MeetingOIS` |
    | rate future | 8 | `CAD-CORRA-3M-FUT` |
    | repo | 3 | `EUR-GC-REPO` |
    | swaption | 4 | `EUR-ESTR-SWAPTION` |
    | tenor basis swap | 2 | `EUR-ESTR-EURIBOR-BASIS` |
    | total return swap | 2 | `TRS-FIXED-FUNDING` |
    | zero-coupon swap | 2 | `EUR-EURIBOR-1M-ZCS` |
    total 189 templates in 19 families
    USD-SOFR-OIS   OIS
    BRL-USD-NDF    NDF
    USD-GC-REPO    repo
    CDS-STANDARD   CDS
    refused, naming the code: yes

    API

    Rust Python Returns
    the registry's codes and lookup (module statics::templates::registry) templates.catalogue() every code with its family
    template(code) templates.get(code) one template
    AnyTemplate::family Template.family() the template's family
    Argument Type Default Meaning
    templates.catalogue() none a table with one row per template: its code and its family
    templates.get(code) str required the template filed under code
    Template.family() none the family the template books, such as "OIS" or "NDF"

    Defaults and limits

    • An unknown code is refused, not defaulted: templates.get raises ValueError (Rust: an error) naming the code and the registered ones.
    • Codes are unique: each names exactly one template.
    • A code resolves to the family the listing reports: reading the table and resolving one code never disagree.

    See also

    • Source: crates/helixrs/src/statics/templates/registry.rs, crates/helixrs/src/statics/templates/mod.rs
    • Related pages:
      • Markets, for each family's templates and their conventions.
      • Templates and builders, for drafting a trade from a code.
      • How trades are built, for why trades are booked by code.

    From the 0.0 line at revision bf7f2e2. Every printed number is that revision's own output.