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.

getOrderById null pointer exception on CLOSED positions
 Post subject: getOrderById null pointer exception on CLOSED positions Post rating: 0   New post Posted: Fri 28 Jan, 2011, 06:20 

User rating: 0
Joined: Wed 18 May, 2011, 23:26
Posts: 40
Location: Switzerland,
List<IOrder> orders = history.getOrdersHistory(Instrument.EURUSD, System.currentTimeMillis() - (6 * 60 * 60 * 1000), System.currentTimeMillis());
for (IOrder o : orders) {
  print("ID: " + o.getId());
  print("State (from history): " + o.getState().toString());
  print("State (from engine): " + engine.getOrder(o.getId()).getState().toString());
}


Returns:
Quote:
ID: 1604xxxx
State (from history): CLOSED
java.lang.NullPointerException


IHistory returns expected result (an IOrder), IEngine does not.

Ideas? Thanks


 
 Post subject: Re: getOrderById null pointer exception on CLOSED positions Post rating: 0   New post Posted: Sun 30 Jan, 2011, 17:10 

User rating: 0
Joined: Wed 18 May, 2011, 23:26
Posts: 40
Location: Switzerland,
getOrderById is the function that was called for the above output. Corrected code below:

        List<IOrder> orders = history.getOrdersHistory(Instrument.EURUSD, System.currentTimeMillis() - (100 * 60 * 60 * 1000), System.currentTimeMillis());

        for (IOrder o : orders) {
            print("ID: " + o.getId());
            print("State (from history): " + o.getState().toString());
            print("State (from engine): " + engine.getOrderById(o.getId()).getState().toString());
        }


 
 Post subject: Re: getOrderById null pointer exception on CLOSED positions Post rating: 0   New post Posted: Tue 01 Feb, 2011, 10:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
The IEngine does not contain closed orders, please use the IHistory.


 
 Post subject: Re: getOrderById null pointer exception on CLOSED positions Post rating: 0   New post Posted: Tue 01 Feb, 2011, 15:28 

User rating: 0
Joined: Wed 18 May, 2011, 23:26
Posts: 40
Location: Switzerland,
Support wrote:
Hi,
The IEngine does not contain closed orders, please use the IHistory.


How about a getOrderById() being accessible from IHistory?

Currently there exists a getOrdersHistory method:

public List<IOrder> getOrdersHistory(Instrument i, long l, long l1)


Would it not be more efficient to provide an order ID to getOrdersHistory (or getOrderHistoryById) rather than iterating over a list to find the order, find that the list does not contain the desired order - increase the lookback, repeat...?

Thank you Dukascopy support for considering this request.


 
 Post subject: Re: getOrderById null pointer exception on CLOSED positions Post rating: 0   New post Posted: Mon 07 Feb, 2011, 10:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
buyandhold wrote:
Would it not be more efficient to provide an order ID to getOrdersHistory (or getOrderHistoryById) rather than iterating over a list to find the order,

Currently we are not planing to create these changes.


 

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