A deadlock is a set of threads that each wait for something another one holds, so none can move. It needs four things at once: exclusive locks, threads holding one lock while waiting for another, no way to take a lock away, and a cycle of waiting. Remove any one and it cannot happen.
In practice that means: lock in one fixed order everywhere (by account id, or a documented hierarchy such as book before risk), or lock everything you need at once with std::scoped_lock; never call code you do not control (a callback, a virtual function) while holding a lock, because it may lock something too; and never lock a mutex you already hold: a std::mutex is not recursive, so a public function that calls another public function deadlocks on itself.
When the simulator finds every thread waiting, it stops the program and reports which thread holds which mutex and the line where each is waiting. Read that report before changing code.
Threads here are simulated. Your program runs on one real thread while a scheduler switches between your threads at shared reads and writes, locks, atomic operations, waits, yields and sleeps, and every test runs under 12 different schedules. The order things can happen in, races at those points and deadlocks are faithful. Real parallel speed-up and weak memory-order effects are not.
A fixed lock order breaks the cycle.