Aggregated view average entry price (which includes commissions) is different to coded version (which doesn't include commissions)

Created at 12 Sep 2023, 01: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!
LE

leonwij

Joined 09.01.2023

Aggregated view average entry price (which includes commissions) is different to coded version (which doesn't include commissions)
12 Sep 2023, 01:30


Hello,

the Position window in "aggregated view" shows Average entry price for a symbol - and this seems to include the cost of commissions both ways.

However when I use the following code:

double AverageEntry = Positions.Where(x => x.SymbolName == Symbol.Name).Average(i => i.EntryPrice); 

this price does not include the cost of commissions.

How do I get the Average entry price that displays in the aggregated view for a particular symbol?

Thanks, Leon


@leonwij
Replies

PanagiotisChar
12 Sep 2023, 06:01

Hi there,

the Position window in "aggregated view" shows Average entry price for a symbol - and this seems to include the cost of commissions both ways.

As far as I know it does not


@PanagiotisChar

leonwij
13 Sep 2023, 04:54

Ok, well is there a simple way to calculate the Breakeven price for a position accounting for in and out commissions?  Or the same for a group of positions within a symbol?


@leonwij

PanagiotisChar
13 Sep 2023, 05:51 ( Updated at: 13 Sep 2023, 05:59 )

Hi there,

I do not have a ready code to share but you can use Symbol.Commission and Symbol.CommissionType alongside with some math to calculate this


@PanagiotisChar