> ## 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.

# Futures hedge basics

> A short option carries directional risk through its delta.

Here we sell a 30-delta put on Brent crude (`COM.BRN`), then neutralise the position's delta each pulse by trading a front-month future - the building block behind the [delta-hedged strangle](https://docs.allasso.ch/dev/pulse/notebooks/delta-hedged-strangle.md).

**What this shows**

* Reading a live delta from the datafeed.
* Sizing a futures hedge to offset the option delta (a future has delta 1).
* Rolling the put monthly and rebalancing the hedge in place with `trade.rebalance(...)`.

```python theme={null}
from pulse import (
    Instrument, Option, Future, InstrumentType, PeriodID, PeriodType,
    Strategy, run_sequentially,
)
import pulse.charts as pcharts
import plotly.io as pio

pio.renderers.default = "notebook_connected"
```

```python theme={null}
class ShortPutFuturesHedge(Strategy):
    """Short a put, then flatten its delta each pulse with a front-month future."""

    def __init__(self, underlying_id, put_delta=0.30, min_dte=30, lots=5.0):
        super().__init__(
            name=f"Short Put + Futures Hedge ({put_delta * 100:.0f}d)",
            description="Sells a put and flattens delta each pulse with a future.",
            underlying_id=underlying_id,
        )
        self._put_delta = put_delta
        self._min_dte = min_dte
        self._lots = lots

    def _last(self, instrument):
        return self.datafeed.instrument.last(instrument, self.last_pulse)

    def _resolve_put(self) -> Instrument:
        expiry = self.resolver.expiry.relative(
            underlying_id=self.underlying_id[0], as_of_time=self.last_pulse,
            period_type=PeriodType.MONTH, instrument_type=InstrumentType.PUT,
            nth=1, period_id=PeriodID.ALL, min_dte=self._min_dte,
        )[0]
        strike = self.resolver.strike.delta.resolve(
            underlying_id=self.underlying_id[0], as_of_time=self.last_pulse,
            expiration_date=expiry, instrument_type=InstrumentType.PUT,
            strike_value=self._put_delta,
        )
        return Option(underlying_id=self.underlying_id[0], instrument_type=InstrumentType.PUT,
                      expiration_date=expiry, strike=strike)

    def _hedge_quantity(self, put) -> float:
        # Short put: position delta = put_delta * (-lots). Cancel it with the future (delta 1).
        position_delta = self._last(put).delta * (-self._lots)
        qty = -position_delta
        return qty if qty != 0 else 1e-6

    def _should_roll(self) -> bool:
        puts = self.get_trades_by_tags(["put"])
        if not puts:
            return True
        return self._last(puts[0].instrument).dte < self._min_dte

    def _roll(self) -> None:
        self.close_trades_by_tags(["put"])
        self.close_trades_by_tags(["hedge"])
        put = self._resolve_put()
        self.broker.create_order(self.pulse_index, put, -self._lots, tags=["put"], is_lots=True)
        futures_expiry = self.resolver.expiry.relative(
            underlying_id=self.underlying_id[0], as_of_time=self.last_pulse,
            period_type=PeriodType.MONTH, instrument_type=InstrumentType.FUTURE,
            nth=1, period_id=PeriodID.ALL, min_dte=self._last(put).dte,
        )[0]
        self.broker.create_order(
            self.pulse_index,
            Future(underlying_id=self.underlying_id[0], expiration_date=futures_expiry),
            self._hedge_quantity(put), tags=["hedge"], is_lots=True,
        )

    def _rebalance_hedge(self) -> None:
        puts = self.get_trades_by_tags(["put"])
        hedges = self.get_trades_by_tags(["hedge"])
        if not puts or not hedges:
            return
        hedges[0].rebalance(self._hedge_quantity(puts[0].instrument))

    def on_update(self) -> None:
        if self._should_roll():
            self._roll()
        else:
            self._rebalance_hedge()
```

```python theme={null}
strategy = ShortPutFuturesHedge("COM.BRN", put_delta=0.30, min_dte=30, lots=5)
result = run_sequentially(
    [strategy], initial_equity=1_000_000,
)[0]
print("ok", "|", f"{result.execution_time:.1f}s", "|", f"{len(strategy.trades)} trades")
```

```text Output theme={null}
ok | 4.3s | 276 trades
```

## Equity

```python theme={null}
pcharts.plot_equity(strategy)
```

![Chart output 1](https://mintcdn.com/allasso/5PMuHlzYzX1FYPYw/images/pulse/notebooks/futures-hedge-basics-1.png?fit=max\&auto=format\&n=5PMuHlzYzX1FYPYw\&q=85\&s=8f3019930b53a48dec684ebe78e54aea)

The future is rebalanced every pulse to offset the put's delta, so the equity curve reflects the
option's time decay far more than the direction of crude. For the full picture - rolling a two-legged
strangle and inspecting the hedge cycle by cycle - see
[Delta-hedged strangle](https://docs.allasso.ch/dev/pulse/notebooks/delta-hedged-strangle.md).


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