code for calculating investment status changes