Partial closing works but from what I see no thanks to BrokerTrade but to BrokerSell2.
First, BrokerSells has to return the ID of the main trade so BrokerTrade cannot check the status of the trade opened to reduce it as it cannot know its ID.
Second, as soon as BrokerTrade returns a negative number, Zorro considers the trade fully closed even if this number was smaller than the opened position in absolute value.

Also, let's take the case when an order to close or reduce a position is pending, I understand in that case we got no other choice than to return 0 from BrokerSell2 and Zorro will try again x number of times. I think what should rather be done is for Zorro to understand the trade is pending and check through BrokerTrade its status to know whether it has been accepted or not. I do not see such behavior possible with the current architecture.

Moreover, I do not see how BrokerSell2 can handle limit/stop orders because as soon as this method returns a non zero value, Zorro will consider the position as reduced or closed.
I tried to make Zorro understand the order was not filled yet setting dFill value to 0 but it did not work and anyway BrokerSell2 is supposed to return the ID of the main trade only hence I do not see how BrokerTrade could check the status of such pending limit/stop order.

I managed to make limit/stop orders work with BrokerBuy2 by not setting dFill value and later on by returning 0 from BrokerTrade when the order is till pending, however I did have to adjust some stuff to get pml=0 when deleting such an order as Zorro still consider the position as opened.
I do believe that Zorro broker API cannot handle properly limit/stop order to open or reduce a position when the broker allows such orders.




Last edited by byakuren81; 04/04/22 11:10.