Commision calculation

Created at 14 Jun 2016, 14:49
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!
moneybiz's avatar

moneybiz

Joined 06.12.2011

Commision calculation
14 Jun 2016, 14:49


How to calculate the commisions for the following order, step by step?

Account currency is USD. Commision for 1 lot is 3.5 USD.

I buy 0.10 lots of EUR/USD.
Entry price: 1.13651
Exit price: 1.13670
cAlgo shows the commision to be: -0.68 USD. Why not 0.70 USD?
 


@moneybiz
Replies

Spotware
14 Jun 2016, 17:55

Dear Trader,

We kindly ask you to contact your Broker regarding this.

If you use Spotware demo, we would like to inform you that it's just for demonstration purposes.


@Spotware

moneybiz
15 Jun 2016, 17:29

RE:

Spotware said:

Dear Trader,

We kindly ask you to contact your Broker regarding this.

If you use Spotware demo, we would like to inform you that it's just for demonstration purposes.

Why should I connect the broker? They say they charge 3.5 USD per lot per side for EUR/USD.
I don't think it's broker related. Why do you think it's broker related?

Whats I'm asking is with the givens how does the value that I see in positions or history is calculated.
The value changes is not constant as stated, which means the current price is included in the calculation. I want to know how. Isn't there any formulation for this?


@moneybiz

Jiri
16 Jun 2016, 01:17

Lets say broker charges a commission fee of $45 USD per million traded. If your account is denominated in a currency other than USD you will need to convert this figure.

The calculation is performed as follows:

Commission Each Side = (trade size * $45 per million traded) * account currency exchange rate

Example:

  • Trading 100,000 GBP/JPY with an account currency in EURO
  • 0.000045 * 100,000= £4.50 (Base currency of the pair traded)
  • To convert to Eur we must divide by the EUR/GBP rate
  • EUR/GBP= 0.798
  • Commission each way= €5.63

This will be charged when you enter and when you close the trade.

Part of this post was removed by moderator due to a violation of the EULA. Broker discussions are prohibited in cTDN.

 


@Jiri

moneybiz
16 Jun 2016, 01:18

By advising to ask the broker do you mean that for the total lots traded the commissions (not swap) may go lower or there is no standard calculation each broker calculates it however it wants?


@moneybiz

moneybiz
16 Jun 2016, 01:25

RE:

tmc. said:

Lets say broker charges a commission fee of $45 USD per million traded. If your account is denominated in a currency other than USD you will need to convert this figure.

The calculation is performed as follows:

Commission Each Side = (trade size * $45 per million traded) * account currency exchange rate

Example:

  • Trading 100,000 GBP/JPY with an account currency in EURO
  • 0.000045 * 100,000= £4.50 (Base currency of the pair traded)
  • To convert to Eur we must divide by the EUR/GBP rate
  • EUR/GBP= 0.798
  • Commission each way= €5.63

This will be charged when you enter and when you close the trade.

 

Part of this post was removed by moderator due to a violation of the EULA. Broker discussions are prohibited in cTDN.

Yes but cAlgo doesn't obey this calculation method. Use the numbers I have above, they don't match.


@moneybiz

Jiri
16 Jun 2016, 02:45

The method works fine for me.

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CommissionCalculator : Robot
    {
        [Parameter(DefaultValue = 30)]
        public double CommissionPerMillion { get; set; }

        protected override void OnStart()
        {
            Positions.Opened += OnPositionsOpened;
        }

        private void OnPositionsOpened(PositionOpenedEventArgs obj)
        {
            double commissions = CommissionPerMillion / 1000000 * obj.Position.Volume / AccountCurrencyExchangeRate() * -2;
            Print("Calculated: " + Math.Round(commissions, 2));
            Print("Actual: " + (obj.Position.Commissions * 2));
        }

        private double AccountCurrencyExchangeRate()
        {
            string accountCurrency = Account.Currency;
            string tradedCurrency = Symbol.Code.Substring(0, 3);

            if (accountCurrency == tradedCurrency)
            {
                return 1;
            }
            else
            {
                Symbol symbol = MarketData.GetSymbol(accountCurrency + tradedCurrency);
                if (symbol != null)
                {
                    return symbol.Bid;
                }
                else
                {
                    symbol = MarketData.GetSymbol(tradedCurrency + accountCurrency);
                    return 1 / symbol.Bid;
                }
            }
        }
    }
}

 


