Dukascopy
 
 
Wiki JStore Search Login

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

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

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

Mock Context/Engine order merge algorithm for JUnit testing
 Post subject: Mock Context/Engine order merge algorithm for JUnit testing Post rating: 0   New post Posted: Tue 17 May, 2011, 17:09 

User rating: -
I am looking to create a Mock implementation of the IEngine interface (actually merging is the only spot I am blocked at, the rest is pretty easy), but I am unsure of the exact way to calculate the various types of merges(same side orders, opposite side orders on both the winning and losing side).

Is there any object to handle the calculation of the outcome of a merge pre-built, or if not, is there any way I could get access to the way this is calculated so that I can accurately mock this?


 
 Post subject: Re: Mock Context/Engine order merge algorithm for JUnit test Post rating: 0   New post Posted: Thu 19 May, 2011, 08:16 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The order merging logic currently is not located in API, so there is no way you can obtain data of the resulting order without actually merging a set of orders by calling the IEngine.mergeOrders method.
While only the resulting order amount is concerned, the order merging algorithm is rather straightforward:
[SELL,0.2] + [BUY, 0.5] = [BUY, 0.3];
[SELL,0.2] + [SELL, 0.4] + [BUY, 0.5] = [SELL, 0.1]
[SELL,0.2] + [SELL, 0.3] + [BUY, 0.5] = [] (the merged order doesn't get created since the resulting amount is 0)

However, the price calculation algorithm is more evolved.

Also see order merging preconditions:
https://www.dukascopy.com/wiki/index.php ... _Positions


 

Jump to:  

cron
  © 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