finalynx.portfolio.node
๏
Module Contents๏
Classes๏
Abstract class that represents an element in the Portfolio tree. |
API๏
- class finalynx.portfolio.node.Node(name: str, asset_class: finalynx.portfolio.constants.AssetClass = AssetClass.UNKNOWN, asset_subclass: finalynx.portfolio.constants.AssetSubclass = AssetSubclass.UNKNOWN, parent: Optional[finalynx.portfolio.folder.Folder] = None, target: Optional[finalynx.portfolio.targets.Target] = None, newline: bool = False, perf: Optional[finalynx.portfolio.constants.LinePerf] = None, currency: Optional[str] = None, envelope: Optional[finalynx.portfolio.envelope.Envelope] = None, aliases: Optional[Dict[str, str]] = None, agents: Optional[Dict[str, Callable[..., str]]] = None)[source]๏
Bases:
finalynx.portfolio.hierarchy.Hierarchy
,finalynx.portfolio.render.Render
Abstract class that represents an element in the Portfolio tree.
Initialization
This is an abstract class used by the
Line
andFolder
subclasses.- Parameters:
name โ The name that will be displayed in the final portfolio tree.
parent โ Parent of this node, passed up to the superclass
Hierarchy
.target โ Optional
Target
instance to format this lineโs amount based on the objective you selected.newline โ Print a new line in the console at the end of this
Line
for better readability.aliases โ Add or replace render aliases used when specifying a render format.
agents โ Add or replace keywords associated to rendering callbacks.
- get_ideal() float [source]๏
- Returns:
The ideal amount to be invested in this node based on surrounding targets.
- get_delta() float [source]๏
- Returns:
How much should be invested in this node to reach the ideal amount set by the target.
- abstract get_perf() finalynx.portfolio.constants.LinePerf [source]๏
- Returns:
The expected yearly performance of this node.
- tree(output_format: str = '[console]', _tree: Optional[rich.tree.Tree] = None, hide_root: bool = False, **render_args: Any) rich.tree.Tree [source]๏
Generate a fully rendered
Tree
object from therich
package using the specified format.This
Tree
can either be manipulated for further operations or directly printed to the console using richโsprint
method.- Parameters:
hide_amount โ Replace the amounts by simple dots (easier to share the result), defaults to False.
_tree โ Internal method to pass the folderโs root tree object to the children.
args โ Provide any list of arguments supported by the
Tree
class if this is the root folder in the hierarchy.
- Returns:
If the
_tree
argument is empty, the function returns a newTree
instance with this nodeโs render. Otherwise, it adds this nodeโs render as a child node and returns the_tree
.
- process() None [source]๏
Some
Node
orTarget
objects might need to process some data once the investment values have been fetched from Finary. Here, this method is left as esmpty but can be overridden by subclasses.
- _render_hint() str [source]๏
- Returns:
A formatted rendering of a hint message (at the end by default).
- _render_prehint() str [source]๏
- Returns:
A formatted rendering of a pre-hint message (next to the amount by default).
- _render_amount(hide_amounts: bool = False) str [source]๏
- Returns:
A formatted rendering of the node amount aligned with the other elements in the same parent.
- Parameters:
hide_amounts โ Replaces amoutn with a dummy amount with dots instead of the real amount (easier to share).
- _render_goal() str [source]๏
- Returns:
A formatted rendering of the target goal. This could either be an ideal amount or ratio to be reached.
- _render_ideal() str [source]๏
- Returns:
A formatted rendering of the ideal amount to be invested based on the target.
- _render_delta(align: bool = True, children: Optional[List[finalynx.portfolio.node.Node]] = None) str [source]๏
Creates a formatted rendering of the delta investment needed to reach the target.
- Parameters:
align โ Use the
children
parameter as a list of nodes to align all amounts vertically.children โ List of
Node
objects used for vertical alignemnt, defaults to this parentโs children.
- Returns:
The rendered string.