Read this material
https://www.investopedia.com/articles/investing/111315/deducting-stock-losses-guide.asp