Question

I'm building a client for trading with a remote server using FIX protocol and QuickFix/J API.

I can send order, receive price updates, cancel orders etc...

I'm asked now to "query API for current position of an instrument".

So let's say I can submit an order for buying an instrument, and it doesn't get executed, I would like to receive from the server some information like "you are LONG on intrument X with quantity Y etc".

Is it possible using QuickFix/J API?

I have written a method like this

static void positionReport() throws SessionNotFound{

    quickfix.fix50.PositionReport order = new quickfix.fix50.PositionReport();

    SessionID sessionId = (SessionID) initiator.getSessions().get(0);

    order.set(new Account("1005390"));
    order.set(new SecurityID("4663789"));
    order.set(new SecurityExchange("XETR"));
    order.set(new Symbol("SAP"));


    Session.sendToTarget(order, sessionId);


}

which sends FIX messages like this

8=FIX.4.29=9835=AP34=4949=HIQ6_ORDER52=20140324-
15:54:10.14256=HIQFIX1=100539048=466378955=SAP207=XETR10=199

and receives messages like this:

8=FIX.4.29=9935=334=6949=HIQFIX52=20140324-15:54:10.89156=HIQ6_ORDER45=4958=Invalid MsgType372=AP373=1110=242

As you can see I get "Invalid message" error

Was it helpful?

Solution 2

No you cannot do that using Quickfix, unless and until the counterparty is modelled to give you FIX acknowledgements to your specific liking. That is why you can add your customized FIX fields to the FIX XML config file.

373 tag says 11  -> 11 = Invalid MsgType
58 confirms it for you again.

Check your FIX XML config and check if your message is complete and if your counterparty allows the messages of type AP.

OTHER TIPS

Check your counterparty's documentation.

FIX is a fairly "dumb" protocol. It just provides a communication infrastructure. The default message definitions are best thought of as a list of suggested messages that you can use. Even if one message type is supported by two counterparties, it's possible that each of the two counterparties could use it in totally different ways.

Most connection providers only use a subset of these messages. You should check their documentation to see if they support the PositionRequest message, and to see how they want you to set the fields in it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top