Generalized Framework for Applying the Kelly Criterion to Stock Markets