Your making it more complicated than it should be. It's price improvement over the best available quoted bid or ask price in the Markets.In my experience, The common approach used by big brokers to calculate the price improvement is the difference between the filled price and the bid price for sell order, the difference between the filled price and the ask price for buy order. They don’t compare against NBBO, Fidelity specifically lists the price improvement they give you.
BID $9.90
ASK $10.00
if Execution occurred at $9.95 for a buy order then price improvement would be $0.05 per share.
