That's right, security should come first. Also, you need to minimize the risks as much as possible, then you will not be able to lose everything.
I know only one way to minimize risks when trading, it is to work only with large exchanges, and everything else depends on luck.
There are many more ways to reduce risks when trading. Pay attention to trading bots.