For regular brokerage purchases and sales of stocks:
From: State of California FTB Pub. 1031 - 2019
Guidelines for Determining
Resident Status
Income Taxable by California
Part-year residents of California are taxed on all income
received while a resident and only on income from
California sources while a nonresident.
Sale of Stocks and Bonds
The gain or loss from the sale of stocks or bonds has a
source where you are a resident at the time of the sale. If buying and selling stocks and bonds is your trade or business, see “Business Income (or Loss)” on page 7 for more information.
Example 15 – You are a resident of Oregon and sell stock
of a California corporation at a gain.
Determination: Because you are an Oregon resident,
the gain has an Oregon source. The gain is not taxable by
California.
Example 16 – You are a resident of California and sell
stock of a Kansas corporation at a gain.
Determination: Because you are a California resident,
you are taxed on all income, regardless
And: State of California FTB Pub. 1100
Taxation of Nonresidents and Individuals Who Change Residency - Section H Capital Gains and Losses
Part-Year Resident
If you changed your residency during 2009 [example year], compute income and deductions using resident rules for the period of the year you were a California resident and nonresident rules for the period of the year you were a nonresident
So when you purchased doesn't generate a gain/loss event, but when you sold which then "captured" does. Do note that Prorate both capital loss carryover amounts based upon the period of California residency and the period of nonresidency during the year.
I also agree with the other poster that you should confirm your Non-Residency status as described in Pub 1031.