To improve the order placement system in Angelone, instead of having separate fields for net_buy_average_price
and net_sell_average_price
, you can introduce a combined field called net_average_price
. This new field will represent a weighted average of both buy and sell prices, which simplifies the calculation for Mark-to-Market (MTM) and Profit & Loss (P&L).
This approach ensures that:
- Simplified Data Representation: One field (
net_average_price
) instead of two (net_buy_average_price
andnet_sell_average_price
), reducing complexity in data handling. - Accurate MTM and P&L Calculation: With a combined average price, the calculations for MTM and P&L become straightforward and less error-prone, as the system would only need to reference a single value.
- Consistency Across Positions: Whether the order is for a new position or a carry-forward one, using
net_average_price
ensures uniformity in how prices are recorded and interpreted.
By implementing net_average_price
, you effectively address MTM and P&L issues related to open and carry-forward positions, making the overall system more robust and user-friendly.