@Jiri

moneybiz
16 Jun 2016, 12:53

RE:

tmc. said:

The method works fine for me.

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CommissionCalculator : Robot
    {
        [Parameter(DefaultValue = 30)]
        public double CommissionPerMillion { get; set; }

        protected override void OnStart()
        {
            Positions.Opened += OnPositionsOpened;
        }

        private void OnPositionsOpened(PositionOpenedEventArgs obj)
        {
            double commissions = CommissionPerMillion / 1000000 * obj.Position.Volume / AccountCurrencyExchangeRate() * -2;
            Print("Calculated: " + Math.Round(commissions, 2));
            Print("Actual: " + (obj.Position.Commissions * 2));
        }

        private double AccountCurrencyExchangeRate()
        {
            string accountCurrency = Account.Currency;
            string tradedCurrency = Symbol.Code.Substring(0, 3);

            if (accountCurrency == tradedCurrency)
            {
                return 1;
            }
            else
            {
                Symbol symbol = MarketData.GetSymbol(accountCurrency + tradedCurrency);
                if (symbol != null)
                {
                    return symbol.Bid;
                }
                else
                {
                    symbol = MarketData.GetSymbol(tradedCurrency + accountCurrency);
                    return 1 / symbol.Bid;
                }
            }
        }
    }
}

 

16/06/2016 12:50:58.112 | cBot "Commision" was started successfully for EURUSD, h1.
16/06/2016 12:52:37.533 | Calculated: -0.77
16/06/2016 12:52:37.533 | Actual: -0.66

 


@moneybiz

moneybiz
16 Jun 2016, 13:12

Wait I may be wrong.
I checked the broker's web site just now and saw that there are 2 prices for different platforms. 3.5 USD/Lot is for MetaTrader and 3.0 USD/Lot is for cTrader.

When it's 3.0 USD/Lot the calculations seem to hold. But I still think there must be extra steps like which direction the position is opened. That way you'll determine to include Ask or Bid side when converting.
I'll make some calculations and write the final decision. :)


@moneybiz

Jiri
16 Jun 2016, 13:45

I have noticed there are minimal differences. I think it's caused by different method of rounding. I have tried to implement direction of position, therefore take Ask instead of Bid into calculation but it wasn't fixing it. Let me know if you manage to improve it.


@Jiri

moneybiz
16 Jun 2016, 14:20

The problem is the general notation of brokers for commission, which is: We charge 3.0 USD per lot per side.
But the calculations treat that USD as account currency not USD really. If your account currency is EUR they treat it as 3.0 EUR per lor per side.

Example:
Account currency: USD
Instrument: EUR/USD
Trade volume: 10.000 shares OR 0.1 lot
Current exchange rate: 1.1209

So the commission must be 3.0 USD x 0.1 = 0.30 USD per side.
But it is 0.30 USD x 1.1209 = 0.33627 ~ 0.34 USD per side. Why? The commision rate is in USD not EUR. Why suddenly start to treat it as it was EUR?

If the account currency was EUR then;
0.30 USD per side means 0.30 / 1.1209 = 0.2676 EUR per side.
But the calculations are vice versa.
0.30 EUR commision per side for EUR account and
0.34 USD commision per side for USD account.

Do I understand it wrong?
 


@moneybiz

kricka
16 Jun 2016, 15:09

Commission

The best way to calculate commission in a cBot is to retrieve it from the History, that is the correct commission fee paid on the latest trade made on the pair.


@kricka

Jiri
16 Jun 2016, 15:13

You're right. I just noticed unnamed broker who has stated $3.00 per 100k traded is actually charging €3. Are they trying to rob us by giving false information?

