A small, declarative language for computing financial indicators, scoring, and screening over panels of securities.
Trail (Tabular Ratios, Analytics & Indicator Language) computes financial ratios, factors, and scores across panels of companies over time, then ranks and screens them. Programs are data, written and validated by both humans and AI agents, and compile to vectorized columnar operations.
model quality on us_main period annual {
operating_margin = income.operating_income / income.revenue
score om_score weight 7 {
2 if operating_margin > 0.12
1 if operating_margin > 0.05
else 0
}
export composite = weighted_score()
}
The language is tiny at its core; the large function library is written in Trail itself.
- spec is the versioned language specification: EBNF grammar, reference, and standard library.
- trail-py is the reference implementation (Python).
pip install trail-lang # the library and the `trail` CLI
pipx install trail-lang # just the CLI, isolatedMIT.