How is margin for F&O calculated

I understand that there is a margin calculator, but I want to make an excel sheet/Python code for a list of possible strategies (iron condors or calendar spreads).
I want to select/filter strategies based on margin required, max return %, max loss % etc

What parameters this margin depends on?
What is the logic followed by Zerodha to arrive at this margin value?

I am not looking for exact value, I am ok with approximate value (5% error is fine), as long as it changes proportionately, it is fine because this is for comparison only.