# fix-sbe

This project is a LinkML model of FIX Simple Binary Encoding (SBE), the FIX Trading Community's standard for binary messages. It describes an SBE document in either edition: SBE 1.0, the final standard, and SBE 2.0 Release Candidate 3, a draft that differs on the wire.

- [Schema documentation](https://github.com/lmodel/fix-sbe/blob/2b9021e1fdc80ee767312b3871e83c70c8b0efc0/docs/elements/index.md), generated from the schema
- [About](https://lmodel.github.io/fix-sbe/docs/about/): how the schema reads SBE, where each part comes from and what it leaves out
- [`fix_sbe.yaml`](https://github.com/lmodel/fix-sbe/blob/2b9021e1fdc80ee767312b3871e83c70c8b0efc0/docs/schema/fix_sbe.yaml): the schema, with its modules merged

## Validating a message schema

An SBE schema is XML, and the model describes the record the converter writes from it. The namespace of the root element says which edition a file follows.

```bash
uv run scripts/sbe_xml_to_yaml.py my-schema.xml --out my-schema.yaml
uv run linkml-validate -s src/fix_sbe/schema/fix_sbe.yaml -C SbeMessageSchemaV1 my-schema.yaml
```

For SBE 2.0, name `SbeMessageSchemaV2`. `project/jsonschema/fix_sbe.schema.json` is the same schema for anyone without LinkML, and its `$defs` hold each class.

## A record

```yaml
schema_version: 0
encoding_sets:
  - encodings:
      - encoding_kind: SbeSimpleTypeV1
        symbolic_name: counter
        primitive_type: uint32
messages:
  - symbolic_name: Heartbeat
    sbe_id: 1
```

## What the validator cannot check

`tests/sbe_rules.py` holds the checks that compare one part of a document with another: the encoding a field names, an offset against the sizes before it, a version against the schema's, and the rest of [About](https://lmodel.github.io/fix-sbe/docs/about/#rules-that-span-a-document).
