Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thinkalpha/fix-client

Package Overview
Dependencies
Maintainers
0
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thinkalpha/fix-client

FIX client

  • 9.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

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 '../';

// extend message type existing message will be extended and FIX42.AllMessages will hold updated interface
declare module '../' {
    namespace FIX42 {
        export interface Heartbeat extends FIX42.FixMessage {
            MyTag1: string;
        }
    }
}

// add custom tag so Encode/Decode know what to do with a new tag
const coderExtension: Partial<FixEncoderMeta> = {
    name2Field: {
        MyTag1: {
            type: FIX_TYPE.STRING,
            number: '10001',
        },
    },
};

// new tag is required
const msg: FIX42.Heartbeat = {
    MsgType: FIX42.MsgTypeEnum.HEARTBEAT,
    MyTag1: 'test', // if you comment this error will be triggered
};

// header is also typed
const header = {
    SenderCompID: 'sender',
    TargetCompID: 'traget', // if you don't provide required field error will be triggered in client.send call
    SendingTime: Instant.parse('2024-01-01T10:00:00.000Z'),
};

const clientConfig = {
    endpoints: [
        {
            host: 'localhost',
            port: 1234,
        },
    ],
    timeout: 10,
    pause$: new Subject<boolean>(),
};

// improved way to create a FixClient (less template parameters, more typesafety)
const client = createFixClient<FIX42.AllMessages, FIX42.MessageHeader, FIX42.MessageTrailer>(
    clientConfig,
    'FIX.4.2-custom', // begin string
    FIX42.coderMeta, // defaults provided by generated code
    coderExtension, // extensions to make new fields work
);

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);
    }
});

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc