Recording and Persisting Position Cost Basis in a Trading Strategy
Summary
This forum exchange addresses how a strategy can retrieve the cost basis of a contract it already holds, so later decisions can account for current profit or loss. Participants advise maintaining the value in strategy-managed state: record it when trade notifications arrive, using callbacks such as trade or trade-update handlers, and persist the stored value as needed.
The discussion highlights a practical distinction between submitting an order and receiving a fill: an order may remain unfilled, so recording intent at submission can misstate the position’s actual cost. However, the original poster says the options strategy template in question does not expose the suggested callbacks. The thread does not resolve how to handle that template limitation or specify accounting rules for partial fills, multiple entries, or position changes, so the callback advice may require adaptation to the framework and strategy type.
Key ideas
- Track cost basis from executed-trade notifications rather than assuming an order has filled.
- Keep the recorded value in strategy-managed state and persist it when needed.
- The suggested trade callbacks may not be available in every options strategy template.
- The exchange does not explain cost-basis handling for partial fills or changing positions.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.