## Working with Average Turnover Constraints Using PortfolioMAD Object

The turnover constraint is an optional linear absolute value constraint (see Average Turnover Constraints) that enforces an upper bound on the average of purchases and sales. The turnover constraint can be set using the PortfolioMAD object or the setTurnover function. The turnover constraint depends on an initial or current portfolio, which is assumed to be zero if not set when the turnover constraint is set. The turnover constraint has properties Turnover, for the upper bound on average turnover, and InitPort, for the portfolio against which turnover is computed.

### Setting Average Turnover Constraints Using the PortfolioMAD Function

The properties for the turnover constraints are set using the PortfolioMAD object. Suppose that you have an initial portfolio of 10 assets in a variable x0 and you want to ensure that average turnover is no more than 30%. To set this turnover constraint:

x0 = [ 0.12; 0.09; 0.08; 0.07; 0.1; 0.1; 0.15; 0.11; 0.08; 0.1 ];
p = PortfolioMAD('Turnover', 0.3, 'InitPort', x0);
disp(p.NumAssets)
disp(p.Turnover)
disp(p.InitPort)
10

0.3000

0.1200
0.0900
0.0800
0.0700
0.1000
0.1000
0.1500
0.1100
0.0800
0.1000
Note if the NumAssets or InitPort properties are not set before or when the turnover constraint is set, various rules are applied to assign default values to these properties (see Setting Up an Initial or Current Portfolio).

### Setting Average Turnover Constraints Using the setTurnover Function

You can also set properties for portfolio turnover using setTurnover to specify both the upper bound for average turnover and an initial portfolio. Suppose that you have an initial portfolio of 10 assets in a variable x0 and want to ensure that average turnover is no more than 30%. Given a PortfolioMAD object p, use setTurnover to set the turnover constraint with and without the initial portfolio being set previously:

x0 = [ 0.12; 0.09; 0.08; 0.07; 0.1; 0.1; 0.15; 0.11; 0.08; 0.1 ];
p = setTurnover(p, 0.3);

disp(p.NumAssets)
disp(p.Turnover)
disp(p.InitPort)
10

0.3000

0.1200
0.0900
0.0800
0.0700
0.1000
0.1000
0.1500
0.1100
0.0800
0.1000

or

x0 = [ 0.12; 0.09; 0.08; 0.07; 0.1; 0.1; 0.15; 0.11; 0.08; 0.1 ];
p = setTurnover(p, 0.3, x0);
disp(p.NumAssets)
disp(p.Turnover)
disp(p.InitPort)
10

0.3000

0.1200
0.0900
0.0800
0.0700
0.1000
0.1000
0.1500
0.1100
0.0800
0.1000

setTurnover implements scalar expansion on the argument for the initial portfolio. If the NumAssets property is already set in the PortfolioMAD object, a scalar argument for InitPort expands to have the same value across all dimensions. In addition, setTurnover lets you specify NumAssets as an optional argument. To clear turnover from your PortfolioMAD object, use the PortfolioMAD object or setTurnover with empty inputs for the properties to be cleared.