finalynx.simulator.actions
Module Contents
Classes
Abstract base class to perform an action on the portfolio. |
|
Set an amount to a line. |
|
Add some amount to a line. |
|
Add the investment interests to each line (defined by the expected performance). |
|
Automatically apply Finalynx’s recommendations on the portfolio. |
API
- class finalynx.simulator.actions.Action(name: Optional[str] = None)[source]
Abstract base class to perform an action on the portfolio.
Initialization
Abstract class. An action describes a procedure to change something in the portfolio. For instance, when receiving a salary, an action could add some amount to the main account.
- abstract apply(portfolio: finalynx.portfolio.folder.Portfolio) List[finalynx.simulator.events.Event] [source]
Apply this action’s consequence, must be overridden.
- class finalynx.simulator.actions.SetLineAmount(target_line: finalynx.portfolio.line.Line, amount: float)[source]
Bases:
finalynx.simulator.actions.Action
Set an amount to a line.
Initialization
This action simply applies the new amount to the line. The timeline then processes the portfolio again to recalculate the SharedFolders’ values.
- apply(portfolio: finalynx.portfolio.folder.Portfolio) List[finalynx.simulator.events.Event] [source]
- class finalynx.simulator.actions.AddLineAmount(target_line: finalynx.portfolio.line.Line, amount: float)[source]
Bases:
finalynx.simulator.actions.Action
Add some amount to a line.
Initialization
This action simply applies the new amount to the line. The timeline then processes the portfolio again to recalculate the SharedFolders’ values.
- apply(portfolio: finalynx.portfolio.folder.Portfolio) List[finalynx.simulator.events.Event] [source]
- class finalynx.simulator.actions.ApplyPerformance(inflation: float = 2.0, period_years: float = 1.0)[source]
Bases:
finalynx.simulator.actions.Action
Add the investment interests to each line (defined by the expected performance).
Initialization
This action applies every line’s expected performance defined in
LinePerf
instances for the entire portfolio objecti.- Parameters:
inflation – Float to reduce each line’s performance by this number.
period_years – Duration to apply the performance on. E.g. for one month, use 1/12.
- apply(portfolio: finalynx.portfolio.folder.Portfolio) List[finalynx.simulator.events.Event] [source]
Applies the performance if set.
n_years
specifies the period to apply the performance over (e.g. 1 / 12 = 0.0833 for one month).- Returns:
The gained amount, or None if no perf was defined.
- _apply_perf(node: finalynx.portfolio.node.Node) None [source]
Traverse the tree, apply the performance for Lines, and collect the buckets for use later.
- class finalynx.simulator.actions.AutoBalance(name: Optional[str] = None)[source]
Bases:
finalynx.simulator.actions.Action
Automatically apply Finalynx’s recommendations on the portfolio.
Initialization
Abstract class. An action describes a procedure to change something in the portfolio. For instance, when receiving a salary, an action could add some amount to the main account.
- apply(portfolio: finalynx.portfolio.folder.Portfolio) List[finalynx.simulator.events.Event] [source]
This action automatically applies the ideal amounts auto-calculated in the portfolio tree. This only applies to
Line
andSharedFolder
instances that have aTargetRatio
target. The amounts are balanced depending on the target percentages for each node. Lines auto-added by envelope in folders are also balanced with equal percentages set for each child in the same folder.
- _get_ideals(node: finalynx.portfolio.node.Node) List[Any] [source]
Save the ideal amounts calculated in the tree before applying them to avoid inconsistent states.
- _set_ideals(node: finalynx.portfolio.node.Node, ideals: List[Any]) None [source]
Set the ideal amounts for each
Line
andSharedFolder
.