finalynx.simulator.actions

Module Contents

Classes

Action

Abstract base class to perform an action on the portfolio.

SetLineAmount

Set an amount to a line.

AddLineAmount

Add some amount to a line.

ApplyPerformance

Add the investment interests to each line (defined by the expected performance).

AutoBalance

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.

__str__() str[source]
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 and SharedFolder instances that have a TargetRatio 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 and SharedFolder.