In order to have a retirement plan, you must have earned income. Investment income is not earned income. So in this sense it is correct that in order to contribute to a retirement plan, the business entity must be generating compensation that is subject to social security and medicare taxes.
However, you have not indicated whether you plan to set up a company retirement plan, or whether you are just talking about contributing money to an IRA. If you have another job (a "real" job), then you can contribute to an IRA based on that income, up to the maximum annual contribution. It does not matter exactly where the money is coming from. And having earned income from the LLC will not allow you to contribute more to an IRA. It might even reduce the amount you can contribute, because when your income is too high, there are contribution limits that kick in.
You are correct that there is no easy way to determine which securities were held for less than 30 days. You have to manually review each transaction. It is possible that third-party software such as Tradelog could provide a filter that would help. Or if you can download all of your transactions into Excel, you could probably write a script or a formula in Excel that would look at the date values, and filter those transactions for which the amount of time between opening and closing is less than 30 days. I am not proficient enough in Excel to do that, but I'm pretty sure it can be done.
But you need to do more research and probably talk with a tax advisor who has experience with professional trading. I am a tax advisor, but trading is not my area of expertise. I am not familiar with the 30-day rule, but that doesn't mean anything.
I will offer the following advice:
If your intent is to have the LLC set up a company retirement plan such as a 401(k), then you will definitely need the services of a firm that specializes in creating and managing retirement plans for small businesses. If you are just talking about contributing to an IRA or a SEP, you can do that on your own. But as I mentioned earlier, having earned income from trading will not increase the IRA contribution limits. If you already have salary or wages from another job, that will allow you to contribute to an IRA, regardless of where you get the money.
Are you absolutely certain that you want the LLC to be an S-corp?
An LLC, if it has only one member, is generally taxed as a sole proprietorship, and that means that you would simply put the trading income on Schedule C, and it would be treated as earned income. If the LLC has more than one member, then it is generally taxed as a partnership, the trading income would flow to Schedule K-1. If the member is identified as an active member and a general partner, then it is considered self-employment income, and that is also earned income.
Choosing S-corp status is an optional election that is available to an LLC. But one of the major advantages, and in many cases arguably the only advantage, is that S-corp status allows you to treat some of the company's income as investment income instead of earned income. And that seems to be the opposite of what you are trying to accomplish.
In an S-corp, you get to designate a certain portion of the income as salary to the shareholders who are actively working and running the business, and the rest is treated as investment income. The portion treated as investment income is not subject to social security and medicare tax, and that is considered a major advantage to many taxpayers. But if your goal is to maximize retirement contributions, it may not be a real benefit.
Also, when you have an S-corp, the shareholders who are actively working in the business must receive a salary. They must be employees of the company. The company must set up a full-blown payroll system, and the company has to withhold federal and state taxes. The working shareholders are genuine employees, and they get a Form W-2 at the end of the year. They cannot get paid as independent contractors with a 1099-MISC (or 1099-NEC, as the new form is called). And the salary cannot be reported on the Schedule K-1. Only the investment income portion appears on the K-1. The salary must be processed as payroll, and it must be reported on Form W-2.
These rules apply to all S-corps, regardless of what kind of business they are in. Active trading is not an exception. The only way an S-corp can avoid having employees and payroll is if all the income is investment income. But again, that is the opposite of what you are trying to accomplish.
Are you sure you want all the baggage associated with payroll??
You may be able to achieve your objective by leaving the LLC in its default status, i.e., a sole prop if it has one member, or a partnership if it has multiple members.
BMK