(A)The term “earned income” means—(i)
wages, salaries, tips, and other employee compensation, but only if such amounts are includible in gross income for the taxable year, plus
the amount of the taxpayer’s net earnings from self-employment for the taxable year (within the meaning of section 1402(a)), but such net earnings shall be determined with regard to the deduction allowed to the taxpayer by section 164(f).
"(a)Net earnings from self-employment The term “net earnings from self-employment” means the gross income derived by an individual from any trade or business carried on by such individual, less the deductions allowed by this subtitle which are attributable to such trade or business," See https://www.law.cornell.edu/uscode/text/26/1402#a
A trade or business is where you produce goods and/or services with the intention of making a profit.
Buying and selling stocks is not a business in that sense, it is merely managing your investments, making it in the same category as dividends and interest.
**Mark the post that answers your question by clicking on "Mark as Best Answer"