If you use logreturns it becomes simpler:
logreturn on stock A: log(price_At+1/price_At)
logreturn on stock B: log(price_Bt+1/price_Bt)
then
total logreturn on pairs trade: logreturn on stock A + logreturn on stock B =
=log((price_At+1*price_Bt)/(price_At*price_Bt+1))=
=spreadt+1 - spreadt
Now it is all consistent, thanks to the property that $\log(x y)=\log(x)+\log(y)$
(Of course no one stops you from calculating simple returns as well, your program can print both. simplereturn = -1.0 + exp(logreturn)
)
(Also, I assumed hedge ratio of 1, like you did)