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());
}