Skip to main content
These tools read and change a scenario’s rules. A scenario is a named rule set. A class’s rule can have a band (the share of the portfolio the class may take) and a size range (the same, for one holding). To make a scenario the active one, use save_portfolio. No tool on this page changes the active scenario.

Read rules

read
Returns every asset class with its id and aliases, each rule’s band, target, size range and short size range, the same rules as rules text, and the 5 latest restore points. Rules and rules_text come back empty, with a note, when no scenario is named or the portfolio has none active. Key arguments: scenario_id, or portfolio_id for its active scenario, or neither. With a scenario, the result also carries rule_changes: each class rule’s recent past values, newest first, as the rule was added, changed or removed with its values before and after.
read
Shows what applying a rules text would change, one row per class: change (added, changed, removed or unchanged) with before and after in band_min_pct, band_max_pct, target_pct and the size fields. An unchanged class has no after. Writes nothing. Key arguments: scenario_id, rules_text (the text).

Change rules with rules text

write, destructive
Replaces a scenario’s rules with a rules text. Classes not in the text lose their rules. Returns the same change rows as preview_rules and a restore_point_id. Key arguments: scenario_id, rules_text (the whole text, edited from get_rules’s rules_text).
write, destructive
Puts a scenario’s rules back exactly as they were at a restore point. Changes made after that point are undone too. Returns the same change rows as preview_rules. Key arguments: restore_point_id (from get_rules).

Change one class

write, destructive
Sets one asset class’s band, target, size range or short size range in a scenario and keeps every other rule. A band is the share of the portfolio the whole class may take; a size range is the same for one holding. Percentages are 0 to 100. A new rule needs a band or a size range, and the target needs a band and must sit inside it. A band of 0 and 0 means none of the class. Send the two fields of a range together. Set both band fields to null, with no size field, to remove the rule; with a size field it clears the band and keeps the rule, and the class total is no longer checked. Returns the rule before and after, and a restore_point_id. Key arguments: scenario_id, asset_class, optional band_min_pct, band_max_pct, target_pct, size_min_pct, size_max_pct, short_size_min_pct, short_size_max_pct, create_class.

Scenarios

write, destructive
Creates a scenario (rule set) or renames it; the old name isn’t kept. A new scenario is empty and not active: fill it with save_class_rule or apply_rules. Make it active with save_portfolio only when the user asks. Key arguments: scenario_id (to change one), name, description.
write, destructive
Deletes a scenario with its rules and its restore points, so it can’t be undone. Portfolios that used it have no active scenario until one is set. Key arguments: scenario_id, confirm_name.

Asset classes

write, destructive
Creates a custom asset class, or renames one. System classes and Cash can’t be renamed. Key arguments: asset_class (to change one), name, description.
write, destructive
Deletes a custom asset class that nothing uses. A class still used by holdings or rules is refused with IN_USE. System classes and Cash can’t be deleted. This can’t be undone. Key arguments: asset_class.
An asset_class argument takes a name, an alias such as Stocks, or an id. A name resolves to your own class first, then the system class, then the alias, which also goes to your own class of its name first.

Next steps

Write your rules

Write your rules as text by hand, with an AI, or from an existing statement.

Scenarios

A named set of rules for one portfolio. You can switch a portfolio between them.

Allocation bands

The rule that checks how much of your portfolio sits in each class.

Size ranges

The rule that caps or floors how large one holding can be.