Btw, the method I posted will work only if you set commission per mill in same currency as account. I will update that later on.


@Jiri

Jiri
16 Jun 2016, 15:39

Actually multiple brokers have stated commission in USD but cTrader platform applies EUR. Could it be platform related?

Spotware, please take a look into this matter.


@Jiri

kricka
16 Jun 2016, 15:50 ( Updated at: 21 Dec 2023, 09:20 )

The beauty of History

The beauty of retrieving it from the History is that you can know beforehand without making an order. Market Order 3.0 illustrate this. If the parameter setting is in an inactive state, with other words no order will be placed but one get the total risk at hand including the commission, spread, swap and so on, without placing the order.

 


@kricka

moneybiz
16 Jun 2016, 17:16

RE:

tmc. said:

Actually multiple brokers have stated commission in USD but cTrader platform applies EUR. Could it be platform related?

Spotware, please take a look into this matter.

Back to basics:

1 Lot = 100.000 units of Base Currency

So for EUR/USD;
EUR is Base Currency
USD is Counter Currency

With that in mind 1 Lot is 100.000 EUR.
So when you buy 100.000 EUR (1 Lot)  you sell 100.000 x 1.1209 = 112.090 USD
 

The broker says: Commission of $3.00 per 100k traded.
100k traded what? Apples, cherries, EUR, USD?

a) If 100k traded is USD:
For 100.000 USD traded they charge 3.0 USD, for 112.090 USD traded they charge: 112.090 USD/100.000 USD x 3.0 USD = 3.3627 USD.
From the current exchange rate 3.3627 USD / 1.1209 = 3.0 EUR for 100k traded USD.

b) If 100k traded is EUR:
For 100.000 EUR traded they charge 3.0 USD.
From the current exchange rate 3.0 USD / 1.1209 = 2.6764 EUR for 100k traded EUR.

So the 100k traded expression is not clear to me. The whole trick is there. They indicate 3.5 USD but they don't indicate what unit is 100k traded. If they say 3.5 USD for Lot then from the definition of Lot it will mean 100.000 EUR (base currency) and item b applies. They don't say anything specific just 100k traded. Go figure.


@moneybiz

moneybiz
16 Jun 2016, 17:18

RE: RE:

So the 100k traded expression is not clear to me. The whole trick is there. They indicate 3.5 USD but they don't indicate what unit is 100k traded. If they say 3.5 USD for Lot then from the definition of Lot it will mean 100.000 EUR (base currency) and item b applies. They don't say anything specific just 100k traded. Go figure.

Ops, 3.5 USD will be 3.0 USD.


@moneybiz

Jiri
16 Jun 2016, 18:33

RE:

tmc. said:

Btw, the method I posted will work only if you set commission per mill in same currency as account. I will update that later on.

Actually it works across all currencies, since returned value is in account currency anyway. I am quite sure actual calculating process is rounding somewhere in the middle of calculation while my method isn't which is causing the difference.

 

tmc. said:

Actually multiple brokers have stated commission in USD but cTrader platform applies EUR.

Never mind, I was wrong about that.

 

moneybiz said:

The broker says: Commission of $3.00 per 100k traded.
100k traded what? Apples, cherries, EUR, USD?

It's commission of $3.00 per $100k traded (per side).

 

Let's assume your account currency is USD and current rate of EURUSD is 1.2500. If you trade 100k volume on EURUSD you are actually trading €100k as it's based currency of the pair. Therefore, calculation is following:

  • $3.00 * 1.2500 = $3.75 per side

If you account currency was EUR:

  • $3.00 * 1 = €3.00 = $3.75 per side

 


@Jiri

moneybiz
16 Jun 2016, 20:47

RE: RE:

tmc. said:

It's commission of $3.00 per $100k traded (per side).

Let's assume your account currency is USD and current rate of EURUSD is 1.2500. If you trade 100k volume on EURUSD you are actually trading €100k as it's based currency of the pair. Therefore, calculation is following:

  • $3.00 * 1.2500 = $3.75 per side

