Generally speaking, it’s safe to trade stocks online. But that doesn’t mean you’ll never be affected by threats. Online stock brokers are doing all they can to minimize those threats.
But as a responsible online trader, you also have to do your part to implement your security measures. Review your broker’s security measures, implement your own, and use common sense when trading, and you should come out unscathed.