Skip to main content

Canonical tickerforge specification (YAML/CSV) for tickerforge-py and other consumers.

Project description

TickerForge Spec

CI

TickerForge Spec is the canonical specification and shared dataset used by TickerForge implementations across different programming languages.

The repository defines exchange metadata, contract rules, and test cases used to resolve financial asset tickers and derivatives contracts (futures and options).

It serves as the source of truth for all implementations of the TickerForge ecosystem.


Purpose

Different languages may implement their own versions of TickerForge (Python, Rust, Go, etc.).

This repository ensures that all implementations share:

  • The same exchange metadata
  • The same contract rules (futures and options)
  • The same symbol resolution logic
  • The same validation test cases

This guarantees consistent behavior across languages.


Repository Structure

tickerforge-spec/

VERSION

spec/
  exchanges/
    b3.yaml
    cme.yaml
  contracts/
    b3/
      futures.yaml
      options.yaml
    cme/
      futures.yaml
  tests/
    b3/
      futures_resolve.csv
      options_resolve.csv
      B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz
    cme/
      futures_resolve.csv
  schemas/
    contract_cycles.yaml
    exchange_schema.yaml
    contracts_schema.yaml
    options_schema.yaml

pyproject.toml
tickerforge_spec_data/
  __init__.py

rust/
  Cargo.toml
  src/lib.rs

scripts/
  check_versions.py

The B3 multi-year calendar golden file is kept only as B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz (semicolon-separated CSV, lzma-compressed)—no uncompressed twin is required in the repo.


Exchanges Metadata

Exchange files define static information such as:

  • timezone
  • trading hours
  • supported assets and product categories
  • exchange identifiers

Example:

exchange: B3
timezone: America/Sao_Paulo

assets:
  WIN:
    type: future
    category: index
    description: Mini Ibovespa Futures
    trading_hours:
      start: "09:00"
      end: "18:25"

  EQUITY_OPTIONS:
    type: option
    category: equity_option
    description: Options on listed equities (PETR4, VALE3, ...)
    trading_hours:
      start: "10:00"
      end: "18:25"

Contract Rules — Futures

Futures contract rules describe how derivatives contracts are generated and resolved.

Each contract defines its cycle (which months it trades in) and an expiration rule.

Supported expiration rule types:

  • nearest_weekday_to_day — closest weekday to a calendar day (e.g. WIN/IND: nearest Wednesday to the 15th)
  • first_business_day — first business day of the contract month (e.g. DOL, WDO, DI1)
  • last_business_day — last business day of the contract month (e.g. BGI)
  • fixed_day — specific calendar day, next business day if holiday (e.g. CCM: 15th)
  • schedule — dates vary per contract; consult exchange maturity calendar (e.g. ICF, CL, GC)

Example:

contracts:
  - symbol: DOL
    exchange: B3
    ticker_format: "{symbol}{month_code}{yy}"
    contract_cycle:
      - F   # January
      - G   # February
      # ... all 12 months
    expiration_rule:
      type: first_business_day

These rules allow implementations to determine:

  • front-month contracts
  • expiration dates
  • contract offsets

Contract Rules — Options

Options contract rules describe how option tickers are resolved.

B3 has four categories of options, each with distinct ticker formats:

Equity options use a compact format where one letter encodes both the option type (call/put) and the expiration month:

  • Calls: A (Jan) through L (Dec)
  • Puts: M (Jan) through X (Dec)
  • Ticker format: {root}{month_code}{strike} — e.g. PETRA35 = Petrobras call, January, strike 35

Index, dollar, and rate options use futures-style month codes with an explicit call/put indicator:

  • Ticker format: {symbol}{month_code}{yy}{C|P}{strike} — e.g. DOLF26C005200

Example:

options:
  - type: equity
    exchange: B3
    option_style: american
    ticker_format: "{root}{month_code}{strike}"
    call_month_codes: [A, B, C, D, E, F, G, H, I, J, K, L]
    put_month_codes: [M, N, O, P, Q, R, S, T, U, V, W, X]
    expiration_rule:
      type: nth_weekday
      weekday: friday
      nth: 3
    underlyings:
      - PETR4
      - VALE3

Shared Test Cases

Test cases ensure that all implementations produce identical results.

Test files use CSV format for easy maintenance and universal parsing.

Futures (spec/tests/<exchange>/futures_resolve.csv):

Columns: symbol,date,offset,expected,comment

symbol,date,offset,expected,comment
WIN,2026-06-01,0,WINM26,before June expiry (Jun 17) front month is June
DOL,2026-04-02,0,DOLK26,after Apr 1 expiry rolls to May
BGI,2026-06-01,0,BGIM26,after May expiry (May 29) front month is June

Options (spec/tests/<exchange>/options_resolve.csv):

Columns: type,underlying,date,option_type,strike,offset,expected,comment

type,underlying,date,option_type,strike,offset,expected,comment
equity,PETR4,2026-01-16,call,35,0,PETRA35,January call strike 35
equity,PETR4,2026-01-16,put,35,0,PETRM35,January put strike 35
dollar,DOL,2026-03-15,call,5200,0,DOLH26C005200,March call strike 5200

Implementations must load these tests and verify their resolver against them.


Implementations

TickerForge implementations may exist in multiple languages.

Examples:

  • tickerforge (Python)
  • tickerforge-rs (Rust)
  • tickerforge-go (Go)

All implementations should rely on this specification.


Versioning and Releases

This repository uses a shared root VERSION file as release authority.

  • Tag format: vX.Y.Z
  • Python package (tickerforge-spec-data in root pyproject.toml) version must match VERSION
  • Rust crate under rust/ uses the same version for local checks; it is marked publish = false (crates.io needs a different layout than ../spec)

Release sequence:

  1. Update VERSION and the version field in pyproject.toml and rust/Cargo.toml
  2. Run python scripts/check_versions.py
  3. Commit and tag vX.Y.Z
  4. GitHub Actions release.yml publishes the Python wheel/sdist to PyPI (spec files are bundled at build time; there is no duplicate spec/ copy in git)

Design Principles

TickerForge Spec follows several principles:

  • Deterministic — no dependency on external APIs
  • Exchange-aware — rules are defined per exchange
  • Language-neutral — YAML and CSV datasets usable by any language
  • Test-driven — shared test cases ensure consistent behavior

Contributing

Contributions are welcome.

Typical contributions include:

  • new exchanges
  • updated contract rules
  • additional test cases
  • corrections to metadata

Please ensure any change includes appropriate test cases.


License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tickerforge_spec_data-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tickerforge_spec_data-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file tickerforge_spec_data-0.1.0.tar.gz.

File metadata

  • Download URL: tickerforge_spec_data-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tickerforge_spec_data-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99576e9127b0eb1330850863753ca3eb27a3843e4df80cbd6fc24daa618f6205
MD5 7640a15fe268aa57b4039c8dc9fab5d7
BLAKE2b-256 e82667e7d68d74e84969d6c05070b45335ce678bc15642b10940941d0442a159

See more details on using hashes here.

File details

Details for the file tickerforge_spec_data-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tickerforge_spec_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d50c21c9adc926613404d18ffc2594e933906760bb9e6aac21ba929a07265080
MD5 da0b9ee3bb927ff6c7d114f44d243404
BLAKE2b-256 9ef9d97c38346cf5e6fbf4e7ac0ee8b8cf4a18f68e3abbc14bd25700fdebab15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page