Theoretically optimal responses of banks to various liquidity and solvency shocks are modelled. The proposed framework is based on a risk-adjusted return portfolio choice in multiple periods subject to the default risk related either to liquidity or solvency problems. Performance of the model and sensitivity of optimal balance sheet structures to some key parameters of the model are illustrated in a specific calibrated setup. The results of the simulations shed light on the effectiveness of the liquidity and solvency regulation. The flexible implementation of the model and its semi-analytical solvability allows for various easy applications of the framework for the macro-prudential policy analysis.