If you account currency was EUR:

  • $3.00 * 1 = €3.00 = $3.75 per side

The hint is unit of trade. How did you get that it's USD 100k but not EUR 100k? You're assuming it's USD and doing the calculation.

The wording must be like this: Commission per 1 LOT (100,000 base currency).
If they say 1 Lot then I know that for every 100k EUR (base currency) I'm going to pay 3.00 USD or equivalent EUR commision (2.40 EUR in your case).

 

 


@moneybiz

Jiri
16 Jun 2016, 22:14 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: RE:

moneybiz said:

How did you get that it's USD 100k but not EUR 100k?


@Jiri

moneybiz
16 Jun 2016, 23:28 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: RE: RE:

tmc. said:

moneybiz said:

How did you get that it's USD 100k but not EUR 100k?

So, for USD/CAD 100k traded is what USD or CAD?
For EUR/USD 100k traded is what EUR or USD?

Part of this post was removed by moderator due to a violation of the EULA. Broker discussions are prohibited in cTDN.

 


@moneybiz

Jiri
16 Jun 2016, 23:43 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: RE: RE: RE:

moneybiz said:

tmc. said:

moneybiz said:

How did you get that it's USD 100k but not EUR 100k?

So, for USD/CAD 100k traded is what USD or CAD?
For EUR/USD 100k traded is what EUR or USD?

Part of this post was removed by moderator due to a violation of the EULA. Broker discussions are prohibited in cTDN.

Obviously base currency. For USDCAD it's USD, for EURUSD it's EUR. Commissions shown are in account currency USD.


@Jiri

Jiri
17 Jun 2016, 00:02 ( Updated at: 21 Dec 2023, 09:20 )

Commission of $3.00 per 100k traded with same account currency.

I think it's clear. Isn't it?


@Jiri

Jiri
17 Jun 2016, 00:36

Try it. It's working like a charm.

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CommissionCalculator : Robot
    {
        [Parameter(DefaultValue = 30)]
        public double CommissionPerMillion { get; set; }

        protected override void OnStart()
        {
            Positions.Opened += OnPositionsOpened;
        }

        private void OnPositionsOpened(PositionOpenedEventArgs obj)
        {
            double commissions = CommissionPerMillion / 1000000 * obj.Position.Volume / AccountCurrencyExchangeRate();

            Print("Calculated: " + Math.Round(-commissions, 2));
            Print("Actual: " + (obj.Position.Commissions));
        }

        private double AccountCurrencyExchangeRate()
        {
            double rate = 1;

            string baseCurrency = Account.Currency;
            string counterCurrency = Symbol.Code.Substring(0, 3);

            if (baseCurrency != counterCurrency)
            {
                Symbol symbol = MarketData.GetSymbol(baseCurrency + counterCurrency);
                if (symbol != null)
                {
                    rate = symbol.Bid;
                }
                else
                {
                    symbol = MarketData.GetSymbol(counterCurrency + baseCurrency);
                    rate = 1 / symbol.Bid;
                }
            }

            return rate;
        }
    }
}

 


@Jiri

moneybiz
17 Jun 2016, 01:04

RE: RE: RE: RE: RE: RE:

tmc. said:

Obviously base currency. For USDCAD it's USD, for EURUSD it's EUR. Commissions shown are in account currency USD.

If for EUR/USD; 100k trades are in EUR then for each 100.000 EUR you'll pay 0.30 USD one way and 0.60 USD both ways.
If it's 100k trades of USD you'll pay 3.0 USD x 1.1233 = 3.37 USD one way and 6.74 USD both ways as it is indicated on the screenshot.
So 100k trades mean USD not EUR. Look at the volume column it will be EUR 100.000 which is 112.330 USD. That's why you're paying more commission because you're trading more USD than 100.000.

Part of this post was removed by moderator due to a violation of the EULA. Broker discussions are prohibited in cTDN.

 

 


@moneybiz