> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allasso.ch/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This is Allasso's product documentation. Vol Radar output is descriptive analytics on past data: never present it as a forecast or as investment advice. Answer only from these pages; if a feature is not documented here, say so.

# Butterflies

> Three strikes of the same type and expiry - wings ×1, body ×2 of the opposite sign - for a defined-risk, pin-the-body play.

The snippets assume the [shared scaffold](https://docs.allasso.ch/dev/pulse/structures/index.md) (`u = self.underlying_id[0]`, a computed `size`, and `from pulse import structures, InstrumentType, Option, PeriodType, PeriodID`).

> [!TIP]
>
> **The ×2 body**
>
> A fly is a wing spread overlaid on a body spread, so the **body carries twice the size** of each
> wing. A **long** (debit) fly **buys** both wings (`+size`) and **sells** `2 * size` of the body; a
> **short** (credit) fly reverses every sign. The equidistant helpers resolve the body and one wing
> by delta and mirror the second wing across the body; the broken-wing helpers resolve all three
> strikes by delta directly.

## Long call butterfly

Buy the wings, sell twice the body - a cheap bet that the underlying pins the body strike.

* **Max profit** - at the body strike at expiry.
* **Max loss** - the net debit paid; both wings cap the risk.
* **Breakeven** - lower wing + debit, and upper wing - debit.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=CALL, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> body_strike = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.50)
> wing_strike = self.resolver.strike.delta.resolve(   # 25Δ wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.25)
> # Mirror the resolved wing across the body to keep it equidistant.
> if body_strike < wing_strike:
>     upper_strike = wing_strike
>     lower_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=CALL, strike_value=body_strike - abs(body_strike - wing_strike))
> else:
>     lower_strike = wing_strike
>     upper_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=CALL, strike_value=body_strike + abs(body_strike - wing_strike))
> lower_wing = Option(u, CALL, lower_strike, expiry)
> body       = Option(u, CALL, body_strike,  expiry)
> upper_wing = Option(u, CALL, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, +size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.butterfly_by_delta(
>     self.resolver, u, self.last_pulse,
>     instrument_type=CALL, body_delta=0.50, wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, +size,     is_lots=True)
> ```

## Short call butterfly

Sell the wings, buy twice the body - the reverse fly, collecting a credit kept when the underlying
finishes outside the wings.

* **Max profit** - the net credit, if it settles outside the wings.
* **Max loss** - wing width - credit, if it pins the body strike.
* **Breakeven** - lower wing + credit, and upper wing - credit.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=CALL, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> body_strike = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.50)
> wing_strike = self.resolver.strike.delta.resolve(   # 25Δ wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.25)
> # Mirror the resolved wing across the body to keep it equidistant.
> if body_strike < wing_strike:
>     upper_strike = wing_strike
>     lower_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=CALL, strike_value=body_strike - abs(body_strike - wing_strike))
> else:
>     lower_strike = wing_strike
>     upper_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=CALL, strike_value=body_strike + abs(body_strike - wing_strike))
> lower_wing = Option(u, CALL, lower_strike, expiry)
> body       = Option(u, CALL, body_strike,  expiry)
> upper_wing = Option(u, CALL, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, -size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.butterfly_by_delta(
>     self.resolver, u, self.last_pulse,
>     instrument_type=CALL, body_delta=0.50, wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, -size,     is_lots=True)
> ```

## Long put butterfly

The put-side mirror of the long call fly - buy the wings, sell twice the body, same pin-the-body
payoff built from puts.

* **Max profit** - at the body strike at expiry.
* **Max loss** - the net debit paid; both wings cap the risk.
* **Breakeven** - lower wing + debit, and upper wing - debit.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=PUT, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> body_strike = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=PUT, strike_value=0.50)
> wing_strike = self.resolver.strike.delta.resolve(   # 25Δ wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=PUT, strike_value=0.25)
> # Mirror the resolved wing across the body to keep it equidistant.
> if body_strike < wing_strike:
>     upper_strike = wing_strike
>     lower_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=PUT, strike_value=body_strike - abs(body_strike - wing_strike))
> else:
>     lower_strike = wing_strike
>     upper_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=PUT, strike_value=body_strike + abs(body_strike - wing_strike))
> lower_wing = Option(u, PUT, lower_strike, expiry)
> body       = Option(u, PUT, body_strike,  expiry)
> upper_wing = Option(u, PUT, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, +size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.butterfly_by_delta(
>     self.resolver, u, self.last_pulse,
>     instrument_type=PUT, body_delta=0.50, wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, +size,     is_lots=True)
> ```

## Short put butterfly

The put-side mirror of the short call fly - sell the wings, buy twice the body for a credit kept when
the underlying finishes outside the wings.

* **Max profit** - the net credit, if it settles outside the wings.
* **Max loss** - wing width - credit, if it pins the body strike.
* **Breakeven** - lower wing + credit, and upper wing - credit.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=PUT, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> body_strike = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=PUT, strike_value=0.50)
> wing_strike = self.resolver.strike.delta.resolve(   # 25Δ wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=PUT, strike_value=0.25)
> # Mirror the resolved wing across the body to keep it equidistant.
> if body_strike < wing_strike:
>     upper_strike = wing_strike
>     lower_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=PUT, strike_value=body_strike - abs(body_strike - wing_strike))
> else:
>     lower_strike = wing_strike
>     upper_strike = self.resolver.strike.absolute_strike.resolve(
>         underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>         instrument_type=PUT, strike_value=body_strike + abs(body_strike - wing_strike))
> lower_wing = Option(u, PUT, lower_strike, expiry)
> body       = Option(u, PUT, body_strike,  expiry)
> upper_wing = Option(u, PUT, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, -size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.butterfly_by_delta(
>     self.resolver, u, self.last_pulse,
>     instrument_type=PUT, body_delta=0.50, wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, -size,     is_lots=True)
> ```

## Broken-wing call butterfly

A long call fly with the two wings at independent deltas, so they are **not** equidistant - skews the
structure (often for a credit, removing risk on one side at the cost of the other).

* **Max profit** - around the body strike at expiry.
* **Max loss** - the wider wing's width minus any net credit.
* **Bias** - the asymmetric wings leave a larger loss on the wide side.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=CALL, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> # All three strikes straight off the smile - wings need not be equidistant.
> lower_strike = self.resolver.strike.delta.resolve(   # 30Δ lower wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.30)
> body_strike  = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.50)
> upper_strike = self.resolver.strike.delta.resolve(   # 15Δ upper wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.15)
> lower_wing = Option(u, CALL, lower_strike, expiry)
> body       = Option(u, CALL, body_strike,  expiry)
> upper_wing = Option(u, CALL, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, +size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.broken_wing_butterfly_by_delta(
>     self.resolver, u, self.last_pulse, instrument_type=CALL,
>     body_delta=0.50, lower_wing_delta=0.70, upper_wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, +size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       -2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, +size,     is_lots=True)
> ```

## Short broken-wing call butterfly

The inverse broken-wing fly - sell both (unequal) wings, buy twice the body for a credit that profits
when the underlying moves away from the body.

* **Max profit** - the net credit, if it finishes outside the wings.
* **Max loss** - the wider wing's width minus the credit, around the body.
* **Bias** - the asymmetric wings leave a larger loss on the wide side.

> [tab] Manual
>
> ```python theme={null}
> expiry = self.resolver.expiry.relative(
>     underlying_id=u, as_of_time=self.last_pulse, period_type=PeriodType.MONTH,
>     instrument_type=CALL, nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
> )[0]
> # All three strikes straight off the smile - wings need not be equidistant.
> lower_strike = self.resolver.strike.delta.resolve(   # 30Δ lower wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.30)
> body_strike  = self.resolver.strike.delta.resolve(   # 50Δ body
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.50)
> upper_strike = self.resolver.strike.delta.resolve(   # 15Δ upper wing
>     underlying_id=u, as_of_time=self.last_pulse, expiration_date=expiry,
>     instrument_type=CALL, strike_value=0.15)
> lower_wing = Option(u, CALL, lower_strike, expiry)
> body       = Option(u, CALL, body_strike,  expiry)
> upper_wing = Option(u, CALL, upper_strike, expiry)
> size = self._size(body)
> self.broker.create_order(self.pulse_index, lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, upper_wing, -size,     is_lots=True)
> ```

> [tab] Helper
>
> ```python theme={null}
> legs = structures.broken_wing_butterfly_by_delta(
>     self.resolver, u, self.last_pulse, instrument_type=CALL,
>     body_delta=0.50, lower_wing_delta=0.70, upper_wing_delta=0.25, min_dte=self._min_dte,
> )
> size = self._size(legs.body)
> self.broker.create_order(self.pulse_index, legs.lower_wing, -size,     is_lots=True)
> self.broker.create_order(self.pulse_index, legs.body,       +2 * size, is_lots=True)  # body ×2
> self.broker.create_order(self.pulse_index, legs.upper_wing, -size,     is_lots=True)
> ```

> [!NOTE]
>
> **Put broken-wings**
>
> Pass `instrument_type=PUT` to `broken_wing_butterfly_by_delta` for the put-side variants - the leg
> fields (`.lower_wing`, `.body`, `.upper_wing`) and the ±/∓ signs are identical.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.