Investing or trading on margin is intended to allow you to trade while you are waiting for previous trades to settle. It's not meant to be a loan, but it is exploited that way by both banks and traders at their own risk. It's simple enough to fix, only allow margin to cover the amount of money waiting to be settled. In other words if a trade hasn't settled then the funds are not available for trading.