Sort:  

Most trading platforms will calculate this stuff for you and send you a 1099 but if you're doing this trading outside of something like that you'll have to come up with another solution.