Exposure & Portfolio

The Exposure object (pd.DataFrame with metadata) keeps track of the instruments, exposures, and initial exposures. The separation between exposures and initial exposures is used for computing expected returns or contributions to expected returns, with the initial exposures being used for transaction cost purposes. The Portfolio object additionally keeps track of an optional benchmark (used for benchmark relative optimization) as well as investment restrictions (used in all of optimization).

Portfolio constraints can be set directly using the methods of the Portfolio class or by specifying two tables (csv or xlsx). The first table contains all the vector definitions, i.e., individual lower and upper bounds as well as group and metric definitions.

The second table contains all the constraints definitions except for individual lower and upper bounds. The constraints can be defined by simply writing the name of the method without set in front, e.g., group_bounds. The parameters for the constraint method are then given in the subsequent columns of the table. It is possible to omit an argument by simply having an empty field or writing None.

Exposure(instruments, exposures=None, initial_exposures=None)

Function for creating a Fortitudo Technologies Exposure object (pd.DataFrame with metadata).

Parameters:
  • instruments (DataFrame) – pd.DataFrame containing instrument information with shape (I, 4).

  • exposures (Union[ndarray, list]) – np.ndarray or list with shape (I,) or (I, P) containing the exposures. Set to np.zeros(I) by default.

  • initial_exposures (Union[ndarray, list]) – np.ndarray or list with shape (I,) containing initial exposures. Set to exposures by default. initial_exposures is used when computing the expected return of exposures, taking possible transaction costs into account.

Return type:

DataFrame

Returns:

Fortitudo Technologies Exposure pd.DataFrame.

Raises:
  • ValueError – If there is a mismatch between instruments and exposures dimension.

  • ValueError – If there is a mismatch between exposures and initial_exposures dimension.

  • ValueError – If exposures is not an np.ndarray or list with at most two dimensions.

class Portfolio(exposures, benchmark=None)

Portfolio object that keeps track of current exposures, benchmark, and restrictions.

Parameters:
  • exposures (DataFrame) – Fortitudo Technologies Exposures pd.DataFrame containing the current portfolio exposures.

  • benchmark (DataFrame) – Fortitudo Technologies Exposures pd.DataFrame containing an optional benchmark. Default: None.

Raises:

ValueError – If there is a mismatch between exposures and benchmark dimensions or benchmark has multiple columns.

set_constraints_from_tables(vectors_path, constraints_path, sep=',', decimal='.')

Method for settings constraints from tabular data.

Parameters:
  • vectors_path (str) – Path to the file (csv or xlsx) containing individual lower and upper bounds as well as group and metric definitions.

  • constraints_path (str) – Path to the file (csv or xlsx) containing the list of constraints other than individual lower and upper bounds.

  • sep (str) – Separator for csv files. Default: ‘,’

  • decimal (str) – Decimal separator for csv files. Default: ‘.’

Raises:
  • TypeError – If vectors_path or constraints_path are not strings.

  • ValueError – If file extension is not .xlsx or .csv for vectors_path and constraints_path.

  • ValueError – If there is a mismatch between Portfolio and vector instruments.

  • ValueError – If constraint type is not supported.

  • ValueError – If a group or metric vector has not been defined but is referred to in the constraints list.

  • ValueError – If a constraint is misspecified, e.g., if a string value is given to a float argument.

set_esg_bounds(esg_metric, bound_lower=None, bound_upper=None)

Method for setting portfolio ESG metric bounds.

Parameters:
  • esg_metric (ndarray) – Vector with shape (I,) containing the ESG metric relative to exposure.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If esg_metric is not a vector with shape (I,).

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_esg_group_bounds(esg_metric, bound_lower=None, bound_upper=None)

Method for setting group ESG metric bounds.

Parameters:
  • esg_metric (ndarray) – Vector with shape (I,) containing the ESG metric relative to exposure and non-zero elements identifying the group.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If esg_metric is not a vector with shape (I,).

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_gross_exposure_max(bound)

Method for setting gross exposure max.

Parameters:

bound (Union[int, float]) – Value for the max gross exposure bound.

Raises:
  • TypeError – If bound is not an integer or float.

  • ValueError – If bound is not positive.

set_group_bounds(group, bound_lower=None, bound_upper=None)

Method for setting group bounds.

Parameters:
  • group (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the group.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If a group is not a np.ndarray with shape (I,) containing only 0’s and 1’s.

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_group_buy_sell_bounds(group, bound_buy=None, bound_sell=None)

Method for setting group buy and sell bounds.

Parameters:
  • group (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the group.

  • bound_buy (float) – Value for the buy upper bound. Default: None.

  • bound_sell (float) – Value for the sell upper bound. Default: None.

Raises:
  • ValueError – If a group is not a np.ndarray with shape (I,) containing only 0’s and 1’s.

  • TypeError – If bound_buy or bound_sell are not integers or floats.

set_group_proportion_bounds(group1, group2, bound_lower=None, bound_upper=None)

Method for setting group proportion bounds.

Parameters:
  • group1 (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the numerator group.

  • group2 (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the denominator group.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If a group is not a np.ndarray with shape (I,) containing only 0’s and 1’s.

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_group_ratio_bounds(group1, group2, bound_lower=None, bound_upper=None)

Method for setting group ratio bounds.

Parameters:
  • group1 (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the numerator group.

  • group2 (ndarray) – np.ndarray with shape (I,) containing 1’s and 0’s that identify the denominator group.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If group1 or group2 is not a np.ndarray with shape (I,) containing only 0’s and 1’s.

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_holding_cost_bounds(bound_lower=None, bound_upper=None)

Method for setting holding cost bounds.

Parameters:
  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:

TypeError – If bound_lower or bound_upper are not integers or floats.

set_individual_bounds(bound_lower=None, bound_upper=None)

Method for setting individual bounds.

Parameters:
  • bound_lower (ndarray) – np.ndarray with shape (I,) containing the individual lower bound values. Default: None.

  • bound_upper (ndarray) – np.ndarray with shape (I,) containing the individual upper bound values. Default: None.

Raises:

ValueError – If bound_lower or bound_upper is not a np.ndarray with shape (I,).

set_metric_bounds(metric, bound_lower=None, bound_upper=None)

Method for setting portfolio metric bounds.

Parameters:
  • metric (ndarray) – Vector with shape (I,) containing the metric relative to exposure.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If metric is not a vector with shape (I,).

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_metric_group_bounds(metric, bound_lower=None, bound_upper=None)

Method for setting group metric bounds.

Parameters:
  • metric (ndarray) – Vector with shape (I,) containing the metric relative to exposure and non-zero elements identifying the group.

  • bound_lower (float) – Value for the lower bound. Default: None.

  • bound_upper (float) – Value for the upper bound. Default: None.

Raises:
  • ValueError – If metric is not a vector with shape (I,).

  • TypeError – If bound_lower or bound_upper are not integers or floats.

set_net_exposure_bounds(bound_lower=None, bound_upper=None)

Method for setting net exposure bounds.

Parameters:
  • bound_lower (Union[int, float]) – Value for the lower bound. Default: None.

  • bound_upper (Union[int, float]) – Value for the upper bound. Default: None.

Raises:

TypeError – If bound_lower or bound_upper are not integers or floats.

set_turnover_max(bound)

Method for setting turnover max.

Parameters:

bound (Union[int, float]) – Value for the max turnover bound.

Raises:
  • TypeError – If bound is not an integer or float.

  • ValueError – If bound is not positive.