Average Spread
I suggest you use a moving average. The way you are doing it, the sum of spread will just get larger on every read and at some point it could overflow, and its accuracy with the division will have more round off error as both numerator and divisor grows.
I would suggest using an EMA, because it is can be calculated incrementally very efficiently, and gives more weight to the more recent data.
Here is a PDF paper that describe the maths and the implementation ... Incremental calculation of weighted mean and variance

Hello, I am trying to obtain the average spread, for which I am doing the following:
I wanted to know if this overloads, if it is the correct and efficient way to do it? or else you shouldn't do it that way. Thank you