Any transfer of financial instruments, such as stocks, in the primary or secondary markets involves 3 processes:
Execution is the transaction whereby the seller agrees to sell and the buyer agrees to buy a security in a legally enforceable transaction. All processes leading to settlement is called clearing, such as recording the transaction. Settlement is the actual exchange of money, or some other value, for the securities.
Clearing is the process of updating the accounts of the trading parties and arranging for the transfer of money and securities. There are 2 types of clearing: bilateral clearing and central clearing. In bilateral clearing, the parties to the transaction undergo the steps legally necessary to settle the transaction. Central clearing uses a third-party — usually a clearinghouse — to clear trades. Clearinghouses are generally used by the members who own a stake in the clearinghouse. Members are generally broker-dealers. Only members may directly use the services of the clearinghouse; retail customers and other brokerages gain access by having accounts with member firms. The member firms have financial responsibility to the clearinghouse for the transactions cleared. It is the responsibility of the member firms to ensure that the securities are available for transfer and that sufficient margin is posted or payments are made by the customers of the firms; otherwise, the member firms must cover any shortfalls. If a member firm becomes financially insolvent, only then will the clearinghouse make up for any shortcomings in the transaction.
For transferable securities, the clearinghouse aggregates the trades from each of its members and nets out the transactions for the trading day. At the end of the trading day, only net payments and securities are exchanged between the members of the clearinghouse. For options and futures and other types of cleared derivatives, the clearinghouse acts as a counterparty to both the buyer and the seller, so that transactions can be guaranteed, thereby virtually eliminating counterparty risk. Additionally, the clearinghouse records all transactions by its members, providing useful statistics, as well as allowing regulatory oversight of the transactions.
Settlement is the actual exchange of money and securities between the parties of a trade on the settlement date after agreeing earlier on the trade. Most settlement of securities trading nowadays is done electronically. Stock trades are settled in 2 business days (T+2), while government bonds and options are settled the next business day (T+1). The T+3 time for settlement that was prevalent before 2018 was shortened by the SEC in 2017 to T+2 (Source: SEC.gov | SEC Adopts T+2 Settlement Cycle for Securities Transactions). Forex transactions where the currencies are from North American countries have T+1 settlement date, while trades involving currencies outside of North America have a T+2 settlement date. In futures, settlement refers to the mark-to-market of accounts using the final closing price for the day. A futures settlement may result in a margin call if there are insufficient funds to cover the new closing price.
Modern day settlement and clearing evolved as a solution to the paper crisis of securities trading as more and more stock and bond certificates were being traded in the 1960's and 1970's, and payments were still made with paper checks. Brokers and dealers either had to use messengers or the mail to send certificates and checks to settle the trades, which posed a huge risk and incurred high transaction costs. At this time, the exchanges closed on Wednesday and took 5 business days to settle trades so that the paperwork could get done.
The first solution to this problem was to hold the certificates at a central depository — sometimes called certificate immobilization — and record change of ownership with a book-entry accounting system that was eventually done electronically. The New York Stock Exchange was the 1st to use this method through its Central Certificate Service, which eventually become the Depository Trust Company, then became a subsidiary of the Depository Trust and Clearing Corporation (DTCC). In Europe, Euroclear and Clearstream are the major central depositories. The process of eliminating paper certificates entirely is sometimes called dematerialization.
A further improvement was multilateral netting, which further reduced the number of transactions. Brokers have accounts at central depositories, such as the DTCC, which acts as a counterparty to every trade. So instead of sending payments and securities for each transaction, trades and payments were simply aggregated over the course of the day for each member broker, then were settled at the end of the day by transferring the net difference in securities and funds from 1 account at the depository to another.
For example, if a broker bought 100 shares of Microsoft for a customer and sold 50 shares of Microsoft for another customer, then the broker's net position is the accumulation of 50 shares of Microsoft, which would be recorded at the end of the market day. If the broker paid $25 per share to buy the 100 shares of Microsoft stock and sold the 50 shares for the same price on the same day, then the net difference plus transaction costs is debited from the broker's account at the end of the market day, and credited to the account of the central depository. Likewise, only 50 shares of Microsoft would be transferred to the broker's account, since this is the net difference of buying 100 shares and selling 50 shares.
Nowadays, governments around the world are promoting, or even requiring, central clearing, so that they can assess the systemic risk being imposed upon economies by their financial institutions, especially in the trading of derivatives, as was witnessed in the recent Great Recession of 2007-2009, when governments had to bail out many financial institutions because of a possible domino effect of major institutional failures. Central clearing is the best means of maintaining records so that financial risks to the economy can be better monitored.