An implementation of the FIX protocol (Financial Information Exchange).
Currently the implementation is pre-beta.
New development is being done on https://github.com/falconair/fix.js. This codebase turned out to be over-engineered. fix.js is much simpler, but its infrastructure is not as developed (package file, 'npm install ...' system, tests, etc.)
Some code from fix.js (similar to this project) is also driving a web app to parse fix protocol messages at http://fixparser.targetcompid.com
npm install nodefix
You can run a test server:
node testFIXServer.js
then a test client, too:
node testFIXClient.js
Both programs should start communicating with each other. Wait a few seconds to see heart-beat messages fly by.
###Server:
var fix = require('fix');
var opt = {};
var server = fix.createServer(opt, function(session){
session.on("logon", function(sender, target){ console.log("EVENT logon: "+ sender + ", " + target); });
session.on("incomingmsg", function(sender,target,msg){ console.log("Server incomingmsg: "+ JSON.stringify(msg)); });
session.on("outgoingmsg", function(sender,target,msg){ console.log("Server outgoingmsg: "+ JSON.stringify(msg)); });
});
server.listen(1234, "localhost", function(){});
Server events:
- newacceptor (port)
- Triggered on new connections from clients
Server methods:
- write(sessionID, data)
- Converts an associative array to a FIX message and sends it to the counter party with given comp ID
- logoff(sessionID, reason)
- Logs off a given comp ID
- kill(sessionID, reason)
- Ends connection of a given comp ID, without logging off
###Client:
var fix = require('fix');
var opt = {};
var client = fix.createClient("FIX.4.2", "initiator", "acceptor",opt);
client.connectAndLogon(1234,"localhost");
client.on("connect", function(){ console.log("EVENT connect"); });
client.on("end", function(){ console.log("EVENT end"); });
client.on("logon", function(sender, target){ console.log("EVENT logon: "+ sender + ", " + target); });
client.on("logoff", function(sender, target){ console.log("EVENT logoff: "+ sender + ", " + target); });
client.on("incomingmsg", function(sender,target,msg){ console.log("EVENT incomingmsg: "+ JSON.stringify(msg)); });
client.on("outgoingmsg", function(sender,target,msg){ console.log("EVENT outgoingmsg: "+ JSON.stringify(msg)); });
Client events:
- newclient (version, sender, target, port, host)
- Triggered on new connections to servers
Client methods:
- write(data)
- Converts an associative array to a FIX message and sends it to the counter party
- logoff(reason)
- Logs off connection
- kill(reason)
- Ends connection without logging off
###Common: Events commons to servers and clients:
- connect (host, port, 'initiator' or 'acceptor')
- Triggered on new connections
- end (sender, target)
- Triggered when connections end
- error (err)
- Triggered on error
- logon (sender, target)
- Triggered when new client completes logon
- incomingmsg (sender, target, msg)
- Triggered on messages coming over the network
- outgoingmsg (sender, target, msg)
- Triggered on messages going out to the network
- incomingresync (sender, target, msg)
- Triggered on messages coming over the network, which may have already been processed. Should not matter other than on re-connections
- outgoingresync (sender, target, msg)
- Triggered on messages going out to the network, which may have already been processed. Should not matter other than on re-connections
- Groups
- Encryption
- Make sure ./traffic directory exists
Copyright (C) 2011 by Shahbaz Chaudhary
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.