Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/whoan/fixparser

:bank: A Rust/WASM library to parse FIX messages without a dictionary
https://github.com/whoan/fixparser

fix fix-parser fix-protocol hacktoberfest json parser wasm

Last synced: 3 months ago
JSON representation

:bank: A Rust/WASM library to parse FIX messages without a dictionary

Awesome Lists containing this project

README

        

# fixparser

![](https://github.com/whoan/fixparser/workflows/build-and-test/badge.svg)
[![Crates.io](https://img.shields.io/crates/v/fixparser.svg)](https://crates.io/crates/fixparser)
[![Docs.rs](https://docs.rs/fixparser/badge.svg)](https://docs.rs/fixparser)

Parse FIX messages without a FIX dictionary universally thanks to Rust + WASM.

```
[dependencies]
fixparser = "0.1.5"
```

It currently supports the following input/output formats:

**Input:**

- [FIX Tag=Value (classic FIX)](https://www.fixtrading.org/standards/tagvalue/)

**Output:**

- Json (`serde_json::value::Value`)

> **In WASM, the output is a JSON string.**

## Goal

To have a universal low-level mechanism to convert FIX messages to something easier to consume by higher-level tools. In such tools, you can combine the output of this library (json) with a FIX dictionary and let your dreams come true :nerd_face:.

## Examples

### Rust

```rust
let input = "Recv | 8=FIX.4.4 | 555=2 | 600=CGY | 604=2 | 605=F7 | 605=CGYU0 | 600=CGY | 10=209";
println!("{}", fixparser::FixMessage::from_tag_value(&input).unwrap().to_json());
```

```rust
// this input has the non-printable SOH character (0x01) as the separator of the fields
let input = "8=FIX.4.4555=2600=CGY604=2605=F7605=CGYU0600=CGY10=209";
println!("{}", fixparser::FixMessage::from_tag_value(&input).unwrap().to_json());
```

For any of those examples you will have this output:

```
{"8":"FIX.4.4","555":[{"600":"CGY","604":[{"605":"F7"},{"605":"CGYU0"}]},{"600":"CGY"}],"10":"209"}
```

Or prettier (`jq`'ed):

```
{
"8": "FIX.4.4",
"555": [
{
"600": "CGY",
"604": [
{
"605": "F7"
},
{
"605": "CGYU0"
}
]
},
{
"600": "CGY"
}
],
"10": "209"
}
```

Give it a try:

```bash
cargo run --example from-stdin
```

### WASM / JS

```bash
yarn add @whoan/fixparser
```

```js
const js = import('@whoan/fixparser')
js.then(fixparser => console.log(fixparser.from_tag_value_to_json('8=FIX.4.4 | 10=909')))
```
```
{"8":"FIX.4.4","10":"909"}
```

## Goodies

- It supports repeating groups
- You don't need a FIX dictionary. It is easy to create a tool to combine the output (json) with a dictionary
- You don't need to specify the separator of the input string as long as they are consistent. eg: 0x01, |, etc...
- You don't need to trim the input string as the lib detects the beginning and end of the message
- You don't need a delimiter (eg: SOH) in the last field
- It makes minimal validations on the message to allow parsing FIX messages with wrong values
- It has WASM bindings to use the library universally (eg: with [wasmer](https://wasmer.io))

## Features

You can debug the library using the `debugging` feature:

```
fixparser = { version = "", features = ["debugging"] }
```

## Nive-to-have features

- Support [data fields](https://www.onixs.biz/fix-dictionary/5.0.SP2/index.html): data, and XMLData
- Support more [input encodings](https://www.fixtrading.org/standards/)

## Limitations

- There is a scenario where the library needs to make assumptions as it can't guess the format without a dictionary. Example:

```
8=FIX.4.4 | 1000=2 | 1001=1 | 1002=2 | 1001=10 | 1002=20 | 1003=30 | 10=209
^ ^
group 1000 does 1003 belong to the second repetition of group 1000?
```

In such a scenario, it will assume *1003* does NOT belong to the group. Doing so, it's easier to fix it with the help of other tools which use FIX dictionaries (coming soon? let's see).

## License

[MIT](https://github.com/whoan/fixparser/blob/master/LICENSE)