TD Ameritrade and its largest shareholder TD Bank have agreed to acquire online brokerage Scottrade for an estimated $4 billion, marking a new wave of consolidation in a market hard hit by robo-advisors and a switch away from day trading to passive investments by consumers.