BrokerTrade: "non-NFA compliant"?

Posted By: AndrewAMD

BrokerTrade: "non-NFA compliant"? - 03/04/22 12:11

jcl,

When placing limit orders (i.e. "NFA") via a plugin, my understanding is that fill status can be tracked using BrokerTrade.

But in the manual, BrokerTrade is described as for "non-NFA compliant" plugins. I think this is incorrect. Can you confirm?

Andrew
Posted By: jcl

Re: BrokerTrade: "non-NFA compliant"? - 03/09/22 11:36

Yes, BrokerTrade only works when brokers keep track of trades. NFA brokers normally don't.

You can use BrokerTrade to return order fill status, but it must then return NAY when the trade is filled and the order disappears. NAY tells Zorro that BrokerTrade is not supported anymore for this trade.
Posted By: AndrewAMD

Re: BrokerTrade: "non-NFA compliant"? - 03/14/22 16:50

Originally Posted by jcl
You can use BrokerTrade to return order fill status, but it must then return NAY when the trade is filled and the order disappears. NAY tells Zorro that BrokerTrade is not supported anymore for this trade.
If I understand correctly:

1) In NFA mode, BrokerTrade must never return a negative number.
2) In NFA mode, order is placed via BrokerBuy2. Order is completely filled and is therefore complete. So BrokerTrade must return the full fill (positive) and then return NAY on the next call.
3) In NFA mode, order is placed via BrokerBuy2. Order is partially filled and then no longer active (expired or canceled). So BrokerTrade must return the partial fill (positive) and then return NAY on the next call.
4) In NFA mode, order is placed via BrokerBuy2. Order is never filled and then no longer active (expired or canceled). So BrokerTrade must return 0 until the order becomes inactive, so it must return NAY on the next call.
5) In NFA mode, order is placed via BrokerBuy2. BrokerTrade returns NAY the first time. Zorro therefore assumes the order was 100% unfilled.

Is this correct?
Posted By: byakuren81

Re: BrokerTrade: "non-NFA compliant"? - 03/14/22 19:46

Hello,

I am implementing a broker API and I can tell you BrokerTrade can handle a trade fully closed manually from the broker GUI with a negative value returned from BrokerTrade corresponding to the lot amount initially opened and Zorro understands this trade is now closed.
However, as I raised the issue in a recent post, it does not work for partially closing the trade manually. When the negative size returned is smaller in absolute value than the lot amount of this trade, Zorro does not do any update on lot amount of the trade.
Posted By: jcl

Re: BrokerTrade: "non-NFA compliant"? - 03/14/22 21:51

1) In NFA mode, BrokerTrade must never return a negative number.

No. It can return a negative number when the position was closed.

2) In NFA mode, order is placed via BrokerBuy2. Order is completely filled and is therefore complete. So BrokerTrade must return the full fill (positive) and then return NAY on the next call.

No. It should return the fill when it is known, NAY when it is not known.

5) In NFA mode, order is placed via BrokerBuy2. BrokerTrade returns NAY the first time. Zorro therefore assumes the order was 100% unfilled.

No. It assumes that the API does not support BrokerTrade.
Posted By: AndrewAMD

Re: BrokerTrade: "non-NFA compliant"? - 03/15/22 11:18

1) The position? Meaning a reverse order was placed and filled? I fail to see how this can be correctly managed with an NFA plugin. It's probably smarter to keep orders and positions separate.

2) So even if I have a REST plugin (where there is rate limiting), the plugin should continue to inquire about the status of a filled / inactive order, even though its fate is sealed. Then once the broker fails to provide information on the order, return NAY. Is this correct?
Posted By: jcl

Re: BrokerTrade: "non-NFA compliant"? - 03/15/22 15:30

If you want, you can theoretically manage trades even with a NFA plugin. The plugin must then keep track of trades and synchronize them with open orders and position sizes. Since this would reqiure a lot programming, we do not mention it in the manual. I also know no plugin that would do that. NFA plugins normally don't use BrokerTrade at all.

Simply return all information that you easily get. Return the fill amount when you get it from the order, otherwise return NAY.
© 2024 lite-C Forums