Skip to content
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

Example for login #24

Open
denisvolokh opened this issue Nov 24, 2021 · 1 comment
Open

Example for login #24

denisvolokh opened this issue Nov 24, 2021 · 1 comment

Comments

@denisvolokh
Copy link

Hi,

Could you please show me how to log in or respond to message type A?

I have code in Python that is based on QuickFIX library and could not find any example using your library.

def toAdmin(self, message, sessionID):
        msg = message.toString().replace(__SOH__, "|")
        self.log_message("[+] To Admin: {msg}", fix_message=msg)

        message.getHeader().setField(fix.SenderSubID(self.username))
        if "A" == message.getHeader().getFieldRef(35).getString():
            message.setField(fix.Password(self.password))
        return

Thanks.

@TimelordUK
Copy link
Owner

TimelordUK commented Nov 24, 2021

hello if you check out https://github.com/TimelordUK/jspf-md-demo

this uses quick fix notation and shows how custom fields can be added and typescript interfaces created

the idea looking at src/md-client.ts is to inherit from AsciiSession which will carry out the login and maintain heartbeat etc. It will forward application messages to

  protected onApplicationMsg (msgType: string, view: MsgView): void {
    this.logger.info(`${view.toJson()}`)
  }

if for some reason AsciiSession is not suitable, you can copy the implementation into your project MyAscciSession change it and inherit from that

this is a simple complete application which sends a message to a server also included,

when login is complete the onReady is called and we can send an application message to the server at this point.

  protected onReady (view: MsgView): void {
    this.logger.info('ready')
    const logoutSeconds = 32
    this.logger.info(`will logout after ${logoutSeconds}`)
    const mdr = MDFactory.BidOfferRequest('EUR/USD')
    this.send(MsgType.MarketDataRequest, mdr)
    setTimeout(() => {
      this.done()
    }, logoutSeconds * 1000)
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants