fix-client
- FixClient - supports JFIX and different FIX versions
- FixSession - keeps FIX session alive
example of custom Tag extension
import { Instant } from '@js-joda/core';
import { Subject } from 'rxjs';
import { createFixClient, FIX42, FixEncoderMeta, FIX_TYPE } from '../';
declare module '../' {
namespace FIX42 {
export interface Heartbeat extends FIX42.FixMessage {
MyTag1: string;
}
}
}
const coderExtension: Partial<FixEncoderMeta> = {
name2Field: {
MyTag1: {
type: FIX_TYPE.STRING,
number: '10001',
},
},
};
const msg: FIX42.Heartbeat = {
MsgType: FIX42.MsgTypeEnum.HEARTBEAT,
MyTag1: 'test',
};
const header = {
SenderCompID: 'sender',
TargetCompID: 'traget',
SendingTime: Instant.parse('2024-01-01T10:00:00.000Z'),
};
const clientConfig = {
endpoints: [
{
host: 'localhost',
port: 1234,
},
],
timeout: 10,
pause$: new Subject<boolean>(),
};
const client = createFixClient<FIX42.AllMessages, FIX42.MessageHeader, FIX42.MessageTrailer>(
clientConfig,
'FIX.4.2-custom',
FIX42.coderMeta,
coderExtension,
);
client.start();
client.send(1, msg, header).catch((e) => console.error(e));
client.messages$.subscribe((msg) => {
console.log(FIX42.coderMeta.msgType2msgName[msg.MsgType]);
if (msg.MsgType === FIX42.MsgTypeEnum.HEARTBEAT) {
console.log(msg.MyTag1);
}
});