Closing positions taking too long sometimes

Created at 07 Jan 2021, 21:30
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TP

tperalta82

Joined 07.07.2020

Closing positions taking too long sometimes
07 Jan 2021, 21:30


Hey Guys,

I sometimes have an issue,  that it takes longer than expected to close a position, here's the journal log

 

07/01/2021 11:52:28.855 | Request to close position PID60993114 is sent to server
07/01/2021 11:52:42.809 | → Request to close position PID60993114 is ACCEPTED, order OID114294551 created (07/01/2021 11:52:33.381 UTC+0)
07/01/2021 11:52:42.840 | → Order OID114294551 is FILLED at 1.22659, position PID60993114 closed (07/01/2021 11:52:33.512 UTC+0)
07/01/2021 11:52:43.277 | Request to close position PID60997923 is sent to server
07/01/2021 11:53:38.512 | cBot "SC" was stopped for EURUSD, m15. (it was a manual stop)

07/01/2021 11:53:56.652 | → Request to close position PID60997923 is ACCEPTED, order OID114298182 created (07/01/2021 11:53:11.073 UTC+0)
07/01/2021 11:53:56.684 | → Order OID114298182 is FILLED at 1.22624, position PID60997923 closed (07/01/2021 11:53:11.188 UTC+0)

Notice the timestamps!

When opening positions it's fine, when closing sometimes this happens, and today it hurt performance a lot, also, while waiting for a ?server? response, we could not click the close all positions button, my co-worker had to open another ctrader on his desktop to close them manually.

 

Any Ideas?

 


@tperalta82
Replies

PanagiotisCharalampous
08 Jan 2021, 08:17

Hi tperalta82,

During peak hours, it might take some time for your order to be filled if the infrastructure (servers, LPs etc) is busy. If you want to avoid UI freezing, try using ClosePositionAsync.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

tperalta82
08 Jan 2021, 12:15 ( Updated at: 08 Jan 2021, 12:16 )

RE:

Good morning PanagiotisCharalampous,

 

Yeah the asynchronous will fix the ui lock, as doe the server response delays, do you think if we use openapi instead of regular cbot, this can be mitigated? 

Or the behavior will be the same?

 

Best regards, 

 

 


@tperalta82

PanagiotisCharalampous
08 Jan 2021, 12:19

Hi tperalta82,

I don't think there will be any difference. cTrader used a similar protocol to Open API so I would not expect a faster communication, neither I think this is a network latency issue. My suspicion is that the delay might be on the LPs side.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

tperalta82
08 Jan 2021, 14:15

RE:

 

Hi PanagiotisCharalampous,

By LP what do you mean? Broker? Liquidity Provider? Kind of lost here.

 

Best Regards,

Tiago

 


@tperalta82

PanagiotisCharalampous
08 Jan 2021, 14:34

Hi Tiago,

I mean liquidity provider.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

tperalta82
08 Jan 2021, 14:49

RE:

Hi again,

So, since we have no idea how to mitigate the possible LP issue (it's not a thing that we can just switch, or am I wrong?), do you think trying it on another broker would fix the issue?

Or what would you suggest?

Thanks in advance!

 


@tperalta82

tperalta82
08 Jan 2021, 14:56

RE: RE:

Another thing i just thought of, we did some tests on demo and this did not occur, is it possible that when using demo, the LP's won't be an issue as the orders won't even go there?

 

 


@tperalta82

PanagiotisCharalampous
08 Jan 2021, 16:34

Hi Tiago,

So, since we have no idea how to mitigate the possible LP issue (it's not a thing that we can just switch, or am I wrong?), do you think trying it on another broker would fix the issue?

You can try

Another thing i just thought of, we did some tests on demo and this did not occur, is it possible that when using demo, the LP's won't be an issue as the orders won't even go there?

Demo orders are not sent to the liquidity provider.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

... Deleted by UFO ...

EagleMoxy
09 Jan 2021, 15:20 ( Updated at: 09 Jan 2021, 15:21 )

LIQUIDITY PROVIDERS AND OTHER BROKERS

Thats troubling to hear (the  late closure of positions) LP`s should be held accountable, but how do you spank the casino? 

I use icmarkets and pepperstone,give them a go, icmarkets have a lot of liquidity providers as do pepperstone. Let us know how it goes!.

 

 


@EagleMoxy

tperalta82
11 Jan 2021, 20:16

RE:

Hey PanagiotisCharalampous ,

After checking the ClosePositionAsync reply you gave me, i went and checked the code, and I already had that for a while, and it still locks the UI

 

try
                                {
                                    TradeOperation tOperation = ClosePositionAsync(pos);
                                    while(tOperation.IsExecuting)
                                    {
                                        Thread.Sleep(50);
                                    }
                                    tResult = tOperation.TradeResult;
                                }
                                catch (InvalidOperationException IOX)

 

I havea full threaded implementation for the cBot, the call is outside of the ontick/onbar and runs on its own thread , sorry for the late reply btw

PanagiotisCharalampous said:

Hi tperalta82,

During peak hours, it might take some time for your order to be filled if the infrastructure (servers, LPs etc) is busy. If you want to avoid UI freezing, try using ClosePositionAsync.

Best Regards,

Panagiotis 

Join us on Telegram

 


@tperalta82

PanagiotisCharalampous
12 Jan 2021, 07:58

Hi tperalta82,

The UI is locked because of this

                                    while(tOperation.IsExecuting)
                                    {
                                        Thread.Sleep(50);
                                    }

The whole point of ClosePositionAsync is not to wait for the order to be executed and proceed with the code execution. If you need to do something as soon as the position is closed, use the Position.Closed event.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

... Deleted by UFO ...

mdipika445
09 Mar 2024, 04:10 ( Updated at: 09 Mar 2024, 07:12 )

Hi tperalta82,

I think this problem is occurred during the peak hours, because that time the servers are very much busy. And cTrader and Open API both are using same protocol, so there would be no difference.

https://www.nodeposithero.com/casinos/mystake-casino/

Regards,

mdipika44


... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...