Pure spot/perp hedge quantity calculation for a caller-chosen target delta.
Rounds to venue amount precision and reports the residual delta after rounding. Candidate selection follows only the caller's venue policy and candidate list — this module never invents instruments or strategy.
Summary
Functions
Selects a hedge candidate under venue_policy and sizes it to target_delta.
Returns the venue quantity step and delta carried by one signed candidate unit.
Types
@type venue_policy() :: :same_only | :prefer_same_venue | :cross_allowed
Functions
@spec calculate(number(), number(), [candidate()], venue_policy(), [String.t()]) :: {:ok, map()} | {:error, atom() | {atom(), term()}}
Selects a hedge candidate under venue_policy and sizes it to target_delta.
current_delta is post-option, pre-hedge exposure in underlying units.
A zero needed hedge returns quantity 0 with residual current - target.
Inverse candidates use a positive caller :price, then a price-bearing
caller :quote, before falling back to price fields in market.info.
@spec candidate_terms(map()) :: {:ok, %{ market: Bourse.Market.t(), kind: term(), amount_step: float(), delta_per_unit: float() }} | {:error, atom()}
Returns the venue quantity step and delta carried by one signed candidate unit.