Bourse.PortfolioRisk.Snapshot (bourse v0.1.0)

Copy Markdown View Source

Point-in-time portfolio risk assembled across venue/account domains.

status is :complete only when every requested read and every applicable risk bucket is complete. A :partial snapshot keeps component data, failures, and blocked buckets queryable without presenting their partial sums as coherent totals.

Summary

Types

aggregate()

@type aggregate() :: map()

blocked_bucket()

@type blocked_bucket() :: map()

component()

@type component() :: %{
  :status => :ok | :error,
  :observed_at => integer(),
  optional(:data) => term(),
  optional(:error) => term(),
  optional(:source_timestamp) => integer() | nil
}

contribution()

@type contribution() :: map()

domain()

@type domain() :: %{
  venue: String.t(),
  account: term(),
  components: %{required(atom()) => component()},
  margin: {:ok, [map()]} | {:error, term()},
  collateral: {:ok, [map()]} | {:error, term()},
  available_capacity: {:ok, map()} | {:error, term()},
  account_modes: {:ok, [String.t()]} | {:error, term()},
  liquidation_state: {:ok, [map()]} | {:error, term()}
}

failure()

@type failure() :: map()

t()

@type t() :: %Bourse.PortfolioRisk.Snapshot{
  aggregates: [aggregate()],
  blocked_buckets: [blocked_bucket()],
  contributions: [contribution()],
  domains: [domain()],
  failures: [failure()],
  observed_at: integer(),
  status: :complete | :partial
}