finalynx.portfolio.targets
ο
Module Contentsο
Classesο
Abstract class that defines an objective for a |
|
Target to make sure your node stays within a specified range. |
|
Target to make sure your node does not exceed a specified value. |
|
Target to make sure your node does not go under a specified value. |
|
Target to make sure your node represents a specified ratio in a folder. |
|
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_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_symbol() str [source]ο
- Returns:
The UFT-8 symbol associated to the target recommentation.
- _render_currency() str [source]ο
- Returns:
This parentβs currency symbol, used for target render methods.
- 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
andtarget_max + tolerance
, the check will return aRESULT_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.
- 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 aRESULT_TOLERATED
.
- 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 aRESULT_TOLERATED
.
- 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
andtarget_ratio + (zone + tolerance) / 2
, the check will return aRESULT_TOLERATED
.
- 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
andtarget_ratio + (zone + tolerance) / 2
, the check will return aRESULT_TOLERATED
.