The whole cost basis thing used to be a real mess especially with acquisitions, spinoffs, and so forth. At one point when I was selling shares for a very long ago company from employee stock purchase and maybe old style options as well, I just came up with a reasonable average and called it a day.
It’s generally easier today.