Security groups
A security group is a primary security and its secondary securities. You add a security group to a model or a sleeve with a target weight, as you add a primary security.
When AdviceCloud builds a rebalance, it gives the primary security priority over the secondary securities. It uses a secondary security in place of the primary security in some cases, such as for tax-loss harvesting or to sell out of a position. The treatment of each secondary security is like_primary (Treat like primary), hold_only (Hold only) or sell_no_tax (Sell if no tax consequences).
To see which models and sleeves include a security group, call List the models and sleeves that use a security group.
List security groups
Returns your firm's security groups, in ascending order of `id`. Unless you send `metrics=true`, the list does not include each security group's secondary securities: call **Get a security group** for those.
Create a security group
Creates a security group with the name, primary security and secondary securities in the request body. To use the security group, add it to a model or a sleeve with a weight.
Get a security group
Returns the security group with the given ID, with its secondary securities. If your firm has no security group with that ID, the response is `404`.
Update a security group
Replaces the security group with the given ID with the one in the request body. Send every field: secondary securities that you leave out of `secondarySecurities` are removed from the security group. Other fields in the body, such as `id` or `secondaryTo`, are ignored. If your firm has no security group with that ID, the response is `404`.
Delete a security group
Deletes the security group with the given ID, and removes it from each model and sleeve that includes it. The other weights of those models and sleeves do not change. To see those models and sleeves first, call **List the models and sleeves that use a security group**. Returns `deleted: true`. If your firm has no security group with that ID, the response is `404`.
List the models and sleeves that use a security group
Returns your firm's models and sleeves that include the security group with the given ID: models first, then sleeves, each in ascending order of `id`. A model that includes the security group only through a sleeve is not listed. Call it before **Delete a security group**. If your firm has no security group with that ID, the response is `404`.