1. Calculate the accounting, holding by holding
Everything else depends on this.
- Premium and discount amortize on the effective-interest method, per holding, at a constant effective yield, so there are no formulas to maintain.
- A callable bought at a premium amortizes to its earliest call date at the call price. Discounts accrete to maturity.
- Each holding accrues on its own day-count basis, read from the import file's Basis column. Include it for every holding: a file that leaves it out gets a default by security type.
- Realized gain or loss on sales, calls, and maturities is measured against amortized cost.
- Each posted close keeps the per-holding accrual and amortization detail behind its GL summary, so a reported number can be traced back to the holdings that produced it.