General equilibrium foundations of finance