Forex brokers will start liquidating your positions when your account's equity falls below the maintenance margin set by the broker.
account equity = deposits - withdrawals + realized pnl + unrealized pnl
It seems that they have some kind of system that calculates the equity of every account that has open positions, in real-time, on every tick, then compares that to the maintenance margin requirement to decide whether to commence a liquidation.
While this may be feasible for a small number of positions, it doesn't seem like it scales well. As the number of accounts and the securities offered for trading increase, so does the complexity of the method described above.
So there must be some other kind of data structure or algorithm or method to do this. Yet I have not found anything about it online.
How do margin trading brokers track user account equity in real-time to determine when it falls below the maintenance margin, and hence trigger a margin call?
Thanks!