Your sole proprietorships' profits and losses will cancel out, but you first have to account for each business on separate Schedule C forms: https://blog.taxact.com/schedule-c-self-employment-income/
Form 1040 will tell you to what extent (if any) that Schedule C losses can reduce your taxes on income from stocks.