Grevlanik, yes, I’ve seen your message later and it seems that this is exactly the same problem and it was not fixed at least for a year … that is sad
Dear JForex dev team, during the time while my bug report was moderated I had some time to think about this problem and here are some concerns
1. I do not use and strategy to create orders – everything is performed from JForex UI. The only my code I use is logging already created orders
2. I expect that problem occurs with BUY/SELL order originated from PLACE_BID/PLACE_OFFER orders. I mostly use PLACE_XXX orders and in many cases they are placed at the ‘edge’ price – this typically causes filling of such orders with multiple portions
So I guess you will be easily able to reproduce the problem by putting BID/OFFER with rather high amount at the current middle price between ASK and BID.
But as far as I noticed further wrong reporting from getAmount() is only minor part of the problem. I tried to workaround the wrong values in getAmount() by manually calculating that value from 'fills' – this should be the difference between ‘SUM(all fills)’ and ‘SUM(all closes)’ and it appears that ‘fills’ and ‘closes’ are also not reported correctly – this leaves no chance to calculate amount correctly because input data is not correct.
The problems I see here are ...
3. Listed ‘Fills’ contain both ‘original’ fills and ‘swap’ fills – that is why long-opened positions have such inadequate SUM of fills (I originally included SWAP into overall amount). Workaround for that problem – ignore ‘fills’ occurring at 21:00-21:10 UTC - these are typically SWAPs – unless indeed created at this time. Unfortunately, JForex API does not provide clear flag of the type of ‘fill’. Please add method into IFillOrder to distinguish ‘swap’ and ‘regular’ fills.
4. Sometimes ‘normal’ fills are reported twice - this is the bug that cannot be workarounded in client code. Here is the example (note – same order logged on another computer does not have ‘fill #2’ – i.e. this is some kind of data/timing-dependent error, note2: WEB interface reports only 99K operation happening at ‘09:30:31.911’):
Filled: #0: 2017-04-28 09:30:31.471 - 1 000 * 1.0937
#1: 2017-04-28 09:30:31.911 - 99 000 * 1.0937
#2: 2017-04-28 09:30:31.912 - 99 000 * 1.0937
5. Sometimes last ‘swap’ does not correspond to actual amount – i.e. previous swap is ‘100K’ and last swap is (for example) ‘27800’. There were no ‘close’ operations for that position – therefore that last swap should also be of ‘100K’ as the previous one. Note again: same position logged on another computer at the same time reports ‘100K’ as last swap.
6. The most misleading thing to me – is incorrectly reported ‘getOriginalAmount()’. As mentioned in JavaDoc – it ‘
Returns original constant amount of the order. The value is set on order submit and cannot be changed later.’ I assume with SELLs originated from PLACE_OFFER there is something wrong happening while OFFER is transformed into SELL somewhere in JForex inner code.
Note: minor thing – both IFillOrder and ICloseOrder are inherited from IPartialOrder and all their methods are copy/pasted into ‘children’ – this is a bit wrong in terms of API declaration, child interface should define only new methods.