Banks should evaluate whether a borrower is likely to default. The author applies several techniques in the extensive mathematical literature of stochastic optimal control/dynamic programming to derive an optimal debt in an environment where there are risks on both the asset and liabilities sides. The vulnerability of the borrowing firm to shocks from either the return to capital, the interest rate or capital gain, increases in proportion to the difference between the Actual and Optimal debt ratio, called the excess debt. As the debt ratio exceeds the optimum, default becomes ever more likely. This paper is "A Tale of Two Crises" because the analysis is applied to the agricultural debt crisis of the 1980s and to the sub-prime mortgage crisis of 2007. A measure of excess debt is derived, and the author shows that it is an early warning signal of a crisis.