0

I am trying to use the override function positions but it is not being called at all when running. Just want it to print out all open positions.

  @Override
public void position(String account, Contract contract, double pos, 
double avgCost) {
  System.out.println("contract " + contract);
}

It is not printing anything out at all. The account has open positions. Trying to just print all open positions each pass by of the function.

James Shelton
  • 77
  • 1
  • 9
  • Make sure the class extends the class you intend it to. If it isn't running (and it's supposed to), you probably didn't extend the right class. – Carter Brainerd Apr 27 '17 at 20:06
  • 1
    Also make sure you are using the right method to make the request, which is reqPositions(). If you use reqAccountUpdates(), you will get callbacks to updateAccountValue(), updatePortfolio() and updateAccountTime(), but not to position(). – gogotox Jun 14 '17 at 19:25

1 Answers1

0

You will have to make a request for positions via ApiController class:

var handler = new PositionsHandler();
controller.reqPositions(handler);

And implement your own positions handler:

public final class PositionsHandler implements IPositionHandler {

  @Override
  public void positionEnd() {
    //NOP
  }

  @Override
  public void position(String account, Contract contract, Decimal pos, double avgCost) {
    //TODO
  }
}
algonell
  • 129
  • 3
  • 7