-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help With Sending Raw Fix Messages #53
Comments
if you checkout https://github.com/TimelordUK/jspf-md-demo we have
<message name='UserFixArchive' msgcat='app' msgtype='UFA'>
<group name='NoEvents' required='Y'>
<field name='Subject' required='N' />
<field name='RawDataLength' required='Y' />
<field name='RawData' required='Y' />
</group>
</message>
> [email protected] generate
> cd node_modules/jspurefix/dist && node jsfix-cmd "--dict=../../data/FIX44-MD.xml" "--compile" "--output=../../src/types/"
case MsgType.News: {
const news: INews = view.toObject()
this.logger.info(news.Headline)
// send the news to 'archive' service as a user defined message
this.sendArchivist(msgType, view)
}
break this method builds a raw message and sends it private sendArchivist (msgType: string, view: MsgView): void {
const viewBuffer = this.asRaw(view)
const asTxt = viewBuffer.toString()
this.logger.info(asTxt)
// @ts-expect-error ts2307
const archive: IUserFixArchive = {
NoEvents: [
{
Subject: msgType,
RawData: viewBuffer,
RawDataLength: viewBuffer.length
}
]
}
this.send(MsgType.UserFixArchive, archive)
}
2022-10-22T13:44:20.004Z [test_server:MDServer] info: event count for archive 1 case MsgType.UserFixArchive: {
const msg: IUserFixArchive = view.toObject()
const events: IUserFixArchiveNoEvents[] = msg.NoEvents
this.logger.info(`event count for archive ${events.length}`)
for (let i = 0; i < events.length; ++i) {
const ev = events[i]
const txt = ev.RawData.toString('utf8')
this.logger.info(`request to archive this message ${txt}`)
}
} |
@TimelordUK thank you for the quick response and example added to https://github.com/TimelordUK/jspf-demo/. Although, I think this does not completely solve my problem. What I mean by "Sending Raw Fix Messages" is I need to send any already prepared FIX message ( |
The problem surely you have is if you wish to communicate say with a third party fix engine the session protocol is important. That is to say you need to maintain sequence numbers and keep alive heartbeat and so on. That being said if you are asking can I read a set of messages say from fix file strip out existing header and trailer and re encode those messages so third party engine will receive them then yes that should be possible. But it would be easier I would think to store and replay messages in json format but working in raw format is also possible. You can’t just take a set of messages and send them without valid headers else a commercial engine will just likely drop session immediately |
@TimelordUK thank you for the response and I understand what you are saying about valid session protocol and messaging, perhaps stripping out the header and trailer would be necessary. I was also thinking to create a unique session based on the message selected from the I'm needing to send messages one at a time from a |
there is a lot of test code alfready that can help which is a good starting point for example in src/test/fix-log-replay.tests we see a helper method :-- beforeAll(async () => {
setup = new Setup('session/test-initiator.json',null)
await setup.init()
definitions = setup.client.config.definitions
expected = require(path.join(root, 'examples/FIX.4.4/fix.json'))
views = await setup.client.getViews() // look to see how this is done
}, 45000) async getViews (fix: string = 'examples/FIX.4.4/fix.txt'): Promise<MsgView[]> {
return this.replayer.replayFixFile(path.join(root, fix))
} replayFixFile (replayFile: string): Promise<MsgView[]> {
return new Promise<MsgView[]>((accept, reject) => {
try {
const arr: MsgView[] = []
const transport: MsgTransport = new MsgTransport(1, this.config, new FileDuplex(replayFile))
transport.receiver.on('msg', (msgType: string, m: MsgView) => {
// note must clone if a view is to be saved after this call
arr.push(m.clone())
})
transport.receiver.on('end', () => {
accept(arr)
})
transport.receiver.on('error', (e) => {
reject(e)
})
} catch (e) {
reject(e)
}
})
} so you would
i can dip in and out for little pieces of help but at moment I am very time constrained - perhaps later on i will add to git a skeleton of the above to show how it can be done |
@TimelordUK I am trying to pass raw FIX messages from client to server. Is there a function or pattern that will take a string like
8=FIX.4.4�9=90�35=A�34=197�49=TRADER�52=20220927-15:38:19.000�56=OMS�98=0�108=30�10=181
and send this exact message without mutation?The text was updated successfully, but these errors were encountered: