Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, AndrewAMD), 656 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
BrokerTrade and partial closing not working #485586
03/27/22 11:40
03/27/22 11:40
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Hello,

Some days ago I mentioned that BrokerTrade function could not handle the partial closing of trades done manually, well actually it does not handle it from Zorro too.

Let's take the case when the partial closing of a given trade is pending, then BrokerSell2 function will return a trade ID number only and BrokerTrade will have to check this pending order status.

However, as soon as the value returned by BrokerTrade is negative, Zorro will consider the opened position fully closed.

So far, from what I see BrokerTrade can handle trades fully closed and opened trades updates only.

It would be great to fix this issue in the future release.

Also, I noticed that when partially closing a trade through BrokerSell2, even if we affect a value to pProfit, Zorro will replace it by its own estimation which is wrong in that case. It lseems the real value is being divided by the trade number of lots before being reduced. For instance when calling BrokerSell2 to close 1 lot out of 3, the profit value estimated by Zorro will be the correct value divided by 3, for closing 1 out of 2 it will be divided by 2.

Last edited by byakuren81; 03/27/22 13:02.
Re: BrokerTrade and partial closing not working [Re: byakuren81] #485589
03/28/22 06:35
03/28/22 06:35
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
BrokerTrade supports partially closing, at least with all plugins that I know. Otherwise all the Z systems and virtual hedging would not work because they all use partial closing. The current profit of an open trade must be returned with BrokerTrade. Otherwise Zorro calculates it from the current price.

Re: BrokerTrade and partial closing not working [Re: byakuren81] #485632
04/04/22 11:05
04/04/22 11:05
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
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.
Re: BrokerTrade and partial closing not working [Re: byakuren81] #485637
04/05/22 13:52
04/05/22 13:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
You can contact Support when you have difficulties with a broker plugin implementation. Plugin support is free. BTW, a negative number by BrokerTrade after partial closing is certainly wrong, since that means always a fully closed trade. And your plugin must also handle trade ID changes. Otherwise partial closing would not work with your plugin.

Re: BrokerTrade and partial closing not working [Re: byakuren81] #485642
04/05/22 22:14
04/05/22 22:14
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Indeed I read in the BrokerTrade doc: "or the negative number of filled contracts when the trade was closed", my bad I missed that, thanks for the info I will contact them.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1