Create Simple scenario-based Portfolio Optimization using tseries

This snippet explains how to compute a optimal Markowitz portfolio weights given a set of return scenarios.

Input: A two-dimensional data structure (matrix, data.frame) of asset return scenarios, i.e. a matrix or data frame data of asset return scenarios, where each row specifies a scenario for each asset. Please see Snippet: Portfolio Return Scenario Creation on how to create one by yourself. This snippet uses a previously prepared dataset from the package financeR.
Output: A Markowitz-risk-optimal portfolio (vector of asset weights, budget normalized).