# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# getGroupRatio

Obtain group ratio constraint arrays from portfolio object

Use the `getGroupRatio` function with a `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` object to obtain group ratio constraint arrays from portfolio objects.

For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

## Syntax

``````[GroupA,GroupB,LowerRatio,UpperRatio] = getGroupRatio(obj)``````

## Description

example

``````[GroupA,GroupB,LowerRatio,UpperRatio] = getGroupRatio(obj)``` obtains equality constraint arrays from portfolio objects.```

## Examples

collapse all

Suppose you want to make sure that the ratio of financial to nonfinancial companies in your portfolios never goes above 50%. Assume you have 6 assets with 3 financial companies (assets 1-3) and 3 nonfinancial companies (assets 4-6). After setting group ratio constraints, obtain the values for `GroupA`, `GroupB`, `LowerRatio`, and `UpperRatio`.

```GA = [ true true true false false false ]; % financial companies GB = [ false false false true true true ]; % nonfinancial companies p = Portfolio; p = setGroupRatio(p, GA, GB, [], 0.5); [GroupA, GroupB, LowerRatio, UpperRatio] = getGroupRatio(p)```
```GroupA = 1 1 1 0 0 0 ```
```GroupB = 0 0 0 1 1 1 ```
```LowerRatio = [] ```
```UpperRatio = 0.5000 ```

Suppose you want to ensure that the ratio of financial to nonfinancial companies in your portfolios never exceeds 50%. Assume you have six assets with three financial companies (assets 1-3) and three nonfinancial companies (assets 4-6). After setting group ratio constraints, obtain the values for `GroupA`, `GroupB`, `LowerRatio`, and `UpperRatio`.

```GA = [ true true true false false false ]; % financial companies GB = [ false false false true true true ]; % nonfinancial companies p = PortfolioCVaR; p = setGroupRatio(p, GA, GB, [], 0.5); [GroupA, GroupB, LowerRatio, UpperRatio] = getGroupRatio(p)```
```GroupA = 1 1 1 0 0 0 ```
```GroupB = 0 0 0 1 1 1 ```
```LowerRatio = [] ```
```UpperRatio = 0.5000 ```

Suppose you want to ensure that the ratio of financial to nonfinancial companies in your portfolios never exceeds 50%. Assume you have six assets with three financial companies (assets 1-3) and three nonfinancial companies (assets 4-6). After setting group ratio constraints, obtain the values for `GroupA`, `GroupB`, `LowerRatio`, and `UpperRatio`.

```GA = [ true true true false false false ]; % financial companies GB = [ false false false true true true ]; % nonfinancial companies p = PortfolioMAD; p = setGroupRatio(p, GA, GB, [], 0.5); [GroupA, GroupB, LowerRatio, UpperRatio] = getGroupRatio(p)```
```GroupA = 1 1 1 0 0 0 ```
```GroupB = 0 0 0 1 1 1 ```
```LowerRatio = [] ```
```UpperRatio = 0.5000 ```

## Input Arguments

collapse all

Object for portfolio, specified using `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` object. For more information on creating a portfolio object, see

## Output Arguments

collapse all

Matrix that forms base groups for comparison, returned as a matrix for a `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` input object (`obj`).

Matrix that forms comparison groups, returned as a matrix `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` input object (`obj`).

Lower bound for ratio of `GroupB` groups to `GroupA` groups, returned as a vector for a `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` input object (`obj`).

Upper bound for ratio of `GroupB` groups to `GroupA` groups, returned as a vector for a `Portfolio`, `PortfolioCVaR`, or `PortfolioMAD` input object (`obj`).

## Tips

You can also use dot notation to obtain group ratio constraint arrays from portfolio objects.

`[GroupA, GroupB, LowerRatio, UpperRatio] = obj.getGroupRatio;`