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.

IEngine.mergeOrders method weird behaviour
 Post subject: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 08:42 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
It seems the code
engine.mergeOrders("label", order, order)
does something weird while nothing is expecting.


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 09:02 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
What do you mean by "wierd"?


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 09:32 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
Initial position doubles in Historical Tester:

Image


Attachments:
merge.png [83.2 KiB]
Downloaded 604 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: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 10:11 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Isn't that a 'normal behavior'? When you merge 2 orders with amount 0.001, the resulting merged order's amount will be 0.002 (aka the sum of the merged orders' amounts).


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 10:20 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
tcsabina wrote:
Isn't that a 'normal behavior'? When you merge 2 orders with amount 0.001, the resulting merged order's amount will be 0.002 (aka the sum of the merged orders' amounts).
Read the first post: two orders are the same one. You can see the same label 'initial' of merged orders on the screenshot.

The mergeOrders method must do nothing in a such case.


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 28 Mar, 2014, 11:00 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Oh, I see now. :idea:


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Sat 05 Apr, 2014, 23:18 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
Hi, Support Team!

Do you confirm this bug?


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Sun 06 Apr, 2014, 10:22 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
NOT A BUG in my personal view.

This is Order Submission and Execution. Labels are for your own benefit.

The merge method doesn't care about Labels, it will merge Orders explicitly given to its parameters.
It is simply required to determine underlying Instruments and order sizes and reconcile all.
If programmer wants to use a 1 lot base order and merge it 10 times to produce a 10 lot position, that's his/her call and perogative.

The method takes a VARIABLE parameter list. The programmer provides that list.

Is it the responsibility of the programmer or the method implementer to sanitize the list?

Should the cost of checking for sloppy programming and a bad list be built into the method for all to bare or be left with those who are not operating with the appropriate care?
If I give the method a list of 10 orders, where order 6 and order 10 match (in terms of Label or Object Reference) that's some search needed to discover that during processing - on top of the existing Order field, state and Instrument checks.

Be sure that you could not repeat this "BUG" using the Platform, since the programmers of the platform have managed their side of the mergeOrders() contract before making their calls.

It's a utility method. It should be used correctly and intuitively. If you ask a merger method to merge 10 1 Lot orders (remember Labels mean nothing here, only order sizes, instrument and order state) then you implicitly ask the merger to interpret its 10 identical parameters as 10 individual and existing orders for consideration. This is reasonable and still consistent with say creating 10 1 Lot orders and merging those.

Depending on the underlying implementation and as per the method contract it will either work or throw an exception as soon as one of the underlying orders is found not to be in FILL state.

I do see and appreciate a strict interpretation of merge/existing(orders) but I care more about underlying performance and state/range checking costs.

If Support consider it a bug then it is what it is.


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Sun 06 Apr, 2014, 15:34 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
CriticalSection wrote:
NOT A BUG in my personal view.
It's a bug for sure 'cause the mergeOrders method must not change net position by contract. See more Merge Positions:
Dukascopy Wiki wrote:
Merge execution: ... technically no orders get filled ...


CriticalSection wrote:
Is it the responsibility of the programmer or the method implementer to sanitize the list?
For a public API it is the responsibility of the API developers to check the parameters for validity.



So, Support Team, what's up?


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Mon 07 Apr, 2014, 10:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The issue has been registered.


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Thu 22 May, 2014, 13:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Fixed with JForex-API 2.9.10.


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Tue 03 Jun, 2014, 12:37 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
API Support wrote:
Fixed with JForex-API 2.9.10.
Yes, it throws an exception now:
com.dukascopy.api.JFException: Cannot merge orders in state other than FILLED

But is such an exception appropriate for this case when an order is FILLED for sure?


 
 Post subject: Re: IEngine.mergeOrders method weird behaviour Post rating: 0   New post Posted: Fri 13 Jun, 2014, 13:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Try:
    @Override
    public void onStart(IContext context) throws JFException {
        engine = context.getEngine();
        history = context.getHistory();
        console = context.getConsole();
        context.setSubscribedInstruments(new HashSet<Instrument>(Arrays.asList(instrument)), true);
        IOrder order = engine.submitOrder("market_" + System.currentTimeMillis(), instrument, OrderCommand.BUY, 1);
        order.waitForUpdate(IOrder.State.FILLED);
        engine.mergeOrders("merged_" + System.currentTimeMillis(), order, order);
    }
We get the following message:
Quote:
Order [market_1402663304684] appears more than once in list of orders to merge


Attachments:
MergeSameOrder.java [1.94 KiB]
Downloaded 244 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.
 

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