ANN: Swift ISO 15022 Parser for node.js

276 views
Skip to first unread message

billywhizz

unread,
Dec 7, 2011, 8:01:58 PM12/7/11
to nodejs
I knocked together a little swift parser a while back . i had to build
one in c# for work and figured it would be fun to do it in node.js
too.

https://github.com/billywhizz/swift-js

it should work on any fairly recent node.js version but the examples
use process.argv instead of process.ARGV so you will need to change
that if you are on an older version than 0.6+. it's a pretty low level
parser and doesn't parse individual field types - just breaks them out
into their relevant parts in json.

it hasn't been extensively tested so would appreciate any feedback.

** note - messages must use CRLF to separate lines according to the
swift spec. **

to run the test, just feed test.js a file with swift formatted
messages in it, e.g.

{1:F01AAAABBBBAXXX1234123456}{2:I543ABCDEFGHXXXAN}{4:
:16R:GENL
:20C::SEME//12345678
:23G:NEWM
:16S:GENL
:16R:TRADDET
:98A::SETT//20110829
:98A::TRAD//20110824
:90B::DEAL//ACTU/CAD00000001,000000
:35B:ISIN CA1058851074
Brazilian Gold Corp
:16S:TRADDET
:16R:FIAC
:36B::SETT//UNIT/00000007500,000
:97A::SAFE//012345678901234
:16S:FIAC
:16R:SETDET
:22F::SETR//TRAD
:16R:SETPRTY
:95P::PSET//ABCDEFGH
:16S:SETPRTY
:16R:SETPRTY
:95R::BUYR/CDSL/EFGH
:16S:SETPRTY
:16R:SETPRTY
:95R::REAG/CDSL/PQRS
:16S:SETPRTY
:16R:AMT
:19A::SETT//CAD000000007488,75
:16S:AMT
:16S:SETDET
-}
produces this json:

{
"headers": [
{
"block": 1,
"id": "F",
"service": "01",
"sender": {
"address": "AAAABBBBAXXX",
"bic": "AAAABBBB",
"terminal": "A",
"branch": "XXX"
},
"session": "1234",
"sequence": "123456"
},
{
"block": 2,
"type": "543",
"direction": "I",
"receiver": {
"address": "ABCDEFGHXXXA",
"bic": "ABCDEFGH",
"terminal": "X",
"branch": "XXA"
},
"priority": "N"
}
],
"body": [
{
"tag": "16",
"option": "R",
"value": "GENL"
},
{
"tag": "20",
"option": "C",
"qualifier": "SEME",
"value": "12345678"
},
{
"tag": "23",
"option": "G",
"value": "NEWM"
},
{
"tag": "16",
"option": "S",
"value": "GENL"
},
{
"tag": "16",
"option": "R",
"value": "TRADDET"
},
{
"tag": "98",
"option": "A",
"qualifier": "SETT",
"value": "20110829"
},
{
"tag": "98",
"option": "A",
"qualifier": "TRAD",
"value": "20110824"
},
{
"tag": "90",
"option": "B",
"qualifier": "DEAL",
"value": "ACTU/CAD00000001,000000"
},
{
"tag": "35",
"option": "B",
"value": "ISIN CA1058851074\r\nBrazilian Gold
Corp"
},
{
"tag": "16",
"option": "S",
"value": "TRADDET"
},
{
"tag": "16",
"option": "R",
"value": "FIAC"
},
{
"tag": "36",
"option": "B",
"qualifier": "SETT",
"value": "UNIT/00000007500,000"
},
{
"tag": "97",
"option": "A",
"qualifier": "SAFE",
"value": "012345678901234"
},
{
"tag": "16",
"option": "S",
"value": "FIAC"
},
{
"tag": "16",
"option": "R",
"value": "SETDET"
},
{
"tag": "22",
"option": "F",
"qualifier": "SETR",
"value": "TRAD"
},
{
"tag": "16",
"option": "R",
"value": "SETPRTY"
},
{
"tag": "95",
"option": "P",
"qualifier": "PSET",
"value": "ABCDEFGH"
},
{
"tag": "16",
"option": "S",
"value": "SETPRTY"
},
{
"tag": "16",
"option": "R",
"value": "SETPRTY"
},
{
"tag": "95",
"option": "R",
"qualifier": "BUYR",
"dss": "CDSL",
"value": "EFGH"
},
{
"tag": "16",
"option": "S",
"value": "SETPRTY"
},
{
"tag": "16",
"option": "R",
"value": "SETPRTY"
},
{
"tag": "95",
"option": "R",
"qualifier": "REAG",
"dss": "CDSL",
"value": "PQRS"
},
{
"tag": "16",
"option": "S",
"value": "SETPRTY"
},
{
"tag": "16",
"option": "R",
"value": "AMT"
},
{
"tag": "19",
"option": "A",
"qualifier": "SETT",
"value": "CAD000000007488,75"
},
{
"tag": "16",
"option": "S",
"value": "AMT"
},
{
"tag": "16",
"option": "S",
"value": "SETDET"
}
],
"trailers": []
}

billywhizz

unread,
Dec 7, 2011, 8:06:16 PM12/7/11
to nodejs
btw - i have been meaning to change the code to create nested blocks
for each 16R/16S pair but just haven't had the time yet and not sure
if it's worth the effort.
Reply all
Reply to author
Forward
0 new messages