GTC Orders and BrokerTrade

Posted By: MegaTanker

GTC Orders and BrokerTrade - 07/10/22 18:15

I'm trying to write BrokerBuy2 such that the Zorro process doesn't block while waiting for feedback from the broker about the order. So BrokerBuy2 returns the trade id immediately so that Zorro can then query the status with BrokerTrade. But this is not working as I would expect it to. When I leave the pFill pointer alone in BrokerBuy2 before returning, Zorro assumes the trade was completely filled (which it isn't actually), but when I set pFill = 0, Zorro correctly prints "Long %0..." in the message log but then never calls BrokerTrade afterwards so it never learns the status of the trade. With pFill untouched, Zorro does call BrokerTrade repeatedly.

I would want the fill to be 0 in Zorro until it actually is partially or fully filled.
Posted By: AndrewAMD

Re: GTC Orders and BrokerTrade - 07/11/22 01:21

You might need the TR_GTC flag set for TradeMode.
https://zorro-project.com/manual/en/trademode.htm
Posted By: jcl

Re: GTC Orders and BrokerTrade - 07/11/22 07:10

Yes. pFill must be set to the actuall fill amount. BrokerTrade updates the fill amount, and is always called unless the trade was rejected, cancelled, or closed.
Posted By: MegaTanker

Re: GTC Orders and BrokerTrade - 07/11/22 07:25

I did set the TR_GTC flag before but did not change the OrderDuration which appears to be 0 by default. So probably Zorro saw the trade as closed because the plugin returned 0 fill and the order immediately timed out on Zorro's side. Will try changing that later.
© 2024 lite-C Forums