Closed kenkunz closed 3 months ago
After further inspection, it appears that TradingPosition.get_value()
, which is used to calculate the metrics in the Value
row, can return incorrect results since it is a planned value
Therefore, @kenkunz, we can switch from stats.position.6[0].value
, since it is a planned and not executed value, to using the value from the trades list i.e. the value circled in red here is correct.
Same thing for the closing value
Issue
There appears to be a discrepancy in the position statistics related to quantity, price and value.
Details
See discord thread for full background.
While getting feedback on a new table-based design for position details, @tsorro noted that the change in value for the position didn't seem to accurately reflect the expected value based on the quantity and price change:
The position in question is: https://tradingstrategy.ai/strategies/enzyme-polygon-eth-breakout/closed-positions/6
The source of data for each of the metrics in the above table is identified below (from the
state
endpoint for this strategy):portfolio.closed_positions.6.opened_at
portfolio.closed_positions.6.closed_at
stats.position.6[0].quantity
(from first stats entry for position)
stats.position.6.at(-2).quantity
(from second-to-last stats entry for position)
portfolio.closed_positions.6.trades.11.executed_price
(from position's first trade)
portfolio.closed_positions.6.trades.12.executed_price
(from position's last trade)
stats.position.6[0].value
(from first stats entry for position)
stats.position.6.at(-2).value
(from second-to-last stats entry for position)
Questions
1. What is the source of the apparent data discrepancy?
2. Is
frontend
using the correct properties fromstate
payload for each of these metrics?