Is it a good idea to buy a stock before its earnings come out if I believe that there will be a surprise and then sell after the report comes out? Will the gains be substantial enough for me to take this risk?
It's an absolutely wonderful idea to "buy a stock before its earnings come out" if you are adept at selecting the stocks that will have positive earnings surprises. If you don't have that ability then not so much.
Many traders utilize option strategies to take advantage of this volatility but let's not go there.
That is the exact thought of many other market participants and what drives the price up before the results come out.
The problem is, that even if the results do supprise on the up side, much of the price rise is already priced in, so when the results do come out, the price actually falls, as those in early take profits.