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.

API - how to get positions?
 Post subject: API - how to get positions? Post rating: 0   New post Posted: Thu 21 Jun, 2012, 13:17 

User rating: 0
Joined: Thu 14 Jun, 2012, 14:24
Posts: 4
Hi!
I was able to get all the orders, but I do not understand how to get all the positions (I have two exactly).
To get orders I use code like the next:
IEngine engine = context.getEngine();
...
List<IOrder> orders = engine.getOrders();

I try to get positions getting history orders (code looks like that one):
IHistory history = context.getHistory();
...
List<IOrder> orders = history.getOrdersHistory(Instrument.EURUSD, timeFrom.getTimeInMillis(), timeTo.getTimeInMillis());

But I get nothing. Is my approach correct and mistake only in instrument or time, or there is another method to get positions?


 
 Post subject: Re: API - how to get positions? Post rating: 0   New post Posted: Thu 21 Jun, 2012, 13:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Quote:
Hi!
I was able to get all the orders, but I do not understand how to get all the positions (I have two exactly).
To get orders I use code like the next:
IEngine engine = context.getEngine();
...
List<IOrder> orders = engine.getOrders();
In fact IOrder represents a position - a main order with optionally attached stop loss and take profit orders.
Quote:
I try to get positions getting history orders (code looks like that one):
IHistory history = context.getHistory();
...
List<IOrder> orders = history.getOrdersHistory(Instrument.EURUSD, timeFrom.getTimeInMillis(), timeTo.getTimeInMillis());

But I get nothing. Is my approach correct and mistake only in instrument or time, or there is another method to get positions?
You can retrieve like this only the orders of IOrder.State.CLOSED, see:
https://www.dukascopy.com/wiki/#Order_history


 

Jump to:  

  © 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