State tax filing

IF you sold all your holdings in a stock, there is no need to "average."  You simply add all your "buys", which may include reinvested dividends, and use that sum.  IF you sold sold some of your holdings of a stock you use First-in, First-out to determine the basis.