Let's assume that an alien who's never been to the US before moves there and becomes a resident alien for that financial year due to fulfilling their substantial presence. The alien owns financial assets that he's been trading over the years. If he decides to cash out an amount of those assets, how would the taxes be calculated? And does it matter how long he's been holding those assets before deciding to cash out? Given that the assets were acquired before moving to the US, and that the alien has never made any trades while in the US up till that point. Also, would it be better if the alien wasn't a resident alien for that financial year?
If you are taxable in the US for a certain tax year, that applies to all income of that year, no matter at which date you made it.
So selling any investment - including crypto - on January 2, and then moving to the US on June 29th makes any gains fully taxable (The tax rate could be 0%, depending on your situation, but that’s a different question).
If your question is “how would they know?“, well, they probably would not know. But this would be cheating on taxes, and - even if found out only much later - could end up in your residency permits are being revoked, and even your potential future naturalization and citizenship being revoked - retroactively. Don’t start your life in the US with a crime.