Key assumptions
The average-price math assumes each entered lot belongs to the same security and should be weighted only by quantity and cost. Corporate actions, taxes, and exact broker contract-note adjustments need to be normalized by you if you want a fully loaded basis.