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.

How to identify orders closed because of 'merge' ?
 Post subject: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Tue 05 Jun, 2018, 12:45 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
I'd like to find orders closed because of merging into another order. Is there some 'sign' of this available in JForex API. I could not find it.


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Sat 09 Jun, 2018, 15:43 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
So .. the only way to identify merged orders I've found so far is to listen to onMessage and check if 'IMessage.getType()' is 'ORDERS_MERGE_OK'. But it seems there is no way to get that information for historic order :(


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Sat 09 Jun, 2018, 19:59 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Hello. I found this https://www.dukascopy.com/client/javadoc3/com/dukascopy/api/IReportPosition.PositionType.html
and https://www.dukascopy.com/client/javadoc3/com/dukascopy/api/IReportPosition.html
but not works on historical tester, only on real data, real statement from live or demo.
public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        // ... and other stuf in here
 
        long to = System.currentTimeMillis();
        long from = to - 5 * Period.MONTHLY.getInterval(); // 5 months back
       
        for(IReportPosition p : context.getReportService().getOpenPositions()) {
            console.getOut().println( p );
        }
       
        for(IReportPosition m : context.getReportService().getClosedPositions(from, to)) {
            console.getOut().println( m.getPositionType() ); // here
        }
       
        context.stop();       
     
    }


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Mon 11 Jun, 2018, 10:32 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
Thanks, I did not notice that functionality. However it does not answer my question - I'm looking the answer for the question 'why the order was closed?'. That report answer the question 'why the order was created?' ...


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Tue 12 Jun, 2018, 07:16 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
mtnfx wrote:
Thanks, I did not notice that functionality. However it does not answer my question - I'm looking the answer for the question 'why the order was closed?'. That report answer the question 'why the order was created?' ...

Something like when system cut losses and opened hedge in "margin cut" mode and you want to get that information about why system opened hedge and merged position . I don't know how to get this, sorry.


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Tue 12 Jun, 2018, 16:55 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,

Unfortunately, JForex-API didn't provide this possibility "out of the box". But, depending on your task, there is some options. Merged orders have empty closeHistory list, maybe this sample will be helpful.

        List<IOrder> myOrders = history.getOrdersHistory(myInstrument, from, to);
        for (IOrder order : myOrders) {
            if (order.getCloseHistory().size() == 0) {
                mergedOrders.add(order);
            }
        }


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Wed 13 Jun, 2018, 15:30 

User rating: 0
Joined: Mon 09 Oct, 2017, 06:34
Posts: 15
Location: Hong Kong,
in fact, you may get msg from onMessage when the order is merge, try to print those msg type, reason etc, you can get more information you want to know


 
 Post subject: Re: How to identify orders closed because of 'merge' ? Post rating: 0   New post Posted: Sat 16 Jun, 2018, 08:07 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
API Support wrote:
Hello,
Unfortunately, JForex-API didn't provide this possibility "out of the box". But, depending on your task, there is some options. Merged orders have empty closeHistory list, maybe this sample will be helpful.
[/code]

Thanks - this seems to be workable solution. Unfortunately there is the bug in JForex where 'close history' is also empty for closed non-merged-out orders - it makes that approach not really reliable.
Hopefully it will be fixed sometime ...

https://www.dukascopy.com/swiss/english ... 85&t=56054
https://www.dukascopy.com/swiss/english ... 85&t=56547


 

Jump to:  

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