# `DeltaCalc.Allocation`
[🔗](https://github.com/ZenHive/delta_calc/blob/v0.3.0/lib/delta_calc/allocation.ex#L1)

Subaccount allocation-envelope calculations.

## API Functions
| Function | Arity | Description | Param Kinds |
| --- | --- | --- | --- |
| `allocate` | 5 | Compute subaccount equity envelope from mode configuration. | `aum: value`, `mode_cfg: value`, `assets: value`, `weights: value`, `per_sub_cap_pct: value` |

# `allocate`

```elixir
@spec allocate(Decimal.t(), map(), [atom()], map(), Decimal.t()) :: map()
```

Compute subaccount equity envelope from mode configuration.

## Parameters

  * `aum` - Assets under management as a canonical decimal string; native Elixir callers may also pass Decimal or integer. (value)
  * `mode_cfg` - Mode config with :pct and :cap as canonical decimal strings; native Elixir callers may also pass Decimal or integer. (value)
  * `assets` - Asset symbols (interface compatibility) (value)
  * `weights` - Asset weight map (interface compatibility). Exact values use canonical decimal strings; native Elixir callers may also pass Decimal or integer. (value)
  * `per_sub_cap_pct` - Per-subaccount capital percentage (0-1) as a canonical decimal string; native Elixir callers may also pass Decimal or integer. (value)

## Returns

Map with :sub_eq, :init_margin, :reserve, :leftover Decimal fields (`map`)

```elixir
# descripex:contract
%{
  params: %{
    aum: %{
      description: "Assets under management as a canonical decimal string; native Elixir callers may also pass Decimal or integer.",
      kind: :value,
      schema: %{"type" => "string"}
    },
    mode_cfg: %{
      description: "Mode config with :pct and :cap as canonical decimal strings; native Elixir callers may also pass Decimal or integer.",
      kind: :value,
      schema: %{
        "additionalProperties" => false,
        "properties" => %{
          "cap" => %{"type" => "string"},
          "pct" => %{"type" => "string"}
        },
        "required" => ["pct", "cap"],
        "type" => "object"
      }
    },
    assets: %{
      description: "Asset symbols (interface compatibility)",
      kind: :value,
      schema: %{"items" => %{"type" => "string"}, "type" => "array"}
    },
    weights: %{
      description: "Asset weight map (interface compatibility). Exact values use canonical decimal strings; native Elixir callers may also pass Decimal or integer.",
      kind: :value,
      schema: %{"type" => "object"}
    },
    per_sub_cap_pct: %{
      description: "Per-subaccount capital percentage (0-1) as a canonical decimal string; native Elixir callers may also pass Decimal or integer.",
      kind: :value,
      schema: %{"type" => "string"}
    }
  },
  returns: %{
    type: :map,
    description: "Map with :sub_eq, :init_margin, :reserve, :leftover Decimal fields"
  }
}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
