BrokerTrade() is fundamentally flawed.

Posted By: AndrewAMD

BrokerTrade() is fundamentally flawed. - 10/08/23 21:04

My proposal is that BrokerTrade receives an additional return code to indicate that an order is expired/cancelled/rejected/dead while 100% unfilled.

Here's why:

BrokerTrade returns the following, according to the docs:
a) Number of contracts or lots (as in BrokerBuy2) currently filled for the order
b) Negative number of filled contracts or lots when the position was closed.
c) -1 when the position was closed at an unknown fill amount. Zorro will then assume that the order was completely filled.
d) NAY (defined in trading.h) when the order or trade state was unavailable. Zorro will then assume that the order was completely filled.

So what of the case of, say, a tif=DAY order with lots=10 that expires completely unfilled. Well, it could return 0 to indicate 0 lots have been filled, but it does not establish the end of the order. Or it could return NAY, but then Zorro will assume the order was completely filled.

Therefore one good solution is to add another return, maybe call it NAY_UNFILLED to say definitively that the order is both dead and unfilled.
Posted By: Petra

Re: BrokerTrade() is fundamentally flawed. - 10/09/23 09:25

A rejected order returns 0 at BrokerBuy2. But it is true, there is no return code for an order that was accepted, but unfilled and later cancelled. I will forward this request to the developers to implement such a code.
© 2024 lite-C Forums