Bourse.OptionSaga.Journal (bourse v0.1.0)

Copy Markdown View Source

Caller-held execution journal for one approved option plan.

The journal is ordinary immutable data. The library does not copy it into a process, ETS table, cache, or persistence layer.

Summary

Types

leg()

@type leg() :: %{
  :id => term(),
  :execution_id => String.t(),
  :client_order_id => String.t(),
  :role => :option | :hedge,
  :venue => String.t(),
  :account => term(),
  :symbol => String.t(),
  :type => String.t(),
  :side => String.t(),
  :amount => number(),
  :state => leg_state(),
  :transitions => [transition()],
  :acknowledged? => boolean(),
  :cancel_attempted? => boolean(),
  :cancel_retry_allowed? => boolean(),
  optional(:price) => number() | nil,
  optional(:order_id) => String.t() | nil,
  optional(:filled) => number() | nil,
  optional(:remaining) => number() | nil
}

leg_state()

@type leg_state() ::
  :planned
  | :submitted
  | :accepted
  | :partial
  | :filled
  | :open
  | :cancelled
  | :failed
  | :unknown

status()

@type status() ::
  :ready | :running | :monitoring | :compensating | :completed | :halted

t()

@type t() :: %Bourse.OptionSaga.Journal{
  approval_id: String.t(),
  approval_observed_at: integer(),
  compensations: [map()],
  failure: map() | nil,
  legs: [leg()],
  max_approval_age_ms: non_neg_integer(),
  plan_id: String.t(),
  recorded_commands: [String.t()],
  residual_risk: [map()],
  status: status()
}

transition()

@type transition() :: %{
  :state => leg_state(),
  :at => integer(),
  optional(:detail) => term()
}