Framework for modeling financial systems using weighted automata, with analysis of worst-case and best-case outcomes