State tax filing

can someone explain this further using an example? Lets say i moved out of CA to VT in May 2021, and sold 2 stocks this year:

  • Stock A: i sold a stock that i owned in Feb  2021 $80 gain 
  • Stock B: Sold a stock i owned in Nov 2021 while in VT for a $100 gain

 

For earned from CA source, is it: 

  • Stock A: $80 earned from CA source if non resident for entire year, $80 earned when CA resident, $0 earned from CA source if non resident
  • Stock B: $0 earned from CA source if non resident for entire year, $0 earned when CA resident, $0 earned from CA source if non resident