In this paper, we study a credit network and, in particular, an interbank system in an agent-based model. To understand the relationship between business cycles and cascade of bankruptcies, we model a three-sector economy with goods, credit and interbank market. In the interbank market, the participating banks share the risk of bad debits, which may potentially spread one bank's crisis through the network of banks. Our agent-based model specifically sheds light on the correlation between the endogenous economic cycle and the trade-off between sharing risk and systemic risk. The purpose of the model is thus to determine whether the linear relationship proposed by Allen and Gale (2000) ceases to be valid during certain periods of the economic cycle.