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.

Global account: getOrdersHistory returns empty lists
 Post subject: Global account: getOrdersHistory returns empty lists Post rating: 0   New post Posted: Tue 18 Jun, 2013, 12:46 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
long time = System.currentTimeMillis();
List<IOrder> orders = context.getHistory().getOrdersHistory(Instrument.EURUSD, time - Period.WEEKLY.getInterval(), time);
System.out.println("t: "+orders.size());

is returning

    > t: 0

tested with all instruments I passed orders on, always empty, even after retrying at runtime (was assuming there might be some cache feature)

any idea?
edit: seems it's doing that for PAMM accounts


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Wed 19 Jun, 2013, 14:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Do you see the orders on chart? Are the orders closed? Do you see them in the portfolio statement?


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Wed 19 Jun, 2013, 17:32 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
Quote:
Do you see them in the portfolio statement?

Do you mean, the reporting webpage, accessible from the jnlp with portfolio>activity log?
yes I see

    JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:52 19.06.2013 15:29:52 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
    JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:52 19.06.2013 15:29:52 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
    java DEMO2ByvHs 19.06.2013 15:29:51 19.06.2013 16:29:49 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
    java DEMO2ByvHs 19.06.2013 15:29:51 19.06.2013 16:29:49 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
    JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:49 19.06.2013 15:29:49 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
    JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:49 19.06.2013 15:29:49 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
But using the SDK, can't read this order. I just sent the code used to [email protected], I tried both sync and async methods https://www.dukascopy.com/wiki/#Order_history


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 07:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
lil wrote:
Do you mean, the reporting webpage, accessible from the jnlp with portfolio>activity log?
No, portfolio -> Position Report and then see the Closed Positions part.
lil wrote:
yes I see

JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:52 19.06.2013 15:29:52 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:52 19.06.2013 15:29:52 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
java DEMO2ByvHs 19.06.2013 15:29:51 19.06.2013 16:29:49 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
java DEMO2ByvHs 19.06.2013 15:29:51 19.06.2013 16:29:49 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:49 19.06.2013 15:29:49 message Order FILLED at 1.18507 NZD (#202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001) - Position #629695AUD/NZD
JForex v.2.25.1 DEMO2ByvHs 19.06.2013 15:29:49 19.06.2013 15:29:49 message Order ACCEPTED: #202658774 BUY 0.001 mil. AUD/NZD @ MKT MAX SLIPPAGE 0.001
None of those is a closed positon. To retrieve active orders use IEngine.getOrders, see: https://www.dukascopy.com/wiki/#Order_Management


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 10:39 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
I read the wiki, specially the order history mgt, but still not able to retirve data:

public class MA_Play implements IStrategy {

    private IConsole console;
    private IContext context;
    private Set<Instrument> instruments = new HashSet<Instrument>(Arrays.asList(Instrument.values()));
    private String mylastclose = null;
   
    public class Beep implements Runnable {
       public void run() {
         while (true) {
            try {
               Thread.sleep(5000);
               for (IOrder i : context.getEngine().getOrders()){
                  if(i.getState()== IOrder.State.FILLED){
                     console.getOut().println(i.getState()+" id:"+ i.getId());
                  }else{
                     console.getOut().println(i.getState()+" id:"+ i.getId());
                  }
               }
               if (mylastclose!=null){
                  IOrder ii = context.getHistory().getHistoricalOrderById(mylastclose);
                    if (ii!=null){
                      console.getOut().println("id:"+ ii.getId()+" __openp: "+ii.getClosePrice()+" __ closep:"+ii.getClosePrice()+" __ a:"+ii.getAmount()+" pl:"+ii.getProfitLossInAccountCurrency()+" ot:"+ii.getFillTime()+" ct:"+ii.getCloseTime()+ " mt:"+ii.getFillHistory() );
                   }else
                       console.getOut().println(mylastclose);
               }
            } catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }
         }
       }
    }
    public void onStart(IContext context) throws JFException {
       console = context.getConsole();
       new Thread(new Beep()).start();
        this.context = context;
        context.setSubscribedInstruments(instruments, true);
        instruments = context.getSubscribedInstruments();
    }

    public void onStop() throws JFException {
        console.getOut().println("Stopped");
    }
    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) {
    }
    public void onMessage(IMessage m) throws JFException {
       IOrder o=m.getOrder();
       if (o!=null && m.getType() == Type.ORDER_FILL_OK){
          mylastclose = o.getId();
          //console.getOut().println(m.getType()+": id:"+ o.getId()+" __openp: "+o.getClosePrice()+" __ closep:"+o.getClosePrice()+" __ a:"+o.getAmount()+" pl:"+o.getProfitLossInAccountCurrency()+" ot:"+o.getFillTime()+" ct:"+o.getCloseTime()+" f:"+o.getFillHistory() +" mt:"+m.getCreationTime() );
          ITick t = context.getHistory().getLastTick(o.getInstrument());
          console.getOut().println(m.getType()+": id:"+ o.getId()+": ab:"+ o.getLabel()+": l:"+ o.getFillHistory()+" __: "+(o.isLong()?t.getBid():t.getAsk())+" __ :"+t.getTime()+" mt:"+m.getCreationTime() );
       }
    }

    public void onAccount(IAccount account) throws JFException {
    }
}

