Skip to content

Instantly share code, notes, and snippets.

@jshelton31
Created April 28, 2017 23:43
Show Gist options
  • Save jshelton31/e85ed06bb0ac5c345bfee69756697dca to your computer and use it in GitHub Desktop.
Save jshelton31/e85ed06bb0ac5c345bfee69756697dca to your computer and use it in GitHub Desktop.
Interactive Brokers Common Function
@Override
public void updatePortfolio(Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, String accountName) {
DecimalFormat df = new DecimalFormat("0.0000"); // TODO get digit according
df.setDecimalSeparatorAlwaysShown(true);
String formatedPosition = df.format(position);
formatedPosition = formatedPosition.replace(",", ".");
System.out.println("contract = " + contract.localSymbol() + ", contract.description() = " + contract.description() + ", unrealizedPNL = " + unrealizedPNL + ", formatedPosition = " + formatedPosition);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment