Hi

When placing a  multi-leg option trade (butterfly, iron condor etc.), how to close the trade and its related positions later when a certain criteria is met, for example, exit @ 30% profit or 7 days before expiration? 

Any example Python code?  Thanks!