outputting:
Order ACCEPTED: #202879048 SELL 0.001 mil. EUR/CAD @ MKT MAX SLIPPAGE 0.001
Order ACCEPTED: #202879048 SELL 0.001 mil. EUR/CAD @ MKT MAX SLIPPAGE 0.001
Order FILLED at 1.36837 CAD (#202879048 SELL 0.001 mil. EUR/CAD @ MKT MAX SLIPPAGE 0.001)  - Position #629695EUR/CAD
Order FILLED at 1.36837 CAD (#202879048 SELL 0.001 mil. EUR/CAD @ MKT MAX SLIPPAGE 0.001)  - Position #629695EUR/CAD
ORDER_FILL_OK: id:202879048: lab:jf126vb19: l:[] __: 1.36861 __ :1371721706710 mt:1371721706830
FILLED id:629695EUR/CAD
202879048
FILLED id:629695EUR/CAD
202879048

I didn't manage yet to make any of https://www.dukascopy.com/client/javadoc ... story.html getOrdersHistory(Instrument instrument, long from, long to) or getHistoricalOrderById(String id)
This works for non-pamm accounts, could you please have a look?


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 11:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
lil wrote:
didn't manage yet to make any of https://www.dukascopy.com/client/javadoc ... story.html getOrdersHistory(Instrument instrument, long from, long to) or getHistoricalOrderById(String id)
Navigate to Portfolio -> Position Report, select the same time period you use in your strategy and then see the Closed Positions part. How many closed positions do you see there?


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 11:55 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
I don' see a 'Position report' but there's a 'Trade Log' entry and the web page shows 162 lines Total 162 records found


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 13:02 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
ok now I use https://demo-login.dukascopy.com/aDDS/login.php?lang=en instead of running directly the jforex.jnlp

first popup:

    Warning: Account status - "Non Hedge Mode". Non hedge mode is not fully supported for this application.
    Trading activity visualization is not available, positions and pending orders will not be displayed.
    It's strongly recommended to use JForex trading platform for non hedge mode accounts. Please contact Support desk for any questions. Would you like to proceed?

I just created another pamm demo account DEMO2oZddV, it's not activated yet, but with this account no popup, the portfolio menu has more items, including position report unlike the first account on the top of this thread


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 13:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
lil wrote:
I don' see a 'Position report' but there's a 'Trade Log' entry and the web page shows 162 lines Total 162 records found
There is no 'Position report' for global accounts. Essentially, are you using a global account? Global accounts have no such thing as closed positions and subsequently no position history.


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 13:34 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
API Support wrote:
There is no 'Position report' for global accounts. Essentially, are you using a global account? Global accounts have no such thing as closed positions and subsequently no position history.

ahh... I was waiting for this reply for a long time,thx, so it means everything must be stored/logged by me?


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 13:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
lil wrote:
ahh... I was waiting for this reply for a long time,thx,
We assume that you work with standard account, unless you state otherwise.
lil wrote:
so it means everything must be stored/logged by m
What is the business logic you wish to implement? For what kind of account?


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 13:54 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
business logic, for the moment simply storing events (all orders emission details, all account updates), since the history functions are not available for global accounts from what I understood


 
 Post subject: Re: problem with getOrdersHistory return empty lists Post rating: 0   New post Posted: Thu 20 Jun, 2013, 14:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
For further inquiries on the topic please refer to:
viewtopic.php?f=65&t=49424&start=20


 

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