Dukascopy
 
 
Wiki JStore Search Login

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

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

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

Error method IOrder.getAmount()
 Post subject: Error method IOrder.getAmount() Post rating: 0   New post Posted: Fri 21 Feb, 2014, 16:52 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
Hi,

I have a strategy which calculates the risk I have on every open position. It calculates the difference between entry point and stop loss level and uses pipvalue and getAmount to calculate the risk.

It usually works properly, but today it is failing on one position. It is a long on USDJPY which currently has an amount of 12988 usd.

When evaluating the other open positions it gives me the right size of the positions, but on this one it gives me a negative amount. It gives me -0.102593 as amount when the real amount is 0.012988. On the other positions, as I said, the amount given is right.

Moreover, when I call IOrder.getOriginalAmount() it gives me back 0.012988, which actually is not the original amount, but the current amount.

I attach the piece of code, the result I obtain and a screenshot with the history of that position. Since I'm using this part of the strategy to calculate risks, it is important that is doesnt makes mistakes by getting the size of the position.

Thanks

if (order.getState() == IOrder.State.FILLED) {
                double sloss = order.getStopLossPrice();
                double carga = order.getAmount()*1000000;               
                double entry = order.getOpenPrice();
                print ("calculo riesgo par:"+instrument+" sl:"+sloss+" entrada:"+entry+" carga:"+carga+" carga original:"+order.getOriginalAmount());
}




Image
Image


Attachments:
messages.png [27.24 KiB]
Downloaded 326 times
usdjpy position history.png [37.97 KiB]
Downloaded 320 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Error method IOrder.getAmount() Post rating: 0   New post Posted: Fri 21 Feb, 2014, 17:14 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
Strange...

I moved the stop loss and after that, the strategy gets the right size for the position. However OriginalAmount is still wrong.
Image


Attachments:
strategy log.png [56 KiB]
Downloaded 335 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Error method IOrder.getAmount() Post rating: 0   New post Posted: Wed 26 Feb, 2014, 09:37 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Is that a global account or you are doing merges and partial closes?


 

Jump to:  

  © 1998-2024 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