projects /
optionstruct
Exact max loss, max profit, breakevens, and margin for any multi-leg options structure, in pure Python.
Build a structure from legs, then ask it for its expiration-payoff risk in real dollars.
short = Leg.short(OptionContract("XSP", OptionType.PUT, "740", exp))
long_ = Leg.long(OptionContract("XSP", OptionType.PUT, "735", exp))
spread = Structure.vertical(short, long_)
r = spread.risk(premiums)
r.net_premium # Decimal('150.00')
- Exact, not sampled. Expiration P&L is piecewise-linear with kinks only at strikes, so extremes and breakevens are computed at the vertices. Unbounded structures report
UNBOUNDEDrather than a fake large number. - Construct, then validate. The core builds any structure without judgment; strategy checks are opt-in validators.
- No dependencies: stdlib and
Decimalonly.