This paper develops a model of the credit market where the equilibrium lending mechanism,
as well as the economy's aggregate investment and output, are endogenously determined.
It predicts that the optimal contract is one of two kinds: either with intensive monitoring
by investors to overcome entrepreneurs' incentive problems, such as most of intermediated
nancing, or with heavy reliance on entrepreneurs, such as market nancing. We show that the
observation that bank lending falls relative to corporate bond issuance during recessions can be
explained by movements in the economy's real factors, such as a decline in average investment
returns, a contraction of credit supply, and paradoxically, maybe even an increase of investment
demand (which worsens credit market condition and intensi es incentive problems).