macrosynergy.panel.converge_row#
Convergence of rows for max weight
- class ConvergeRow(row, max_weight, margin=0.001, max_loops=25)[source]#
Bases:
objectClass designed to receive a row of weights, where at least one weight in the aforementioned row exceeds the permitted upper-bound, and subsequently redistributes the excess evenly across all cross-sections.
- Parameters:
row (ndarray) – Array of weights.
max_weight (float) – Maximum weight.
margin (float) – Margin of error allowed in the convergence to within the upper-bound, “max_weight”.
max_loops (int) – Controls the accuracy: in theory, the greater the number of loops allowed, the more accurate the convergence. However, will only become significant if a tight margin is imposed: the “looser” the margin, the less likely the maximum number of loops permitted will be exceeded.
- classmethod application(row, max_weight)[source]#
Initiates the class and applies the redistribution of weights.
- distribute_simple()[source]#
Initiates an indefinite While Loop until the weights converge below the (max_weight + margin). Will evenly redistribute the excess weight across all active cross-sections, and will compute the maximum weight, the number of cross- sections above the threshold and the excess weight dynamically: through each iteration.