Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

BreakEven price in consideration of commission
 Post subject: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 16:08 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Hello,

I want to get a BreakEven price level exactly when an order is filled for a scalping strategy.
Therefore I have to add (long trade) or subtract (short trade) an offset to the open price which is a commission in pips per roundturn.
But I'm not sure how to calculate the commission in pips.

Is the following function correct and applicable to all currency pairs (XXX/USD, USD/XXX and other pairs) ?
double calculateBreakEvenPrice (IOrder order, double dMyCommissionInUSDPerMillion)
{
    if (order == null || order.getState() != IOrder.State.FILLED)
        return Double.NaN;
   
    double dCommissionInPips = 2.0 * dMyCommissionInUSDPerMillion / 100.0;
    if (order.isLong())
        return order.getOpenPrice() + dCommissionInPips;
    else
        return order.getOpenPrice() - dCommissionInPips;
}

Regards
AbsoluteReturner


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 16:31 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Support, can you please move this topic to "Knowledge base" ?

Thanks
AbsoluteReturner


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 17:32 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi AbsoluteRunner:

You don't need to do the calculations as you have methods implemented in IOrder object to get the commission values of the order:

- getCommission()
- getCommissionInUSD()

Of course you have also to take the spread in consideration at the moment of determining the breakeven point.

I hope that helps

JL


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 18:27 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Hi jlongo,

the getCommission methods provide the commission represented in money.
But what I want to know is: How many additional (fractional) pips the price must move in trade direction exactly, so that the roundturn commission is earned and I'm really breakeven ?

When an order is filled and I'm using order.getOpenPrice(), I think the spread dosn't have to be considered for breakeven calculation anymore, only the commission.

Nevertheless, perhaps the getCommissionInUSD() method can be used to eliminate the "dMyCommissionInUSDPerMillion" parameter as follows:
(I assume that order.getAmount() provides the amount in millions)
dMyCommissionInUSDPerMillion = order.getCommissionInUSD() / order.getAmount();

But I think this is usable for USD/XXX pairs only, isn't it ?


Regards
AR


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 18:53 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi again:

I'm thinking in something like: instrument.getPipValue();

Hope that helps...

Best regards

JL

EDIT: with getPipValue() you have the pip value for your base currency for the pair in use.
with getCommision() you have the value of the commission for this order in your base currency.


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 19:21 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Yes, you are right, I forgot to integrate the pip value into my function:
double calculateBreakEvenPrice (IOrder order, double dMyCommissionInUSDPerMillion)
{
    if (order == null || order.getState() != IOrder.State.FILLED)
        return Double.NaN;
     
    double dCommissionInPips = 2.0 * dMyCommissionInUSDPerMillion / 100.0;
    if (order.isLong())
        return order.getOpenPrice() + dCommissionInPips * order.getInstrument().getPipValue();
    else
        return order.getOpenPrice() - dCommissionInPips * order.getInstrument().getPipValue();
}

But my original question is not answered yet:
Is it correct to calculate the commission in pips as follows: 2.0 * dMyCommissionInUSDPerMillion / 100.0 ?

AR


 
 Post subject: Re: BreakEven price in consideration of commission Post rating: 0   New post Posted: Mon 20 Aug, 2012, 20:49 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi again:

Supposing you have a 1.000.000$us/xxx order and your base currency is in us, your pip value is 0.0001 per 1$us... so, for 1.000.000$us, each pip is 100$us...
Supposing you pay the highest commission (35$us per million), you need 0,35 * 2 pips in green to pay the commission (fill and close added for volume commission)

This gives us the following formula: (commission value in base currency / (amount of the order * pip value in base currency)) * 2 - because of the sum of the fill and close turnover.

Just a warning: this is only what i think consulting the site and javadoc and some of my trades... i can be wrong because my commission is always greater than i expect: for a trade of 100.000 eur/usd i'm expecting a commission of 3$6us and i get 4$38us for example (18$us by million on table of commissions). Don't know if exists some more taxes, but talk with your manager about that.

EDIT: The commissions charged Dukascopy are charged correctly, i forget to do the correct calculations. To anyone that have interest in this, the 4.38$us means that i sell/buy 100.000€ what is aproximatly 125.000$us and by this way is correct this commission.

I forget to say before and i realized that consulting position reports we also must have swaps in consideration if you have orders open at the day transition (can be on your side or against).

Hope that helps

JL


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com