Skip to content

Commit

Permalink
chore: Improve README and repo layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivix committed Aug 4, 2024
1 parent 078faaf commit 88efc54
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 19 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,5 @@ target/
**/*.rs.bk

notes.md
test.txt
large_test.txt
very_large_test.txt
test/large_test.txt
test/very_large_test.txt
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# PREtty FIX
![CI Status](https://img.shields.io/github/actions/workflow/status/shivix/prefix/rust.yml?branch=master)
![Latest Release](https://img.shields.io/github/v/release/shivix/prefix)

A commandline based pretty printer for FIX messages.

Based on a FIX4.4 dictionary, but is usable with most versions.
Based on a FIX4.4 dictionary, but is usable with all versions.

<img alt="Prefix showcase" src="https://github.com/Shivix/prefix/tree/master/examples/prefix.gif" width="1200" />

## Usage
Mainly developed with unix piping in mind:
input can be passed in as an argument or piped in:
```bash
echo 8=4.4^1=test | prefix
```
But can also provide a message as an argument:
```bash
prefix 8=4.4^1=test
prefix "8=FIX4.4|1=test|55=EUR/USD|10=123|"
echo "8=FIX4.4|1=test|55=EUR/USD|10=123|" | prefix
```
outputs:
```
BeginString = 4.4
BeginString = FIX4.4
Account = test
Symbol = EUR/USD
CheckSum = 123
```

Currently can use ^ and | and SOH as delimiters.
Expand All @@ -26,10 +30,8 @@ Use `prefix --help` or `man prefix` for more details.
Unix piping greatly increases the potential uses. For example:
Parsing a log file and aligning the values for easy scan reading.
```bash
# Creates the example log file.
echo "8=FIX.4.4|1=TEST^55=EUR/USD|150=1" > example.log
# Pipes the contents to prefix which parses and pipes them to awk, which prints them aligned.
cat example.log | prefix -v | awk '{printf("%-20s %-30s\n", $1,$3)}'
# Pipe the file contents to prefix which parses and pipes them to awk, which prints them aligned.
cat example.txt | prefix -v | awk '{printf("%-20s %-30s\n", $1,$3)}'
```
outputs:
```
Expand All @@ -38,6 +40,18 @@ Account TEST
Symbol EUR/USD
ExecType PartialFill
```
Or summarising a log file that includes FIX messages.
```bash
# Pipe the file contents to prefix which then summarises the FIX messages by instrument
cat example.log | prefix --summary 55 --only-fix | sort | uniq --count
```
outputs:
```
4 NewOrderSingle EUR/USD
4 ExecutionReport EUR/USD
2 NewOrderSingle USD/KRW
2 ExecutionReport USD/KRW
```

## Installation
Can be installed using:
Expand Down
Binary file added examples/prefix.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples/prefix.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Output prefix.gif

Set FontSize 26
Set Width 1200
Set Height 600
Set CursorBlink false

# Not yet released
#Env PROMPT "$ "

Type@0ms `FIX_MSG="8=FIX.4.4|35=8|34=42|49=SENDER|56=TARGET|55=EURUSD|44=1.032|38=10000|54=1|150=F|10=123|"` Enter
Sleep 1s
Type@100ms "prefix $FIX_MSG -v" Sleep 1s Enter

Sleep 10s
1 change: 1 addition & 0 deletions src/prefix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fn parse_tags(input: &str, regex: &Regex) -> String {

fn add_colour(input: &str, use_colour: bool) -> String {
if use_colour {
// TODO: Allow configuring colour using ENV variable
format!("\x1b[33m{}\x1b[0m", input)
} else {
input.to_string()
Expand Down
8 changes: 4 additions & 4 deletions test.sh → test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ for args in "${arg_sets[@]}"; do
$before_cmd $msg $args >>"$before_file"
$after_cmd $msg $args >>"$after_file"
done
cat test.txt | $before_cmd $args >>"$before_file"
cat test.txt | $after_cmd $args >>"$after_file"
cat test/test.txt | $before_cmd $args >>"$before_file"
cat test/test.txt | $after_cmd $args >>"$after_file"
done
cat test.txt | $before_cmd --summary 55 | sort | uniq --count >>"$before_file"
cat test.txt | $after_cmd --summary 55 | sort | uniq --count >>"$after_file"
cat test/test.txt | $before_cmd --summary 55 | sort | uniq --count >>"$before_file"
cat test/test.txt | $after_cmd --summary 55 | sort | uniq --count >>"$after_file"

$diff_tool "$before_file" "$after_file"
39 changes: 39 additions & 0 deletions test/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
8=FIX.4.49=7535=A34=100SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

8=FIX.4.49=14835=D34=101SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=EUR/USD60=20240101-04:04:04.40410=092
Non FIX Message Line
8=FIX.4.49=28935=834=10249=SENDER152=20240101-01:01:01.10056=TARGET16=113.3544=1.12311=01234567891014=444415=USD17=1098765432121=231=113.3532=400037=1098765432138=700039=140=154=155=EUR/USD60=20240101-01:01:01.100150=F151=4000453=1448=PARTY447=D452=110=151
Another Non FIX Message Line
Another Non FIX Message Line with 55 and 54 to translate
8=FIX.4.49=7535=A34=103SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

Non FIX Message Line
8=FIX.4.49=28935=834=10449=SENDER152=20240101-01:01:01.10056=TARGET16=113.3544=1.12311=01234567891014=4444.4415=USD17=1098765432121=231=113.3532=400037=1098765432138=700039=140=154=155=EUR/USD60=20240101-01:01:01.100150=F151=4000453=1448=PARTY447=D452=110=151
Another Non FIX Message Line with 55 and 54 to translate
8=FIX.4.49=7535=A34=105SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

8=FIX.4.49=14835=D34=106SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=EUR/USD60=20240101-04:04:04.40410=092
Non FIX Message Line
Another Non FIX Message Line with 55 and 54 to translate

8=FIX.4.49=7535=A34=107SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

8=FIX.4.49=14835=D34=108SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=USD/KRW60=20240101-04:04:04.40410=092

8=FIX.4.49=14835=D34=109SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=USD/KRW60=20240101-04:04:04.40410=092
Non FIX Message Line
8=FIX.4.49=28935=834=11049=SENDER152=20240101-01:01:01.10056=TARGET16=113.3544=1.12311=01234567891014=123.12315=USD17=1098765432121=231=113.3532=400037=1098765432138=700039=140=154=155=USD/KRW60=20240101-01:01:01.100150=F151=4000453=1448=PARTY447=D452=110=151
Another Non FIX Message Line
8=FIX.4.49=7535=A34=111SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

8=FIX.4.49=14835=D34=112SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=EUR/USD60=20240101-04:04:04.40410=092
Non FIX Message Line
8=FIX.4.49=28935=834=11349=SENDER152=20240101-01:01:01.10056=TARGET16=113.3544=1.12311=01234567891014=123.12315=USD17=1098765432121=231=113.3532=400037=1098765432138=700039=140=154=155=EUR/USD60=20240101-01:01:01.100150=F151=4000453=1448=PARTY447=D452=110=151
Another Non FIX Message Line
8=FIX.4.49=7535=A34=115SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

8=FIX.4.49=14835=D34=116SENDER152=20240101-04:04:04.444TARGET144=1.12311=01234567891015=USD21=238=700040=154=155=EUR/USD60=20240101-04:04:04.40410=092
Non FIX Message Line
8=FIX.4.49=28935=834=11749=SENDER152=20240101-01:01:01.10056=TARGET16=113.3544=1.12311=01234567891014=123.12315=USD17=1098765432121=231=113.3532=400037=1098765432138=700039=140=154=155=EUR/USD60=20240101-01:01:01.100150=F151=4000453=1448=PARTY447=D452=110=151
Another Non FIX Message Line
8=FIX.4.49=7535=A34=118SENDER152=20240101-10:10:00.001TARGET198=0108=6010=178

0 comments on commit 88efc54

Please sign in to comment.