Bourse.OptionProposal.Optimizer (bourse v0.1.0)

Copy Markdown View Source

Exact bounded optimization for caller-approved option-risk instruments.

The caller supplies every instrument, side, quantity bound, objective, weight, tolerance, hard limit, and tie-break rule. The optimizer searches only those finite venue-valid quantity grids. It returns a v1-shaped plan when feasible and a labelled diagnosis when no grid point satisfies every objective and hard limit.

Summary

Functions

Solves one finite caller-authored option-risk problem.

Types

instrument()

@type instrument() :: %{
  :id => term(),
  :venue => String.t(),
  :account => term(),
  :symbol => String.t(),
  :side => String.t(),
  :market => Bourse.Market.t(),
  :quantity_limits => %{min: number(), max: number()},
  optional(:greeks) => Bourse.InstrumentGreeks.t(),
  optional(:kind) => atom() | String.t(),
  optional(:price) => number(),
  optional(:type) => String.t()
}

objective()

@type objective() :: %{
  target: number(),
  tolerance: number(),
  weight: number(),
  underlying: String.t(),
  unit_convention: map()
}

problem()

@type problem() :: %{
  :instruments => [instrument()],
  :objectives => %{required(atom()) => objective()},
  :hard_limits => map(),
  :tie_break_policy => [atom()],
  :venue_policy => atom(),
  optional(:baseline_contributions) => [map()],
  optional(:max_combinations) => pos_integer()
}

Functions

optimize(problem)

@spec optimize(problem()) :: {:ok, map()} | {:error, term()}

Solves one finite caller-authored option-risk problem.

Option quantities are canonical base amounts and are checked with Bourse.Unified.OptionQuantity. At most one non-option delta hedge is accepted because the emitted plan.hedge deliberately retains the v1 singular shape.