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.

After ORDER_SUBMIT_OK message, an order is changed
 Post subject: After ORDER_SUBMIT_OK message, an order is changed Post rating: 0   New post Posted: Tue 15 Dec, 2015, 21:39 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Dear Support,

I have an issue properly detecting when an order was Filled.
I created a sample strategy to demonstrate the issue. In a nutshell:
- I submit orders in the onBar() function. I handle a private Set, and add the orders into the set after the engine.submitOrder() was called.
- I want to do certain action after the order is filled. I used to do this by using to onMessage() function, and checking if the strategy receive an ORDER_FILL_OK message of this particular order.

This used to be a working scenario, but now it is not working anymore, because after a certain onMessage() call, the order in the private Set is not the same anymore that is available within message.getOrder().

This is a sample output of the strategy attached:
2015-12-15 20:28:00   Order fill
2015-12-15 20:28:00   false
2015-12-15 20:28:00   myOrders:[EURUSD1]-FILLED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   anOrder: [EURUSD1]-FILLED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   message: Message Type: ORDER_FILL_OK; Text: ; Related Order: [EURUSD1]-FILLED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   false
2015-12-15 20:28:00   myOrders:[EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   anOrder: [EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   message: Message Type: NOTIFICATION; Text: ORDER_FILLED-Order FILLED at 1.09137 (#369216953 SELL 0.005 mil. EUR/USD @ MKT MAX SLIPPAGE 0)  - Position #96057133; Related Order: [EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   Order submit
2015-12-15 20:28:00   false
2015-12-15 20:28:00   myOrders:[EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   anOrder: [EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   message: Message Type: ORDER_SUBMIT_OK; Text: ; Related Order: [EURUSD1]-OPENED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   true
2015-12-15 20:28:00   myOrders:[EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   anOrder: [EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   message: Message Type: NOTIFICATION; Text: ORDER_ACCEPTED-Order ACCEPTED: #369216954 STOP LOSS BUY 0.005 mil. EUR/USD @ MKT IF ASK  => 1.09195 - Position #96057133; Related Order: [EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   true
2015-12-15 20:28:00   myOrders:[EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   anOrder: [EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   message: Message Type: NOTIFICATION; Text: ORDER_ACCEPTED-Order ACCEPTED: #369216953 SELL 0.005 mil. EUR/USD @ MKT MAX SLIPPAGE 0 - Position #96057133; Related Order: [EURUSD1]-CREATED / EUR/USD / 1.09137 / 0.005 / 0.005
2015-12-15 20:28:00   --Sending SHORT EURUSD1; amount=0.005; price=0.00000; SL=1.09195
2015-12-15 20:28:00   adding order to set. myorders size: 0


I've indicated with red when things go wrong.
Edit: color codes seems to to work within /code block, so I removed them. But I think it is visible what is wrong: We should get 'true', instead of getting 'false'.


What is strange that on the Historical Test this strategy is working as designed. (So the condition of myOrders.contains(anOrder) is always true.


If this is a bug, could you advise how to work around, till the bug is fixed?

Thanks and regards.


Attachments:
File comment: Strategy to indicate the problem
RockNRoll_04.java [7.02 KiB]
Downloaded 189 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: After ORDER_SUBMIT_OK message, an order is changed Post rating: 0   New post Posted: Wed 16 Dec, 2015, 13:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This happens because the IOrder object is updated when it get filled. This causes .hashCode() to return different value. At the same time HashSet holds the order by the first hashcode.
A solution could be to use List instead of HashSet to store orders.


 
 Post subject: Re: After ORDER_SUBMIT_OK message, an order is changed Post rating: 0   New post Posted: Thu 17 Dec, 2015, 10:07 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Dear Support,

Thanks for the reply. I will try the list...

Is this (hash update) is something new(ish)? Haven't been the case, let's say, a year ago, has it?
And why the order hash has not been updated during a historical test?


 
 Post subject: Re: After ORDER_SUBMIT_OK message, an order is changed Post rating: 0   New post Posted: Fri 18 Dec, 2015, 14:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Last change for IOrder.hashCode() on demo was around Aug 2013.


 

Jump to:  

  © 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