### Description

Random portfolios are a sample from the population of portfolios that obey some given set of constraints. The constraints are the key ingredient.

For example, we may want 5000 portfolios that obey the constraints:

- long-only
- 75 to 80 names in the portfolio
- no asset may contribute a fraction of more than 3% to the portfolio variance

### Implementation

The `random.portfolio`

function is used to produce random portfolios. This function takes the same arguments as `trade.optimizer`

plus an argument saying how many portfolios to generate and an argument saying whether to return the portfolios or the trades. It ignores the arguments concerning utility, and cost (unless there are cost constraints).

It is easy to generate random portfolios if there are only trivial constraints. However, when realistic constraints are placed on the portfolios, then efficiently generating the portfolios becomes a computational challenge.

See Constraints for the constraints that are implemented.

### See Also

- Random portfolios have a wide range of applications
- Random Portfolios in Finance
- The Random portfolios blog category