esanchezros / quickfixj-spring-boot-starter

Spring Boot Starter for QuickFIX/J
Apache License 2.0
125 stars 57 forks source link

Configuring fix44.xml file #99

Closed kunalbarchha closed 1 year ago

kunalbarchha commented 1 year ago

Hi,

This is not a bug, but need some clarity on how to configure the FIX44.XML file. I have a FIX 4.4 client using Spring boot application. Market Data Snapshot is working fine. But when I try to request Security List, or place a New Single Order, the request is processed successfully at the broker and I can see on console the FIX message.

But right after that, the messages are rejected by the library with following errors :

Security List Request : Error: Tag Not defined for MsgType 110 -- I understand tag 110 = minQuantity, and it is also received in the response I get.

New Singe Order Response : (Rejecting invalid message: quickfix.FieldException: Required tag missing, field=6 )

To be sure, I raised a ticket with my broker, and here's what he responded :

This is coming from your quickfix client (49=MyCompanyID) because your client doesn't recognize tag 110 as a valid field in a SecurityList response. (Tag 372=y).

Your quickfix install should have a file called FIX44.xml which contains all the message definitions for FIX version 4.4. To eliminate the reject, you need to edit this definition file to add tag 110 to the SecurityList definition. Once this is added, quickfix will no longer reject the SecurityList response. It appears that a similar thing is happening in regard to the execution report we sent to you. On new order acks, we do not send tag 6. However, we send it on fills and partial fills. In the same message definitions file, you should be able to mark fields as required or not required. Setting tag 6 to not required for 'ExecutionReport' would fix this second issue that you see.

I tried going through the provided examples and documentation, but couldn't find anything on the topic.

P.S. I am working with FIX for the first time in my career !

Thanks.

esanchezros commented 1 year ago

Hi @kunalbarchha,

Thanks for using the quickfixj spring boot starter. Although this question would be more related on the QuickFixJ repo, I think I can help you on this one.

Your broker has made changes to the standard FIX 4.4 definition and they probably should have provided you with a custom dictionary (the FIX44.XML file). However, pretty much none of brokers keep their fix dictionaries in sync with their FIX specifications, so you have to create one yourself.

Once you have handcrafted the custom dictionary for your broker, as indicated on their response, you need to make it available on the classpath, i.e put it in the resources folder. To avoid confusion, name the file something like FIX44-brokername.xml. The standard dictionaries are available on the classpath via the quickfixj lib.

On your quickfixj config file you can specify the application dictionary to use for validating messages. In this case you specify the name of the custom dictionary you put in resources:

# Validation
UseDataDictionary=Y
AppDataDictionary=FIX44-brokername.xml
ValidateIncomingMessage=Y

Sometimes you also want to have ValidateUserDefinedFields=N set, as they may have user defined fields in some messages and you may not need these. Alternatively, use AllowUnknownMsgFields=Y which will allow flag quickfixj to not fail parsing the message in case a field is unknown.

Bear in mind that the SecurityList class that comes with quickfixj will not have the accessors for MinQty (i.e. getMinQty) so you'll have to use msg.getInt(MinQty.FIELD). If you want to have custom fields added to the quickfixj classes, you will have to build quickfixj with the custom dictionary. Once you have the artifact built, you will need to add it to the pom dependencies and exclude the standard quickfixj dependency that comes with this spring boot starter.

I hope this helps. Best Ed

kunalbarchha commented 1 year ago

@esanchezros Thanks a lot for such a detailed explanation and helping out. Not many Repo maintainers spare time for support / education... Appreciate it ! I ended up creating a custom FIX44.XML and almost followed what you have mentioned. I now got the understanding how FIX actually works in the backgroun. Will be easier for further integration.

Once again, Thank you !

esanchezros commented 1 year ago

No worries at all @kunalbarchha, let me know if I can be of any further help. Thanks