When getting portfolio history, profit_loss_pct is currently calculated from a base value, not from previous value. This is problematic as there is no documentation as to where this base_value comes from. I assume the profit_loss_pct is meant to be an ROI calculation over the timeframe but that limits the usefulness to only calls made from an initial investment date, rather than being comparable to other percentage changes over the timeframe for which it is reported, like comparing to the % change in market indices.
getting portfolio history on 1/5/2021 for my paper trading portfolio returns the following:
base_value = 30872.29 which is just arbitrarily the equity value of the first day in the range. This is not the actual starting value of the account as I reset the account on 11-30 with a starting value of 30,000.
profit_loss_pct(2020-12-9) = (30568.30-30872.29)/30872.29 = -0.0098467
this is the percentage change but it is not useful as it is being calculated from an arbitrary value rather than the previous value.
changing the period of the call to ‘1W’ and specifying the timeframe as ‘1D’ returns:
base_value = 32640.94
again we can see the profit_loss_pct is calculated from this base_value which is again the closing equity of the first day in the range.
profit_loss_pct (2021-01-04) = (32436.85-32640.94)/32640.94 = -0.006253
However using a period of ‘1D’ and timeframe of ‘15Min’ returns:
base_value =32436.85 ???
Here the base value isn’t in the values returned for today but corresponds with my account’s equity for the previous day. Which is inconsistent with behavior from calls for longer time frames.
If possible could this behavior be changed to be more consistent and intuitive?
Alternatively could the name of the column be changed and documentation be updated to include the specific source of the base_value?