For the future readers.
Using average open price and the current price, you can get PnL in points.?
?
?
Average?
double average_op = (op1 * lot1 + op2 * lot2 + opN * lotN) / (lot1 + lot2 + lotN);
Profit in points:
double profit = Bid - average_op;
What I was expected to receive from IB API is an ability to see the PnL in points and dollars separately.?
Appeared that IB returns only average cost in dollars and only for one unit, so there is no need to divide it by number of contracts but it needs to be divided by multiplier.?
?
Examples?
?
What "reqOpenPositions" returns
- 2 contracts of ESZ4 (ES futures) => 300540
- 1 contract of E1AZ4 C6020 (ES call option) => 901.42
- 1 contract of SPY (ETF stock) => 597.94
- 1 contract of SPY 241203C00600000 (SPY call option) => 155
After dividing by multiplier I can get average open price?
- ESZ4 => 300540 / 50 => 6010.80
- E1AZ4 C6020 (ES call option) => 901.42 / 50 => 18.03
- SPY (ETF stock) => 597.94 / 1 => 597.94
- SPY 241203C00600000 (SPY call option) => 155 / 100 => 1.55
I know average cost in dollars that IB returns.?
- to get PnL in points I can subtract average open price from the current price from "reqMktData"
- to get PnL in dollars I can either make a call to "getPnl" or multiple PnL in points by tick value received from "reqMktData"
In other words, there are always 2 calls.?
- reqPositions
- reqMktData or reqPnl?