finalynx.portfolio.targets

Module Contents

Classes

Target

Abstract class that defines an objective for a Node in the Portfolio tree.

TargetRange

Target to make sure your node stays within a specified range.

TargetMax

Target to make sure your node does not exceed a specified value.

TargetMin

Target to make sure your node does not go under a specified value.

TargetRatio

Target to make sure your node represents a specified ratio in a folder.

TargetGlobalRatio

Target to make sure your node represents a specified ratio in your portfolio.

API

class finalynx.portfolio.targets.Target[source]

Bases: finalynx.portfolio.hierarchy.Hierarchy

Abstract class that defines an objective for a Node in the Portfolio tree.

Initialization

Abstract Target class that holds the Node parent using this instance and provides a common logic for rendering the amounts.

RESULT_NOK

None

RESULT_OK

None

RESULT_TOLERATED

None

RESULT_INVEST

None

RESULT_DEVEST

None

RESULT_START

None

RESULT_NONE

None

get_amount() float[source]
Returns:

The amount stored in the target’s parent.

get_ideal() float[source]
Returns:

The ideal amount to be invested based on surrounding targets.

check() Dict[str, str][source]

Default behavior to check if the parent’s amount respects the target objective. This method should be overriden by all subclasses to define custom-tailored logic.

Returns:

A Target.RESULT_* object depending on the recommendation to be rendered in the output console.

prehint() str[source]

Virtual method for information to be printed between the amoutn and the name.

hint() str[source]

Virtual method for information to be printed at the end of the parent’s description.

get_ratio(absolute: bool = False) float[source]

Returns how much this amount represents agains the reference in percentage (0-100%).

Parameters:

absolute – If false, gives the relative percentage of this line to the parent folder. If true, gives the ratio between the current and ideal amount.

_get_parent_amount() float[source]
Returns:

The value to be checked against (parent’s amount).

render_ideal() str[source]

Ideal amount to be reached based on the current target and node position in the tree. Must be overridden by subclasses.

render_goal() str[source]

Ideal amount or ratio to be reached based on the current target and node position in the tree. Must be overridden by subclasses.

_render_target_name() str[source]
Returns:

The name of the target recommentation.

_render_target_symbol() str[source]
Returns:

The UFT-8 symbol associated to the target recommentation.

_render_target_color() str[source]
Returns:

The color associated to the target recommentation.

_render_currency() str[source]
Returns:

This parent’s currency symbol, used for target render methods.

to_dict() Dict[str, Any][source]

Empty dict, should be overridden by subclasses.

static from_dict(dict: Dict[str, Any]) finalynx.portfolio.targets.Target[source]
class finalynx.portfolio.targets.TargetRange(target_min: float, target_max: float, tolerance: float = 0)[source]

Bases: finalynx.portfolio.targets.Target

Target to make sure your node stays within a specified range.

Initialization

This target checks if the amount is between two values (with an optional tolerance).

Parameters:
  • target_min – Minimum threshold to get a RESULT_OK.

  • target_max – Maximum threshold to get a RESULT_OK.

  • tolerance – If the amount is between target_min - tolerance and target_max + tolerance, the check will return a RESULT_TOLERATED.

check() Dict[str, str][source]

This function checks the conditions described in the init method.

get_ideal() float[source]
Returns:

The ideal amount to be invested based on surrounding targets.

render_ideal() str[source]
Returns:

The average between target boundaries.

render_goal() str[source]
Returns:

Same as ideal amount.

_get_variable() float[source]

Internal method that gives the value to be checked (overriden by subclasses).

hint() str[source]
Returns:

A formatted description of the target (at the end of the line).

to_dict() Dict[str, Any][source]
class finalynx.portfolio.targets.TargetMax(target_max: float, tolerance: float = 0)[source]

Bases: finalynx.portfolio.targets.TargetRange

Target to make sure your node does not exceed a specified value.

Initialization

This target checks if the amount is below a specified threshold (with an optional tolerance).

Parameters:
  • target_max – Maximum threshold to get a RESULT_OK.

  • tolerance – If the amount is at most target_max + tolerance, the check will return a RESULT_TOLERATED.

get_ideal() float[source]
Returns:

The ideal amount to be invested based on surrounding targets.

hint() str[source]
Returns:

A formatted description of the target.

to_dict() Dict[str, Any][source]
class finalynx.portfolio.targets.TargetMin(target_min: float, tolerance: float = 0)[source]

Bases: finalynx.portfolio.targets.TargetRange

Target to make sure your node does not go under a specified value.

Initialization

This target checks if the amount is above a specified threshold (with an optional tolerance).

Parameters:
  • target_min – Minimum threshold to get a RESULT_OK.

  • tolerance – If the amount is at least target_min - tolerance, the check will return a RESULT_TOLERATED.

get_ideal() float[source]
Returns:

The ideal amount to be invested based on surrounding targets.

hint() str[source]
Returns:

A formatted description of the target.

to_dict() Dict[str, Any][source]
class finalynx.portfolio.targets.TargetRatio(target_ratio: float, zone: float = 4, tolerance: float = 2)[source]

Bases: finalynx.portfolio.targets.TargetRange

Target to make sure your node represents a specified ratio in a folder.

Initialization

This target checks if the amount represents a specified ratio of the total amounf of the parent node (with an optional tolerance).

Parameters:
  • target_ratio – Target to get a RESULT_OK.

  • zone – Accepted tolerance to still return a RESULT_OK.

  • tolerance – If the amount is between target_ratio - (zone + tolerance) / 2 and target_ratio + (zone + tolerance) / 2, the check will return a RESULT_TOLERATED.

get_ideal() float[source]
Returns:

How much this amount represents agains the reference in percentage (0-100%).

render_goal() str[source]
Returns:

The target ratio as a string.

_get_variable() float[source]
Returns:

The value to be checked.

hint() str[source]
Returns:

A formatted description of the target.

to_dict() Dict[str, Any][source]
class finalynx.portfolio.targets.TargetGlobalRatio(target_ratio: float, zone: float = 4, tolerance: float = 0)[source]

Bases: finalynx.portfolio.targets.TargetRatio

Target to make sure your node represents a specified ratio in your portfolio.

Initialization

This target checks if the amount represents a specified ratio of the total amount of your entire portfolio.

Parameters:
  • target_ratio – Target to get a RESULT_OK.

  • zone – Accepted tolerance to still return a RESULT_OK.

  • tolerance – If the amount is between target_ratio - (zone + tolerance) / 2 and target_ratio + (zone + tolerance) / 2, the check will return a RESULT_TOLERATED.

_get_parent_amount() float[source]
Returns:

The value to be checked against (portfolio amount).

hint() str[source]
Returns:

A formatted description of the target.

to_dict() Dict[str, Any][source]