npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-fix

v0.0.7

Published

A basic Node.js FIX protocol message parser

Downloads

17

Readme

A basic Node.js Financial Information Exchange (FIX) message parser

Install

npm install parse-fix

Example

import { 
  parseFixText, 
  fixMessagesFromText, 
  parseFixMsg 
} from 'parse-fix';

const fixText = `
127.0.0.1:55220 -> tcp -> some.server.com:8289
    8=FIX.4.49=9935=A34=149=MY_ORDERS52=20221112-00:57:16.86256=RECEIPIENT_SYSTEM98=0108=20141=Y554=password10=150
127.0.0.1:55220 <- tcp <- some.server.com:8289
    8=FIX.4.4\x019=00086\x0135=A\x0149=RECEIPIENT_SYSTEM\x0156=MY_ORDERS\x0134=1\x0152=20221112-00:57:17.090\x0198=0\x01108=20\x01141=Y\x0110=045\x01
127.0.0.1:55220 -> tcp -> some.server.com:8289
    8=FIX.4.4|9=68\x0135=5|34=2|49=MY_ORDERS|52=20221112-00:57:17.862|56=RECEIPIENT_SYSTEM|10=084|
`;

const parsed = parseFixText(fixText);
const msgsFromText = fixMessagesFromText(fixText);
const oneParsedMsg = parseFixMsg(msgsFromText[0]);

Fix messages may be delimited by ASCII 1 (SOH: ), Pipe ("|") or escaped Ascii 1 ("\x01"), and are expected to begin with field 8 (BeginString) and end with field 10 (CheckSum).

parseFixText returns an array of objects with these keys:

  • short is a summary field-name to field-value-or-lookup object
  • parsed is an array of field objects
  • byFieldName is an object of field objects, by field name
  • byFieldNo is an object of field objects, by field number
  • _raw is the original FIX message
[
  {
    "short": {
      "BeginString": "FIX.4.4",
      "BodyLength": "99",
      "MsgType": "LOGON",
      "MsgSeqNum": "1",
      "SenderCompID": "MY_ORDERS",
      "SendingTime": "20221112-00:57:16.862",
      "TargetCompID": "RECEIPIENT_SYSTEM",
      "EncryptMethod": "NONE_OTHER",
      "HeartBtInt": "20",
      "ResetSeqNumFlag": "Y",
      "Password": "password",
      "CheckSum": "150",
      "_raw": "8=FIX.4.4\u00019=99\u000135=A\u000134=1\u000149=MY_ORDERS\u000152=20221112-00:57:16.862\u000156=RECEIPIENT_SYSTEM\u000198=0\u0001108=20\u0001141=Y\u0001554=password\u000110=150\u0001"
    },
    "parsed": [
      {
        "fieldNo": "56",
        "value": "RECEIPIENT_SYSTEM",
        "fieldName": "TargetCompID"
      },
      {
        "fieldNo": "98",
        "value": "0",
        "fieldName": "EncryptMethod",
        "lookup": "NONE_OTHER"
      }
    ],
    "byFieldName": {
      "SenderCompID": {
        "fieldNo": "49",
        "value": "MY_ORDERS",
        "fieldName": "SenderCompID"
      },
      "EncryptMethod": {
        "fieldNo": "98",
        "value": "0",
        "fieldName": "EncryptMethod",
        "lookup": "NONE_OTHER"
      }
    },
    "byFieldNo": {
      "8": {
        "fieldNo": "8",
        "value": "FIX.4.4",
        "fieldName": "BeginString"
      },
      "35": {
        "fieldNo": "35",
        "value": "A",
        "fieldName": "MsgType",
        "lookup": "LOGON"
      }
    },
    "_raw": "8=FIX.4.4\u00019=99\u000135=A\u000134=1\u000149=MY_ORDERS\u000152=20221112-00:57:16.862\u000156=RECEIPIENT_SYSTEM\u000198=0\u0001108=20\u0001141=Y\u0001554=password\u000110=150\u0001"
  },
  // etc
]

fixMessagesFromText produces an array of unparsed FIX messages

[
  "8=FIX.4.4\u00019=99\u000135=A\u000134=1\u000149=MY_ORDERS\u000152=20221112-00:57:16.862\u000156=RECEIPIENT_SYSTEM\u000198=0\u0001108=20\u0001141=Y\u0001554=password\u000110=150\u0001",
  "8=FIX.4.4\\x019=00086\\x0135=A\\x0149=RECEIPIENT_SYSTEM\\x0156=MY_ORDERS\\x0134=1\\x0152=20221112-00:57:17.090\\x0198=0\\x01108=20\\x01141=Y\\x0110=045\\x01",
  "8=FIX.4.4|9=68\\x0135=5|34=2|49=MY_ORDERS|52=20221112-00:57:17.862|56=RECEIPIENT_SYSTEM|10=084|"
]

parseFixMsg produces an array of field objects from one message string:

[
  {
    "fieldNo": "8",
    "value": "FIX.4.4",
    "fieldName": "BeginString"
  },
  {
    "fieldNo": "9",
    "value": "99",
    "fieldName": "BodyLength"
  },
  {
    "fieldNo": "35",
    "value": "A",
    "fieldName": "MsgType",
    "lookup": "LOGON"
  },
  {
    "fieldNo": "34",
    "value": "1",
    "fieldName": "MsgSeqNum"
  },
  {
    "fieldNo": "49",
    "value": "MY_ORDERS",
    "fieldName": "SenderCompID"
  },
  {
    "fieldNo": "52",
    "value": "20221112-00:57:16.862",
    "fieldName": "SendingTime"
  },
  {
    "fieldNo": "56",
    "value": "RECEIPIENT_SYSTEM",
    "fieldName": "TargetCompID"
  },
  {
    "fieldNo": "98",
    "value": "0",
    "fieldName": "EncryptMethod",
    "lookup": "NONE_OTHER"
  },
  {
    "fieldNo": "108",
    "value": "20",
    "fieldName": "HeartBtInt"
  },
  {
    "fieldNo": "141",
    "value": "Y",
    "fieldName": "ResetSeqNumFlag"
  },
  {
    "fieldNo": "554",
    "value": "password",
    "fieldName": "Password"
  },
  {
    "fieldNo": "10",
    "value": "150",
    "fieldName": "CheckSum"
  }
]

TODO

  • Config object for settings
  • Limitation of output fields for parseFixText
  • Allow lookup override
  • Error handling

References