Bourse.OptionProposal.MarginImpact (bourse v0.1.0)

Copy Markdown View Source

Venue-local margin evidence and supported candidate-plan comparison.

Deribit and OKX expose joint-plan simulations and can be ranked within one venue/account/collateral domain. Bybit exposes a single-order quote and Derive exposes a position-scenario result; those observations stay individually labelled and never enter a portfolio-offset calculation.

Summary

Functions

Returns the provider-authoritative margin capability classifications.

Returns one venue's margin capability or an explicit not-supported error.

Evaluates caller-supplied plans and ranks only eligible joint-plan results.

Types

candidate_plan()

@type candidate_plan() :: %{
  :id => term(),
  :exchange => Bourse.Exchange.t(),
  :account => term(),
  :account_mode => atom(),
  :provider_params => map(),
  optional(:baseline_provider_params) => map(),
  optional(:request_opts) => keyword()
}

capability()

@type capability() :: %{
  label: capability_label(),
  endpoint: atom(),
  account_modes: [atom()],
  official_reference: String.t()
}

capability_label()

@type capability_label() ::
  :joint_plan_simulation
  | :single_order_margin_quote
  | :position_scenario_margin

problem()

@type problem() :: %{
  candidate_plans: [candidate_plan()],
  objective: :minimize | :maximize,
  weights: %{required(atom()) => number()},
  tie_break_policy: [atom()]
}

result()

@type result() :: %{
  observations: [map()],
  comparisons: [map()],
  objective: :minimize | :maximize,
  weights: %{required(atom()) => number()},
  tie_break_policy: [atom()],
  collateral_domains: [map()],
  cross_venue: map(),
  portfolio_margin_netting: false
}

Functions

capabilities()

@spec capabilities() :: %{required(String.t()) => capability()}

Returns the provider-authoritative margin capability classifications.

capability(venue)

@spec capability(String.t() | atom()) ::
  {:ok, capability()} | {:error, Bourse.Error.t()}

Returns one venue's margin capability or an explicit not-supported error.

compare(problem)

@spec compare(problem()) :: {:ok, result()} | {:error, Bourse.Error.t()}

Evaluates caller-supplied plans and ranks only eligible joint-plan results.

Ranking is local to one venue, account, account mode, and provider collateral scope. The result deliberately has no global cross-venue winner.