The following court case confirms that unrelated business income tax (UBIT) applies to stock margin trading performed in an IRA or solo 401k plan: Bartels Trust v. U.S. (106 AFTR 2d 2010-6004 9/07/2010)
The Court of Appeals for the Federal Circuit held that income from securities purchased on margin is subject to unrelated business income tax (UBIT) even though the exempt entity was not engaged in a trade or business.
On another note, UBIT will also be triggered by investing Solo 401k plan funds in a trade or business through a partnership or LLC. However, UDFI does not apply to solo 401k funds that are invested in debt financed real estate where the sole owner of the property is the solo 401k.