Trying to find all possible combinations
This might be a bit advanced for your level (I'm not sure where you're coming from), but this is technically a Knapsack problem. If you're unfamiliar, I suggest first reading a bit from Wiki: https://en.wikipedia.org/wiki/Knapsack_problem

Each of your options has a maximum loss, and some value to you. (I'm not quite sure what your value function here is -- is it the maximum profit? Or maybe $(max\,\,profit - max\,\,loss)/2$?) You have a cap on how much loss you'll assume as risk: your available money. Given that cap, you want to maximize your value.

If you think of the Knapsack as carrying options, then you have a "weight" on each option that is its maximum loss, and your max "weight" you bear is the money you have to risk. You want to maximize the value of your knapsack.

Now, the Knapsack problem is in general NP-hard: this means that no one has a solution to always find the true optimum quickly, and it's unlikely there ever will be. But, there are algorithms that do extremely well for most problems, or give approximate solutions. The Wikipedia article discusses a few.

From a practical perspective, one of the best options is running this as an "Integer Linear Programming" problem, or ILP. Writing your own ILP solver is hard, but there are good software libraries for it. There are also lots of tutorials online about tackling stock portfolio problems with ILP libraries. For instance, a minute of googling "Integer linear progrmaming stock option" took me to https://www.mathworks.com/help/optim/ug/maximize-long-term-investments-using-linear-programming.html, which talks about doing it in MATLAB. You can find many more, probably for Python and Java and R, to name a few likely candidates.