Hello,
Unfortunately, there's no option how to get to "Position Summary" tab. However, you can retrieve all orders made by your account and distinguish orders by state and OrderCommand (Buy/Sell).
This could be done easily by following example:
import com.dukascopy.api.*;
import java.util.List;
public class GetDataOrders implements IStrategy {
private IEngine engine;
private IConsole console;
@Override
public void onStart(IContext context) throws JFException {
console = context.getConsole();
engine = context.getEngine();
List<IOrder> ordersList = engine.getOrders();
console.getOut().println("\nCurrently opened " + ordersList.size() + " positions.\n");
for (IOrder order : ordersList) {
context.getConsole().getOut().println(
"Order ID: " + order.getId()
+"\t|\tState: " + order.getState()
+"\t|\tOrder Command: " + order.getOrderCommand()
+"\t\t|\tPrice:" + order.getOpenPrice()
+"\t\t|\tAmount: " + order.getAmount()
);
}
double totalAmount = 0;
double total = 0;
for (IOrder order : ordersList) {
if (order.getState() == IOrder.State.FILLED &&
order.getOrderCommand() == IEngine.OrderCommand.BUY ||
order.getOrderCommand() == IEngine.OrderCommand.SELL) {
totalAmount += order.getAmount();
}
}
for(IOrder order : ordersList) {
if (order.getState() == IOrder.State.FILLED &&
order.getOrderCommand() == IEngine.OrderCommand.BUY ||
order.getOrderCommand() == IEngine.OrderCommand.SELL) {
total += order.getAmount() * order.getOpenPrice() / totalAmount;
}
}
console.getOut().println("=========================== STATISTICS ===========================");
console.getOut().println("Total amount: " + totalAmount);
console.getOut().println("Total price: " + total);
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
@Override
public void onMessage(IMessage message) throws JFException {
}
@Override
public void onAccount(IAccount account) throws JFException {
}
@Override
public void onStop() throws JFException {
}
}
Learn more about IOrder & IEngine:
hereGood luck and have a nice day