Prime brokers and hedge funds form relationships in a matching market. What are the determinants of these matches? How did they change after the financial crisis? I estimate a matching model in which part of the profits of prime brokers and hedge funds depends on variables that are defined at the level of the entire portfolio of clients that a prime broker serves. I show that prime brokers and their client hedge funds choose to have trading relationships with each other in a manner that reflects the benefits of specialization. Moreover, prime brokers preferred risky clients before the crisis, while they were averse to risky clients after the crisis. Identification follows from pairwise matching stability. I analyze the potential underlying economic mechanisms, mainly the cost advantages to a prime broker of collateral re-use between hedge fund clients. This is known as internalization. I estimate that the value of internalization for major prime brokers, such as Goldman Sachs, is around $100-200 million annually.